]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/obj/wasm: handle stack unwinding in wasmexport
authorCherry Mui <cherryyz@google.com>
Wed, 7 Aug 2024 15:52:39 +0000 (11:52 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 12 Aug 2024 16:17:19 +0000 (16:17 +0000)
commit2ebe15c67e1989ccf962d587df1d4d18eb188da2
treeec3371db2651beeae3a0ed567dd8fe0d6a42438e
parentd36353499f673c89a267a489beb80133a14a75f9
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>
src/cmd/compile/internal/ssagen/abi.go
src/cmd/internal/obj/wasm/wasmobj.go
src/cmd/link/internal/wasm/asm.go
src/runtime/asm_wasm.s