diff --git a/src/runtime/panic.go b/src/runtime/panic.go index cac51733..c7d3d14c 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -1,5 +1,10 @@ package runtime +// trap is a compiler hint that this function cannot be executed. It is +// translated into either a trap instruction or a call to abort(). +//go:linkname trap llvm.trap +func trap() + // Builtin function panic(msg), used as a compiler intrinsic. func _panic(message interface{}) { printstring("panic: ") diff --git a/src/runtime/runtime_wasm.go b/src/runtime/runtime_wasm.go index cf4eca69..8e58eec5 100644 --- a/src/runtime/runtime_wasm.go +++ b/src/runtime/runtime_wasm.go @@ -49,6 +49,7 @@ func align(ptr uintptr) uintptr { return (ptr + 3) &^ 3 } +// Abort executes the wasm 'unreachable' instruction. func abort() { - // TODO + trap() }