aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-10-18 12:31:11 +0200
committerRon Evans <[email protected]>2024-10-19 16:00:45 +0100
commit2f9e39e21c8d3ff2f1ee991bd9492da2e37162c3 (patch)
tree1052ba91daa9445bae6f20526406e2f6dfe7b7b2 /src/runtime
parentcd2bb8333d859a311d8ff9e94cb4e0fade8f65b3 (diff)
downloadtinygo-2f9e39e21c8d3ff2f1ee991bd9492da2e37162c3.tar.gz
tinygo-2f9e39e21c8d3ff2f1ee991bd9492da2e37162c3.zip
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.
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/runtime_wasm_js.go7
-rw-r--r--src/runtime/runtime_wasm_js_scheduler.go14
-rw-r--r--src/runtime/scheduler.go18
3 files changed, 0 insertions, 39 deletions
diff --git a/src/runtime/runtime_wasm_js.go b/src/runtime/runtime_wasm_js.go
index 89898b554..b49ffd15d 100644
--- a/src/runtime/runtime_wasm_js.go
+++ b/src/runtime/runtime_wasm_js.go
@@ -4,13 +4,6 @@ package runtime
type timeUnit float64 // time in milliseconds, just like Date.now() in JavaScript
-// wasmNested is used to detect scheduler nesting (WASM calls into JS calls back into WASM).
-// When this happens, we need to use a reduced version of the scheduler.
-//
-// TODO: this variable can probably be removed once //go:wasmexport is the only
-// allowed way to export a wasm function (currently, //export also works).
-var wasmNested bool
-
var handleEvent func()
//go:linkname setEventHandler syscall/js.setEventHandler
diff --git a/src/runtime/runtime_wasm_js_scheduler.go b/src/runtime/runtime_wasm_js_scheduler.go
index 94018336e..9fd8c4554 100644
--- a/src/runtime/runtime_wasm_js_scheduler.go
+++ b/src/runtime/runtime_wasm_js_scheduler.go
@@ -8,24 +8,10 @@ func resume() {
handleEvent()
}()
- if wasmNested {
- minSched()
- return
- }
-
- wasmNested = true
scheduler(false)
- wasmNested = false
}
//export go_scheduler
func go_scheduler() {
- if wasmNested {
- minSched()
- return
- }
-
- wasmNested = true
scheduler(false)
- wasmNested = false
}
diff --git a/src/runtime/scheduler.go b/src/runtime/scheduler.go
index 2f2287652..3f726a064 100644
--- a/src/runtime/scheduler.go
+++ b/src/runtime/scheduler.go
@@ -247,24 +247,6 @@ func scheduler(returnAtDeadlock bool) {
}
}
-// This horrible hack exists to make WASM work properly.
-// 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.
-// Thus there are two copies of the scheduler running at once.
-// This is a reduced version of the scheduler which does not deal with the timer queue (that is a problem for the outer scheduler).
-func minSched() {
- scheduleLog("start nested scheduler")
- for !schedulerDone {
- t := runqueue.Pop()
- if t == nil {
- break
- }
-
- scheduleLogTask(" run:", t)
- t.Resume()
- }
- scheduleLog("stop nested scheduler")
-}
-
func Gosched() {
runqueue.Push(task.Current())
task.Pause()