-
Notifications
You must be signed in to change notification settings - Fork 667
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
Add instruction metering #4122
base: main
Are you sure you want to change the base?
Add instruction metering #4122
Conversation
Currently, there is no implementation on the AOT side since I'm not sure if this is really possible since we are dealing with compiled / native code. Regarding the classic/fast interpreter, I'm note sure about the save/restore of the context. It seems that |
#if WASM_INSTRUCTION_METERING != 0 | ||
#define CHECK_INSTRUCTION_LIMIT() \ | ||
if (instructions_left == 0) { \ | ||
goto return_func; \ |
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.
Thank you for contributing.
I totally agree with the concept of checking the meter in HANDLE_OP_END
.
However, I have reservations about this part. Clearly, running out of meter should not be equated with a normal return. It's more akin to being suspended or interrupted. Additionally, unlike a normal return, there is no return value for subsequent processing. Perhaps a special exception is needed.
Another one, When instructions_left == -1
, IIUC, this signifies unlimited instructions. We should bypass the calculation to minimize performance degradation, as this check occurs after every opcode execution.
Resolve #3927 and #2163.