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
+2
View File
@@ -104,6 +104,7 @@ func (*stackState) unwind()
func (t *Task) Resume() {
// The current task must be saved and restored because this can nest on WASM with JS.
prevTask := currentTask
t.gcData.swap()
currentTask = t
if !t.state.launched {
t.state.launch()
@@ -112,6 +113,7 @@ func (t *Task) Resume() {
t.state.rewind()
}
currentTask = prevTask
t.gcData.swap()
if t.state.asyncifysp > t.state.csp {
runtimePanic("stack overflow")
}