feat: support jit to interpreter fallback#274
feat: support jit to interpreter fallback#274starwarfan wants to merge 10 commits intoDTVMStack:mainfrom
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.
design how to test this feature
There was a problem hiding this comment.
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.
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.
only stack sized synced, are all stack elements in Instance now?
There was a problem hiding this comment.
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.
what's the "proper byte order"?
need a testcase for this.
There was a problem hiding this comment.
add some simple test cases
| Frame->Stack[I] = Value; | ||
| } | ||
|
|
||
| // Ensure memory state consistency between JIT and interpreter |
There was a problem hiding this comment.
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.
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.
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.
There was a problem hiding this comment.
evm asm and jitFallbackExecutionTest are added
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