From 4b223a33d9f44b99a783cb63329facea7edfb783 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 28 May 2019 10:58:14 -0700 Subject: wasm2js: Switch optimizations (#2141) This pattern-matches towers of blocks + a br_table into a JS switch. This is much smaller in code size and also avoids heavy nesting that can exceed the recursion limits of JS parsers. This is not enough yet, because it pattern-matches very specifically. In reality, switches can look slightly different. Followup PRs will extend this. For now, this passes the test suite (what passed before - not including the massive-switch tests) + fuzzing so it's a good start. --- test/wasm2js/loop.2asm.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'test/wasm2js/loop.2asm.js') diff --git a/test/wasm2js/loop.2asm.js b/test/wasm2js/loop.2asm.js index 1b5a05a33..ab7e7d825 100644 --- a/test/wasm2js/loop.2asm.js +++ b/test/wasm2js/loop.2asm.js @@ -235,19 +235,15 @@ function asmFunc(global, env, buffer) { }; } block50 : { - loop_in51 : while (1) { - switch (0 | 0) { - default: - break block50; - }; + loop_in51 : while (1) switch (0 | 0) { + default: + break block50; }; } block52 : { - loop_in53 : while (1) { - switch (1 | 0) { - default: - break block52; - }; + loop_in53 : while (1) switch (1 | 0) { + default: + break block52; }; } return 19 | 0; -- cgit v1.2.3