Source file src/runtime/stubs_wasmx.go
1 // Copyright 2024 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build wasm || wasm32 6 7 package runtime 8 9 // pause sets SP to newsp and pauses the execution of Go's WebAssembly 10 // code until an event is triggered, or call back into Go. 11 // 12 // Note: the epilogue of pause pops 8 bytes from the stack, so when 13 // returning to the host, the SP is newsp+8. 14 // If we want to set the SP such that when it calls back into Go, the 15 // Go function appears to be called from pause's caller's caller, then 16 // call pause with newsp = internal/runtime/sys.GetCallerSP()-16 (another 8 is 17 // the return PC pushed to the stack). 18 func pause(newsp uintptr) 19