]> Cypherpunks repositories - gostls13.git/commit
runtime, sycall/js: add support for callbacks from JavaScript
authorRichard Musiol <mail@richard-musiol.de>
Sat, 19 May 2018 22:56:36 +0000 (00:56 +0200)
committerAustin Clements <austin@google.com>
Thu, 14 Jun 2018 21:50:53 +0000 (21:50 +0000)
commite083dc6307b6593bdd44b219ffd21699d6f17fd7
tree2a411d82639a778c6aa107529b1d708034c7a7f1
parent5fdacfa89f871888d6f8fde726b8f95f11e674d6
runtime, sycall/js: add support for callbacks from JavaScript

This commit adds support for JavaScript callbacks back into
WebAssembly. This is experimental API, just like the rest of the
syscall/js package. The time package now also uses this mechanism
to properly support timers without resorting to a busy loop.

JavaScript code can call into the same entry point multiple times.
The new RUN register is used to keep track of the program's
run state. Possible values are: starting, running, paused and exited.
If no goroutine is ready any more, the scheduler can put the
program into the "paused" state and the WebAssembly code will
stop running. When a callback occurs, the JavaScript code puts
the callback data into a queue and then calls into WebAssembly
to allow the Go code to continue running.

Updates #18892
Updates #25506

Change-Id: Ib8701cfa0536d10d69bd541c85b0e2a754eb54fb
Reviewed-on: https://go-review.googlesource.com/114197
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
18 files changed:
misc/wasm/wasm_exec.js
src/cmd/internal/obj/wasm/a.out.go
src/cmd/internal/obj/wasm/anames.go
src/cmd/internal/obj/wasm/wasmobj.go
src/cmd/link/internal/wasm/asm.go
src/cmd/trace/annotations.go
src/cmd/trace/annotations_test.go
src/cmd/trace/trace_test.go
src/go/build/deps_test.go
src/runtime/lock_futex.go
src/runtime/lock_js.go
src/runtime/lock_sema.go
src/runtime/proc.go
src/runtime/rt0_js_wasm.s
src/runtime/sys_wasm.s
src/syscall/js/callback.go [new file with mode: 0644]
src/syscall/js/js.go
src/syscall/js/js_test.go