Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Support 'bail-out' from native code to signal debug/error-states/branches. #121

Closed
twitchyliquid64 opened this issue Apr 7, 2019 · 0 comments

Comments

@twitchyliquid64
Copy link
Contributor

twitchyliquid64 commented Apr 7, 2019

Just thinking aloud here, would appreciate any thoughts/feedback.

It would be good for native code to be able to return early to signal different states back to the interpreter.

  • Debug: Stack/local handling code can do bounds checks and return a value if bounds are every violated. We dont expect this to happen for verified modules, but it would be good to have this as a build flag like we have for the interpreter (to be sure).
  • (in the future) Branching: we can compute/store an 'outgoing branch table' for each native code sequence, and the native section can return back a specific code to signal a branch to another function, or even stuff like function calls.

Keeping things simple, I think we should implement this signalling through a int64 value on the stack, and by the native code returning. The int64 value can be packed something like this:

04 Bits: Return code (0 = no error, 1 = bounds check failed, 2 = unreachable, 3 = function call, 4 = branch, 5 = fatal error, remaining codes reserved
04 Bits: Reserved for future flags.
24 Bits: Index of the WASM instruction where the bail-out happened (ie: index into `BytecodeMetadata.Instructions`)
32 Bits: Jump target / Branch index / Code-specific-data.
@twitchyliquid64 twitchyliquid64 changed the title Support 'bail-out' Support 'bail-out' from native code to signal debug/error-states/branches. Apr 7, 2019
@sbinet sbinet closed this as completed in 41ac96a Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant