diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-02-15 20:10:07 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-02-15 20:11:03 -0800 |
commit | d4bd7dd9c6024db514c34435ce3476875360ede4 (patch) | |
tree | 3e7f80c14b2c6328a777a66e0e8df48eb2655e4e /src/js | |
parent | afbb7dbfd3034f33e41f28a1e361ad96c6ba7fa4 (diff) | |
download | binaryen-d4bd7dd9c6024db514c34435ce3476875360ede4.tar.gz binaryen-d4bd7dd9c6024db514c34435ce3476875360ede4.tar.bz2 binaryen-d4bd7dd9c6024db514c34435ce3476875360ede4.zip |
add sm code to parallel v8 code in integrateWasmJS
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/wasm.js-post.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index bdb825573..4e4e3017b 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -90,21 +90,27 @@ function integrateWasmJS(Module) { } } - if (typeof WASM === 'object') { + if (typeof WASM === 'object' || typeof wasmEval === 'function') { // Provide an "asm.js function" for the application, called to "link" the asm.js module. We instantiate // the wasm module at that time, and it receives imports and provides exports and so forth, the app // doesn't need to care that it is wasm and not asm. Module['asm'] = function(global, env, providedBuffer) { // Load the wasm module var binary = Module['readBinary'](Module['wasmCodeFile']); - // Create an instance of the module using native support in the JS engine. - var instance = WASM.instantiateModule(binary, flatten({ // XXX for now, flatten the imports + var importObj = flatten({ // XXX for now, flatten the imports "global.Math": global.Math, "env": env, "asm2wasm": asm2wasmImports - })); - + }); + var instance; + if (typeof WASM === 'object') { + instance = WASM.instantiateModule(binary, importObj); + } else if (typeof wasmEval === 'function') { + instance = wasmEval(binary.buffer, importObj); + } else { + throw 'how to wasm?'; + } mergeMemory(instance.memory); applyMappedGlobals(); |