diff options
author | Blealtan <blealtan@outlook.com> | 2018-02-07 07:27:11 +0300 |
---|---|---|
committer | Morgan Brown <morganbr@users.noreply.github.com> | 2018-02-07 07:27:11 +0300 |
commit | eba7180dc25ff12d8989cc2eec2a0e7803071609 (patch) | |
tree | 301e1fd324c0cc64774c1b1fcef9dcae4c8e2d1a /src/ILCompiler.WebAssembly | |
parent | 6a0654db927ead2f8a2d4a038da292cb367e6be5 (diff) |
Implement break opcode as llvm.debugtrap (#5344)
* Implement break opcode as llvm.debugtrap.
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 #4511
Set IsDebuggerPresent to TRUE in case of WASM. Although
`Debugger._isDebuggerAttached` is not set, this modify itself will allow
`Debugger.Break` to work.
Add test in HelloWasm for `Debugger.Break`.
Diffstat (limited to 'src/ILCompiler.WebAssembly')
-rw-r--r-- | src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs | 5 | ||||
-rw-r--r-- | src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter_Statics.cs | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs index 1e1c20470..037140bb6 100644 --- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs +++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter.cs @@ -327,6 +327,11 @@ namespace Internal.IL private void ImportBreak() { + if (DebugtrapFunction.Pointer == IntPtr.Zero) + { + DebugtrapFunction = LLVM.AddFunction(Module, "llvm.debugtrap", LLVM.FunctionType(LLVM.VoidType(), Array.Empty<LLVMTypeRef>(), false)); + } + LLVM.BuildCall(_builder, DebugtrapFunction, Array.Empty<LLVMValueRef>(), string.Empty); } private void ImportLoadVar(int index, bool argument) diff --git a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter_Statics.cs b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter_Statics.cs index 002e5e916..ad6bc1c78 100644 --- a/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter_Statics.cs +++ b/src/ILCompiler.WebAssembly/src/CodeGen/ILToWebAssemblyImporter_Statics.cs @@ -100,6 +100,7 @@ namespace Internal.IL methodCodeNodeNeedingCode.SetDependencies(ilImporter.GetDependencies()); } + static LLVMValueRef DebugtrapFunction = default(LLVMValueRef); static LLVMValueRef TrapFunction = default(LLVMValueRef); static LLVMValueRef DoNothingFunction = default(LLVMValueRef); |