aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-08-19 15:17:04 -0400
committerCherry Mui <cherryyz@google.com>2024-08-21 01:11:27 +0000
commitf38d42f2c4c6ad0d7cbdad5e1417cac3be2a5dcb (patch)
treed305e0873748c2f413f9b8cb4e354a2fcefbeee8 /misc
parent24fd1a043d1a81267d4a8175c114b59a86928ddd (diff)
downloadgo-f38d42f2c4c6ad0d7cbdad5e1417cac3be2a5dcb.tar.xz
cmd/link: support wasmexport on js/wasm
Add export functions to the wasm module on GOOS=js. (Other parts work the same way as wasip1.) Add a test. Fixes #65199. Change-Id: Ia22580859fe40631d487f70ee293c12867e0c988 Reviewed-on: https://go-review.googlesource.com/c/go/+/606855 Reviewed-by: Zxilly Chou <zxilly@outlook.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Diffstat (limited to 'misc')
-rw-r--r--misc/wasm/wasm_exec.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index 0f635d6d54..af7e28f5f4 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -216,10 +216,15 @@
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
}
+ const testCallExport = (a, b) => {
+ return this._inst.exports.testExport(a, b);
+ }
+
const timeOrigin = Date.now() - performance.now();
this.importObject = {
_gotest: {
add: (a, b) => a + b,
+ callExport: testCallExport,
},
gojs: {
// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)