mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 04:23:41 +00:00
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:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user