diff options
Diffstat (limited to 'src/runtime/rt0_js_wasm.s')
| -rw-r--r-- | src/runtime/rt0_js_wasm.s | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/runtime/rt0_js_wasm.s b/src/runtime/rt0_js_wasm.s index c4efd9637c..b22c46e2e9 100644 --- a/src/runtime/rt0_js_wasm.s +++ b/src/runtime/rt0_js_wasm.s @@ -31,14 +31,9 @@ TEXT wasm_export_run(SB),NOSPLIT,$0 I64ExtendI32U I64Store $8 - I32Const $runtime·rt0_go(SB) - I32Const $16 - I32ShrU - Set PC_F - - I32Const $0 - Set PC_B - + I32Const $0 // entry PC_B + Call runtime·rt0_go(SB) + Drop Call wasm_pc_f_loop(SB) Return @@ -46,14 +41,9 @@ TEXT wasm_export_run(SB),NOSPLIT,$0 // wasm_export_resume gets called from JavaScript. It resumes the execution of Go code until it needs to wait for // an event. TEXT wasm_export_resume(SB),NOSPLIT,$0 - I32Const $runtime·handleEvent(SB) - I32Const $16 - I32ShrU - Set PC_F - I32Const $0 - Set PC_B - + Call runtime·handleEvent(SB) + Drop Call wasm_pc_f_loop(SB) Return @@ -63,15 +53,30 @@ TEXT wasm_pc_f_loop(SB),NOSPLIT,$0 // 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. -loop: - Loop - Get PC_F - CallIndirect $0 - Drop +// 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 - Get PAUSE - I32Eqz - BrIf loop + CallIndirect $0 + Drop + + Get PAUSE + I32Eqz + BrIf loop + End End I32Const $0 @@ -91,6 +96,7 @@ TEXT runtime·pause(SB), NOSPLIT, $0-8 RETUNWIND TEXT runtime·exit(SB), NOSPLIT, $0-4 + I32Const $0 Call runtime·wasmExit(SB) Drop I32Const $1 |
