In resume instruction, update StackLimits from generated code #223
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 PR is part of a series that implements native stack switching.
This particular PR moves one particular aspect out of the
tc_resume
libcall: Updating theStackLimits
object of the parent of the continuation being resumed.Doing this inside the libcall had practical reasons: We needed access to the updated
last_wasm_exit_pc
/last_wasm_exit_fp
value in theVMRuntimeLimits
in order to copy them into theStackLimits
. However, these values are only updated by the libcall mechanism itself, so they are only available inside the libcall implementation itself.This PR obtains the corresponding values using code generated for
resume
, before the actualtc_resume
libcall happening, and writes them into theStackLimits
.get_frame_pointer
instruction to obtain a value forlast_wasm_exit_fp
.last_wasm_exit_pc
is obtained using a new CLIF instruction,get_instruction_pointer
. All this does is giving us some instruction pointer that is guaranteed to be associated with the current Wasm instruction being translated (i.e.,resume
in our case). While this means that we will write slightly different values forlast_wasm_exit_pc
into theStackLimits
than before, this difference does not matter at all for backtrace creation.last_wasm_exit_pc
is never used for control flow (i.e., it is never branched to), all that matters is what Wasm instruction it is associated with.I consider this to be a workaround, once native stack switching is fully rolled out it would be nice to overhaul the whole backtrace generation mechanism in the longer term. But this PR's goal is to make it possible to move to native stack switching with as little changes to backtrace creation as possible.