internal/task: swap stack chain when switching goroutines

This change swaps the stack chain when switching goroutines, ensuring that the chain is maintained consistently.
This is only really currently necessary with asyncify on wasm.
This commit is contained in:
Nia Waldvogel
2021-12-14 16:48:11 -05:00
committed by Ayke
parent d5c0083085
commit e4de7b4957
10 changed files with 51 additions and 4 deletions
+7
View File
@@ -1,3 +1,4 @@
//go:build (gc.conservative || gc.extalloc) && tinygo.wasm
// +build gc.conservative gc.extalloc
// +build tinygo.wasm
@@ -37,3 +38,9 @@ func markStack() {
// construction. Calls to it are later replaced with regular stack bookkeeping
// code.
func trackPointer(ptr unsafe.Pointer)
// swapStackChain swaps the stack chain.
// This is called from internal/task when switching goroutines.
func swapStackChain(dst **stackChainObject) {
*dst, stackChainStart = stackChainStart, *dst
}