-
Notifications
You must be signed in to change notification settings - Fork 25
feat: support jit to interpreter fallback #274
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
base: main
Are you sure you want to change the base?
Conversation
| - Cross-function fallback (limited to single function scope) | ||
|
|
||
| ## Success Criteria | ||
| - JIT-compiled EVM code can fallback to interpreter at any instruction boundary |
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.
design how to test this feature
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.
more test cases: stack flush/restore, memory consistency, gas, fallback triggers, error conditions, OutOfGas and revert in fallbacked interpreter, etc.
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.
a unittest is added
| const auto &RuntimeFunctions = getRuntimeFunctionTable(); | ||
| // Create a constant instruction for the target PC | ||
| MType *I64Type = &Ctx.I64Type; | ||
| MInstruction *PCConst = createIntConstInstruction(I64Type, targetPC); |
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.
only stack sized synced, are all stack elements in Instance now?
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.
currently we only call this after handleEndBlock
| intx::uint256 Value = 0; | ||
| for (size_t J = 0; J < ELEMENT_SIZE; ++J) { | ||
| Value = (Value << 8) + ElementData[J]; | ||
| } |
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.
what's the "proper byte order"?
need a testcase for this.
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.
add some simple test cases
| Frame->Stack[I] = Value; | ||
| } | ||
|
|
||
| // Ensure memory state consistency between JIT and interpreter |
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.
Would it be easier to test if we add a test option or hints for testing purposes (such as a specific offset or after a certain opcode) to specify a location where JIT falls back to the interpreter?
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.
yes. now we use 0xee as a trigger to fallback for testing
| endif() | ||
|
|
||
| if(ZEN_ENABLE_JIT_FALLBACK_TEST) | ||
| add_definitions(-DZEN_ENABLE_JIT_FALLBACK_TEST) |
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.
In the GitHub CI workflow, we should run tests for both scenarios: with ZEN_ENABLE_JIT_FALLBACK_TEST enabled and disabled.
After the tests pass, we can archive the openspec change.
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:
6. Release note