aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-08-07 11:52:39 -0400
committerCherry Mui <cherryyz@google.com>2024-08-12 16:17:19 +0000
commit2ebe15c67e1989ccf962d587df1d4d18eb188da2 (patch)
treeec3371db2651beeae3a0ed567dd8fe0d6a42438e /src/cmd/link
parentd36353499f673c89a267a489beb80133a14a75f9 (diff)
downloadgo-2ebe15c67e1989ccf962d587df1d4d18eb188da2.tar.xz
cmd/internal/obj/wasm: handle stack unwinding in wasmexport
CL 603055 added basic support of wasmexport. This CL follows it and adds stack unwinding handling. If the wasmexport Go function returns normally, we directly return to the host. If the Go function unwinds the stack (e.g. goroutine switch, stack growth), we need to run a PC loop to call functions on the new stack, similar to wasm_pc_f_loop. One difference is that when the wasmexport function returns normally, we need to exit the loop and return to the host. Now a wasmimport function can call back into the Go via wasmexport. During the callback the stack could have moved. The wasmimport code needs to read a new SP after the host function returns, instead of assuming the SP doesn't change. For #65199. Change-Id: I62c1cde1c46f7eb72625892dea41e8137b361891 Reviewed-on: https://go-review.googlesource.com/c/go/+/603836 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
Diffstat (limited to 'src/cmd/link')
-rw-r--r--src/cmd/link/internal/wasm/asm.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/cmd/link/internal/wasm/asm.go b/src/cmd/link/internal/wasm/asm.go
index cdd8de467d..5b36ea0fbc 100644
--- a/src/cmd/link/internal/wasm/asm.go
+++ b/src/cmd/link/internal/wasm/asm.go
@@ -73,6 +73,7 @@ var wasmFuncTypes = map[string]*wasmFuncType{
"wasm_export_resume": {Params: []byte{}}, //
"wasm_export_getsp": {Results: []byte{I32}}, // sp
"wasm_pc_f_loop": {Params: []byte{}}, //
+ "wasm_pc_f_loop_export": {Params: []byte{I32}}, // pc_f
"runtime.wasmDiv": {Params: []byte{I64, I64}, Results: []byte{I64}}, // x, y -> x/y
"runtime.wasmTruncS": {Params: []byte{F64}, Results: []byte{I64}}, // x -> int(x)
"runtime.wasmTruncU": {Params: []byte{F64}, Results: []byte{I64}}, // x -> uint(x)