Skip to content
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

Merged
merged 1 commit into from
Jan 31, 2025
Merged

Implement Nop #320

merged 1 commit into from
Jan 31, 2025

Conversation

vorosl
Copy link
Contributor

@vorosl vorosl commented Jan 16, 2025

I've implemented Nop, it is useful for debugging.

@@ -455,7 +455,7 @@ void JITCompiler::buildVariables(uint32_t requiredStackSize)
}

if (instr->opcode() == ByteCode::ThrowOpcode || instr->opcode() == ByteCode::UnreachableOpcode
|| instr->opcode() == ByteCode::EndOpcode) {
|| instr->opcode() == ByteCode::EndOpcode || instr->opcode() == ByteCode::NopOpcode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop is not a control transfer instruction.

@@ -25,28 +25,29 @@

#include "wabt/walrus/binary-reader-walrus.h"

#define EXECUTE_VALIDATOR(expr) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file is changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the autoformat formatted it. Should I turn off the autoformat for this file?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is probably not checked by the CI, you can just ignore it without changes.

@@ -1447,6 +1447,13 @@ ByteCodeStackOffset* Interpreter::interpret(ExecutionState& state,
NEXT_INSTRUCTION();
}

DEFINE_OPCODE(Nop)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be debug only.

@@ -1404,6 +1404,10 @@ static void compileFunction(JITCompiler* compiler)
compiler->append(byteCode, group, opcode, 0, 0);
break;
}
case ByteCode::NopOpcode: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug only.

@vorosl vorosl force-pushed the nop branch 4 times, most recently from 145521e to aa3a087 Compare January 17, 2025 10:42
@vorosl vorosl requested a review from zherczeg January 17, 2025 11:26
@clover2123
Copy link
Collaborator

Where is this nop instruction used? just for debugging?

@zherczeg
Copy link
Collaborator

That is the plan. It should be debug only. In some time sensitive tasks, it could do something, but WebAssembly is high level for such cases.

Comment on lines +1348 to +1352
case ByteCode::NopOpcode: {
sljit_emit_op0(m_compiler, SLJIT_NOP);
break;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree! The patch is not ready yet

Copy link
Collaborator

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

@@ -30,6 +30,7 @@ namespace Walrus {
class FunctionType;

#define FOR_EACH_BYTECODE_OP(F) \
F(Nop) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have any side effects?

@@ -2475,6 +2476,22 @@ class Throw : public ByteCode {
uint32_t m_tagIndex;
uint32_t m_offsetsSize;
};
#if !defined(NDEBUG)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline before.

@@ -1446,7 +1446,14 @@ ByteCodeStackOffset* Interpreter::interpret(ExecutionState& state,
ASSERT_NOT_REACHED();
NEXT_INSTRUCTION();
}

#if !defined(NDEBUG)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline before.

@vorosl vorosl force-pushed the nop branch 3 times, most recently from 38b674d to 3ee510a Compare January 27, 2025 13:17
@@ -78,6 +79,58 @@ class FunctionType;
F(Store32) \
F(Store64) \
F(FillOpcodeTable)
#else /* !NDEBUG */
#define FOR_EACH_BYTECODE_OP(F) \
Copy link
Collaborator

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?

Signed-off-by: Laszlo Voros <[email protected]>
Copy link
Collaborator

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@clover2123 clover2123 merged commit d94bad3 into Samsung:main Jan 31, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants