aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/asm_wasm.s
diff options
context:
space:
mode:
authorJohan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>2023-03-24 23:07:58 -0700
committerGopher Robot <gobot@golang.org>2023-04-05 19:28:25 +0000
commit99de78e175bed03e21e0da72d2f084c88e4f62ad (patch)
tree695fc1cf5ec100426b3dd72f4bb846b5f0b71f0e /src/runtime/asm_wasm.s
parentc00e9285eae4599f6a123d0a355633379be998e8 (diff)
downloadgo-99de78e175bed03e21e0da72d2f084c88e4f62ad.tar.xz
all: add wasip1 asm and link logic
Add wasip1 asm and symbols to cmd/internal/obj, cmd/link and runtime. For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: Ie088d9b65ea13e231694af6341465f95be33093f Reviewed-on: https://go-review.googlesource.com/c/go/+/479617 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/runtime/asm_wasm.s')
-rw-r--r--src/runtime/asm_wasm.s41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/runtime/asm_wasm.s b/src/runtime/asm_wasm.s
index 330c10cc0c..9cd8b5a99f 100644
--- a/src/runtime/asm_wasm.s
+++ b/src/runtime/asm_wasm.s
@@ -15,7 +15,9 @@ TEXT runtime·rt0_go(SB), NOSPLIT|NOFRAME|TOPFRAME, $0
// set g to g0
MOVD $runtime·g0(SB), g
CALLNORESUME runtime·check(SB)
+#ifdef GOOS_js
CALLNORESUME runtime·args(SB)
+#endif
CALLNORESUME runtime·osinit(SB)
CALLNORESUME runtime·schedinit(SB)
MOVD $runtime·mainPC(SB), 0(SP)
@@ -482,3 +484,42 @@ TEXT runtime·gcWriteBarrier8<ABIInternal>(SB),NOSPLIT,$0
I64Const $64
Call gcWriteBarrier<>(SB)
Return
+
+TEXT wasm_pc_f_loop(SB),NOSPLIT,$0
+// Call the function for the current PC_F. Repeat until PAUSE != 0 indicates pause or exit.
+// The WebAssembly stack may unwind, e.g. when switching goroutines.
+// The Go stack on the linear memory is then used to jump to the correct functions
+// with this loop, without having to restore the full WebAssembly stack.
+// It is expected to have a pending call before entering the loop, so check PAUSE first.
+ Get PAUSE
+ I32Eqz
+ If
+ loop:
+ Loop
+ // Get PC_B & PC_F from -8(SP)
+ Get SP
+ I32Const $8
+ I32Sub
+ I32Load16U $0 // PC_B
+
+ Get SP
+ I32Const $8
+ I32Sub
+ I32Load16U $2 // PC_F
+
+ CallIndirect $0
+ Drop
+
+ Get PAUSE
+ I32Eqz
+ BrIf loop
+ End
+ End
+
+ I32Const $0
+ Set PAUSE
+
+ Return
+
+TEXT wasm_export_lib(SB),NOSPLIT,$0
+ UNDEF