wasmtime
wasmtime copied to clipboard
winch: Move the stack overflow check to the function prologue
Move the stack check to the function prologue in winch generated code by adding the final stack maximum to the stack min bound before comparing against the current SP.
This new approach is more accurate than the previous implementation that would only check the size of locals
, but does require that we patch the function during MacroAssembler::finalize
, as we don't know the stack high water mark until then. Enabling the patching required the addition of the start_patchable
/end_patchable
api to MachBuffer
, which gives a way to name sections of the code buffer (with some restrictions) that can be edited later. We use this then to modify an add-with-immediate instruction to add the used stack space to the stack lower bound from vmctx
, when finalizing the function.
The tests are failing due to the addition of stack checking to one of the trampolines (as the vmctx isn't setup yet in one case). I might roll those back so that this can be debugged separately.
Subscribe to Label Action
cc @saulecabrera
Thus the following users have been cc'd because of the following labels:
- saulecabrera: winch
To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json
configuration file.