diff options
author | Richard Musiol <mail@richard-musiol.de> | 2018-05-20 00:56:36 +0200 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2018-06-14 21:50:53 +0000 |
commit | e083dc6307b6593bdd44b219ffd21699d6f17fd7 (patch) | |
tree | 2a411d82639a778c6aa107529b1d708034c7a7f1 /src/runtime/sys_wasm.s | |
parent | 5fdacfa89f871888d6f8fde726b8f95f11e674d6 (diff) | |
download | go-e083dc6307b6593bdd44b219ffd21699d6f17fd7.tar.gz go-e083dc6307b6593bdd44b219ffd21699d6f17fd7.zip |
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>
Diffstat (limited to 'src/runtime/sys_wasm.s')
-rw-r--r-- | src/runtime/sys_wasm.s | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/runtime/sys_wasm.s b/src/runtime/sys_wasm.s index 9a67ceec63..3ca844a4c7 100644 --- a/src/runtime/sys_wasm.s +++ b/src/runtime/sys_wasm.s @@ -149,13 +149,6 @@ TEXT runtime·wasmTruncU(SB), NOSPLIT, $0-0 I64TruncUF64 Return -TEXT runtime·exit(SB), NOSPLIT, $0-8 - Call runtime·wasmExit(SB) - Drop - I32Const $0 - Set SP - I32Const $1 - TEXT runtime·exitThread(SB), NOSPLIT, $0-0 UNDEF @@ -194,6 +187,14 @@ TEXT ·walltime(SB), NOSPLIT, $0 CallImport RET +TEXT ·scheduleCallback(SB), NOSPLIT, $0 + CallImport + RET + +TEXT ·clearScheduledCallback(SB), NOSPLIT, $0 + CallImport + RET + TEXT ·getRandomData(SB), NOSPLIT, $0 CallImport RET |