summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-02-15 22:13:13 -0800
committerAlon Zakai <alonzakai@gmail.com>2016-02-15 22:13:13 -0800
commit6f6813c152ab90f811102f19128b82902e7f62ea (patch)
treef4551516f9d5e399ae3b3e34335e965669876832 /src/js
parentd4bd7dd9c6024db514c34435ce3476875360ede4 (diff)
downloadbinaryen-6f6813c152ab90f811102f19128b82902e7f62ea.tar.gz
binaryen-6f6813c152ab90f811102f19128b82902e7f62ea.tar.bz2
binaryen-6f6813c152ab90f811102f19128b82902e7f62ea.zip
send flattened output to v8 and structed to sm. send only functions to both
Diffstat (limited to 'src/js')
-rw-r--r--src/js/wasm.js-post.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js
index 4e4e3017b..75a91d4d4 100644
--- a/src/js/wasm.js-post.js
+++ b/src/js/wasm.js-post.js
@@ -45,7 +45,9 @@ function integrateWasmJS(Module) {
for (var x in obj) {
for (var y in obj[x]) {
if (ret[y]) Module['printErr']('warning: flatten dupe: ' + y);
- ret[y] = obj[x][y];
+ if (typeof obj[x][y] === 'function') {
+ ret[y] = obj[x][y];
+ }
}
}
return ret;
@@ -98,14 +100,14 @@ function integrateWasmJS(Module) {
// Load the wasm module
var binary = Module['readBinary'](Module['wasmCodeFile']);
// Create an instance of the module using native support in the JS engine.
- var importObj = flatten({ // XXX for now, flatten the imports
+ var importObj = {
"global.Math": global.Math,
"env": env,
"asm2wasm": asm2wasmImports
- });
+ };
var instance;
if (typeof WASM === 'object') {
- instance = WASM.instantiateModule(binary, importObj);
+ instance = WASM.instantiateModule(binary, flatten(importObj));
} else if (typeof wasmEval === 'function') {
instance = wasmEval(binary.buffer, importObj);
} else {