Implement instruction metering resume#4902
Open
AlixANNERAUD wants to merge 1 commit intobytecodealliance:mainfrom
Open
Implement instruction metering resume#4902AlixANNERAUD wants to merge 1 commit intobytecodealliance:mainfrom
AlixANNERAUD wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
…ctionality and add tests
986030e to
41dd8a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for resuming WebAssembly execution after an instruction metering trap in both the classic and fast interpreter modes. When the instruction budget is exhausted, the runtime now preserves interpreter state, allowing the host to set a new budget and resume execution from where it left off, rather than restarting the function. This is achieved through new APIs, changes to execution environment state, and updates to the interpreter logic.
Instruction Metering & Resumption Enhancements:
WASMExecEnvto track metering suspension state and the necessary context to resume execution (metering_suspended,metering_suspend_frame,metering_suspend_function,metering_suspend_argc,metering_suspend_argv). [1] [2]wasm_runtime_resume_wasmAPI, allowing the host to resume execution after an instruction limit trap, with documentation added towasm_export.hand header exposure inwasm_runtime_common.h. [1] [2] [3]Interpreter Logic Updates (Classic & Fast):
wasm_interp_classic.c) and fast (wasm_interp_fast.c) interpreters to detect instruction metering exceptions, preserve interpreter state on trap, and resume execution from the correct frame and instruction pointer when requested. This includes careful frame management and state clearing. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]Instruction Metering Robustness:
Documentation: