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

Implement break opcode as trap #4511

Closed
morganbr opened this issue Sep 15, 2017 · 2 comments
Closed

Implement break opcode as trap #4511

morganbr opened this issue Sep 15, 2017 · 2 comments

Comments

@morganbr
Copy link
Contributor

Implement the break opcode. This normally breaks in a debugger, but that doesn't seem to be possible in WebAssembly, so we should start by implementing it as a trap. The method that handles the break opcode is

@morganbr
Copy link
Contributor Author

llvm.debugtrap might even stop the debugger correctly.

@Blealtan
Copy link
Contributor

Blealtan commented Feb 3, 2018

Experimented on @llvm.debugtrap. Emscripten generates it to a call to imported function asm2wasm.debugger, which is in turn implemented in js as the js statement debugger;; LLVM generates it into instruction unreachable, which is implemented in browsers as trap. As currently this is the only two implementation that generate LLVM IR directly into WASM, using @llvm.debugtrap intrinsic should be the best manner. Working on this.

Blealtan added a commit to Blealtan/corert that referenced this issue Feb 3, 2018
In Emscripten, `llvm.debugtrap` is implemented as a round-trip call to
`debugger;` statement JavaScript which will invoke debugger in browsers;
and in LLVM it's implemented as `unreachable` instruction of WASM. This
should be a better match than `llvm.trap` on `break` opcode semantics.

Fix dotnet#4511
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants