summaryrefslogtreecommitdiff
path: root/test/wasm2js/loop.2asm.js
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-05-28 10:58:14 -0700
committerGitHub <noreply@github.com>2019-05-28 10:58:14 -0700
commit4b223a33d9f44b99a783cb63329facea7edfb783 (patch)
tree05530ae1e9dc98acf18133c05ddfad1ba5826a1c /test/wasm2js/loop.2asm.js
parent899263882c48dba8e34717af1e28005f8888dca7 (diff)
downloadbinaryen-4b223a33d9f44b99a783cb63329facea7edfb783.tar.gz
binaryen-4b223a33d9f44b99a783cb63329facea7edfb783.tar.bz2
binaryen-4b223a33d9f44b99a783cb63329facea7edfb783.zip
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.
Diffstat (limited to 'test/wasm2js/loop.2asm.js')
-rw-r--r--test/wasm2js/loop.2asm.js16
1 files changed, 6 insertions, 10 deletions
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;