Skip to content

Commit 2f9e39e

Browse files
aykevldeadprogram
authored andcommitted
runtime: remove minSched hack for wasm
I am not entirely sure what it's doing (it seems related to js.FuncOf), but tests still seem to pass when this code is removed. So let's remove it.
1 parent cd2bb83 commit 2f9e39e

File tree

3 files changed

+0
-39
lines changed

3 files changed

+0
-39
lines changed

src/runtime/runtime_wasm_js.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ package runtime
44

55
type timeUnit float64 // time in milliseconds, just like Date.now() in JavaScript
66

7-
// wasmNested is used to detect scheduler nesting (WASM calls into JS calls back into WASM).
8-
// When this happens, we need to use a reduced version of the scheduler.
9-
//
10-
// TODO: this variable can probably be removed once //go:wasmexport is the only
11-
// allowed way to export a wasm function (currently, //export also works).
12-
var wasmNested bool
13-
147
var handleEvent func()
158

169
//go:linkname setEventHandler syscall/js.setEventHandler

src/runtime/runtime_wasm_js_scheduler.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,10 @@ func resume() {
88
handleEvent()
99
}()
1010

11-
if wasmNested {
12-
minSched()
13-
return
14-
}
15-
16-
wasmNested = true
1711
scheduler(false)
18-
wasmNested = false
1912
}
2013

2114
//export go_scheduler
2215
func go_scheduler() {
23-
if wasmNested {
24-
minSched()
25-
return
26-
}
27-
28-
wasmNested = true
2916
scheduler(false)
30-
wasmNested = false
3117
}

src/runtime/scheduler.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -247,24 +247,6 @@ func scheduler(returnAtDeadlock bool) {
247247
}
248248
}
249249

250-
// This horrible hack exists to make WASM work properly.
251-
// When a WASM program calls into JS which calls back into WASM, the event with which we called back in needs to be handled before returning.
252-
// Thus there are two copies of the scheduler running at once.
253-
// This is a reduced version of the scheduler which does not deal with the timer queue (that is a problem for the outer scheduler).
254-
func minSched() {
255-
scheduleLog("start nested scheduler")
256-
for !schedulerDone {
257-
t := runqueue.Pop()
258-
if t == nil {
259-
break
260-
}
261-
262-
scheduleLogTask(" run:", t)
263-
t.Resume()
264-
}
265-
scheduleLog("stop nested scheduler")
266-
}
267-
268250
func Gosched() {
269251
runqueue.Push(task.Current())
270252
task.Pause()

0 commit comments

Comments
 (0)