From b769b4ede65eb014376b67f78ba5e6cb04e0cef8 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 11 Apr 2019 14:01:51 -0700 Subject: Wasm2js refactoring (#1997) Early work for #1929 * Leave core wasm module - the "asm.js function" - to Wasm2JSBuilder, and add Wasm2JSGlue which emits the code before and after that. Currently that's some ES6 code, but we may want to change that later. * Add add AssertionEmitter class for the sole purpose of emitting modules + assertions for testing. This avoids some hacks from before like starting from index 1 (assuming the module at first position was already parsed and printed) and printing of the f32Equal etc. functions not at the very top (which was due to technical limitations before). Logic-wise, there should be no visible change, except some whitespace and reodering, and that I made the exceptions print out the source of the assertion that failed from the wast: -if (!check2()) fail2(); +if (!check2()) throw 'assertion failed: ( assert_return ( call add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; (fail2 etc. did not exist, and seems to just have given a unique number for each assertion?) --- test/wasm2js/switch.2asm.js | 1 + 1 file changed, 1 insertion(+) (limited to 'test/wasm2js/switch.2asm.js') diff --git a/test/wasm2js/switch.2asm.js b/test/wasm2js/switch.2asm.js index e793696df..053736116 100644 --- a/test/wasm2js/switch.2asm.js +++ b/test/wasm2js/switch.2asm.js @@ -1,3 +1,4 @@ + function asmFunc(global, env, buffer) { "use asm"; var HEAP8 = new global.Int8Array(buffer); -- cgit v1.2.3