-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Nop #320
Implement Nop #320
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,14 @@ namespace Walrus { | |
|
||
class FunctionType; | ||
|
||
#if defined(NDEBUG) | ||
#define F_NOP(F) | ||
#else /* !NDEBUG */ | ||
#define F_NOP(F) F(Nop) | ||
#endif /* NDEBUG */ | ||
|
||
#define FOR_EACH_BYTECODE_OP(F) \ | ||
F_NOP(F) \ | ||
F(Unreachable) \ | ||
F(Throw) \ | ||
F(End) \ | ||
|
@@ -2476,6 +2483,24 @@ class Throw : public ByteCode { | |
uint32_t m_offsetsSize; | ||
}; | ||
|
||
#if !defined(NDEBUG) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline before. |
||
class Nop : public ByteCode { | ||
public: | ||
Nop() | ||
: ByteCode(Opcode::NopOpcode) | ||
{ | ||
} | ||
|
||
|
||
void dump(size_t pos) | ||
{ | ||
printf("nop"); | ||
} | ||
|
||
protected: | ||
}; | ||
#endif /* !NDEBUG*/ | ||
|
||
class Unreachable : public ByteCode { | ||
public: | ||
Unreachable() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1447,6 +1447,15 @@ ByteCodeStackOffset* Interpreter::interpret(ExecutionState& state, | |
NEXT_INSTRUCTION(); | ||
} | ||
|
||
#if !defined(NDEBUG) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add newline before. |
||
DEFINE_OPCODE(Nop) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be debug only. |
||
: | ||
{ | ||
ADD_PROGRAM_COUNTER(Nop); | ||
NEXT_INSTRUCTION(); | ||
} | ||
#endif /* !NDEBUG */ | ||
|
||
DEFINE_OPCODE(End) | ||
: | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1345,6 +1345,12 @@ void JITCompiler::compileFunction(JITFunction* jitFunc, bool isExternal) | |
m_context.appendTrapJump(ExecutionContext::GenericTrap, sljit_emit_jump(m_compiler, SLJIT_JUMP)); | ||
break; | ||
} | ||
#if !defined(NDEBUG) | ||
case ByteCode::NopOpcode: { | ||
sljit_emit_op0(m_compiler, SLJIT_NOP); | ||
break; | ||
} | ||
Comment on lines
+1349
to
+1352
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit) what about enabling this code only in debug mode? Or it doesn't matter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree! The patch is not ready yet |
||
#endif /* !NDEBUG */ | ||
case ByteCode::EndOpcode: { | ||
emitEnd(m_compiler, item->asInstruction()); | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1404,6 +1404,12 @@ static void compileFunction(JITCompiler* compiler) | |
compiler->append(byteCode, group, opcode, 0, 0); | ||
break; | ||
} | ||
#if !defined(NDEBUG) | ||
case ByteCode::NopOpcode: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug only. |
||
compiler->append(byteCode, group, opcode, 0, 0); | ||
break; | ||
} | ||
#endif /* !NDEBUG */ | ||
case ByteCode::JumpOpcode: { | ||
Jump* jump = reinterpret_cast<Jump*>(byteCode); | ||
compiler->appendBranch(jump, opcode, labels[COMPUTE_OFFSET(idx, jump->offset())], 0); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicating the entire macro is not a good idea.
What about defining a F_NOP macro which is empty or
F(Nop)
depending on debug?