diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-29 21:10:56 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-29 21:33:44 -0800 |
commit | 587b3b9573c503c32ea09bb702d894a33217798d (patch) | |
tree | 55e256048487dfc37a187834e75d8235861c0359 /src/js | |
parent | 7a0879dc88c49b38b75e8fc61d1f65570380fafc (diff) | |
download | binaryen-587b3b9573c503c32ea09bb702d894a33217798d.tar.gz binaryen-587b3b9573c503c32ea09bb702d894a33217798d.tar.bz2 binaryen-587b3b9573c503c32ea09bb702d894a33217798d.zip |
refactor wasm.js method and add testing
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/post.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/js/post.js b/src/js/post.js index 233a9c449..7703d4a84 100644 --- a/src/js/post.js +++ b/src/js/post.js @@ -1,5 +1,17 @@ function integrateWasmJS(Module) { + // wasm.js has several methods for creating the compiled code module here: + // * 'wasm-s-parser': load s-expression code from a .wast and create wasm + // * 'asm2wasm': load asm.js code and translate to wasm + // * 'just-asm': no wasm, just load the asm.js code and use that (good for testing) + // The method can be set at compile time (BINARYEN_METHOD), or runtime by setting Module['wasmJSMethod']. + var method = Module['wasmJSMethod'] || 'wasm-s-parser'; + assert(method == 'asm2wasm' || method == 'wasm-s-parser' || method == 'just-asm'); + + if (method == 'just-asm') { + eval(Module['read'](Module['asmjsCodeFile'])); + return; + } // wasm lacks globals, so asm2wasm maps them into locations in memory. that information cannot // be present in the wasm output of asm2wasm, so we store it in a side file. If we load asm2wasm @@ -137,8 +149,6 @@ function integrateWasmJS(Module) { }; // Prepare to generate wasm, using either asm2wasm or wasm-s-parser - var method = Module['wasmJSMethod'] || 'wasm-s-parser'; - assert(method == 'asm2wasm' || method == 'wasm-s-parser'); var code = Module['read'](method == 'asm2wasm' ? Module['asmjsCodeFile'] : Module['wasmCodeFile']); var temp = wasmJS['_malloc'](code.length + 1); wasmJS['writeAsciiToMemory'](code, temp); |