diff options
author | Sam Clegg <sbc@chromium.org> | 2022-10-05 15:18:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 15:18:22 -0700 |
commit | c43721a1ae80539aea5ea9d8d295b7e377aa03f5 (patch) | |
tree | 4a796dd8baa33f6edd44b16addb967483f6b1479 /test/wasm2js/dynamicLibrary.2asm.js.opt | |
parent | 9b5ba422bf670754a5ac4fb39b0199ac8e1edb84 (diff) | |
download | binaryen-c43721a1ae80539aea5ea9d8d295b7e377aa03f5.tar.gz binaryen-c43721a1ae80539aea5ea9d8d295b7e377aa03f5.tar.bz2 binaryen-c43721a1ae80539aea5ea9d8d295b7e377aa03f5.zip |
wasm2js: Support for flexible module import naming (#5114)
The previous code was making emscripten-specific assumptions about
imports basically all coming from the `env` module.
I can't find a way to make this backwards compatible so may do a
combined roll with the emscripten-side change:
https://github.com/emscripten-core/emscripten/pull/17806
Diffstat (limited to 'test/wasm2js/dynamicLibrary.2asm.js.opt')
-rw-r--r-- | test/wasm2js/dynamicLibrary.2asm.js.opt | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/test/wasm2js/dynamicLibrary.2asm.js.opt b/test/wasm2js/dynamicLibrary.2asm.js.opt index 44b3411a0..61bdab183 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js.opt +++ b/test/wasm2js/dynamicLibrary.2asm.js.opt @@ -1,5 +1,4 @@ -import { memoryBase } from 'env'; -import { tableBase } from 'env'; +import * as env from 'env'; function Table(ret) { // grow method not included; table is not growable @@ -34,10 +33,10 @@ function Table(ret) { return uint8Array; } function initActiveSegments(imports) { - base64DecodeToExistingUint8Array(bufferView, imports[memoryBase], "ZHluYW1pYyBkYXRh"); + base64DecodeToExistingUint8Array(bufferView, imports['env']['memoryBase'], "ZHluYW1pYyBkYXRh"); } -function asmFunc(importObject) { - var env = importObject.env || importObject; +function asmFunc(imports) { + var env = imports.env; var memory = env.memory; var buffer = memory.buffer; var HEAP8 = new Int8Array(buffer); @@ -67,7 +66,7 @@ function asmFunc(importObject) { } bufferView = HEAPU8; - initActiveSegments(env); + initActiveSegments(imports); var FUNCTION_TABLE = Table(new Array(10)); FUNCTION_TABLE[import$tableBase + 0] = foo; FUNCTION_TABLE[import$tableBase + 1] = foo; @@ -83,6 +82,8 @@ function asmFunc(importObject) { var memasmFunc = new ArrayBuffer(16777216); var retasmFunc = asmFunc({ + "env": { memory: { buffer : memasmFunc } + }, }); export var baz = retasmFunc.baz; |