diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-12-07 14:08:41 -1000 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-12-07 16:50:05 -1000 |
commit | 97968a879d0b55baccb5f72627fca84a6a015356 (patch) | |
tree | a87e63e22d02a1005cfa6669b80eb7a0194b89e9 /src | |
parent | 7a7d142903b6eb18854cb9b955fc728a7e3853bd (diff) | |
download | binaryen-97968a879d0b55baccb5f72627fca84a6a015356.tar.gz binaryen-97968a879d0b55baccb5f72627fca84a6a015356.tar.bz2 binaryen-97968a879d0b55baccb5f72627fca84a6a015356.zip |
handle imports in tables in interpreter
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-js.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index e5032264a..2735f84f8 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -227,9 +227,18 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { Address offset = ConstantExpressionRunner(instance.globals).visit(segment.offset).value.geti32(); assert(offset + segment.data.size() <= wasm.table.initial); for (size_t i = 0; i != segment.data.size(); ++i) { - EM_ASM_({ - Module['outside']['wasmTable'][$0] = $1; - }, offset + i, wasm.getFunction(segment.data[i])); + Name name = segment.data[i]; + auto* func = wasm.checkFunction(name); + if (func) { + EM_ASM_({ + Module['outside']['wasmTable'][$0] = $1; + }, offset + i, func); + } else { + auto* import = wasm.getImport(name); + EM_ASM_({ + Module['outside']['wasmTable'][$0] = Module['lookupImport'](Pointer_stringify($1), Pointer_stringify($2)); + }, offset + i, import->module.str, import->base.str); + } } } } |