summaryrefslogtreecommitdiff
path: root/test/wasm2js/br_table_to_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/br_table_to_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/br_table_to_loop.2asm.js')
-rw-r--r--test/wasm2js/br_table_to_loop.2asm.js24
1 files changed, 10 insertions, 14 deletions
diff --git a/test/wasm2js/br_table_to_loop.2asm.js b/test/wasm2js/br_table_to_loop.2asm.js
index 0e3257559..ac59cb0d4 100644
--- a/test/wasm2js/br_table_to_loop.2asm.js
+++ b/test/wasm2js/br_table_to_loop.2asm.js
@@ -23,26 +23,22 @@ function asmFunc(global, env, buffer) {
var infinity = global.Infinity;
function $0() {
block : {
- loop : while (1) {
- switch (1 | 0) {
- case 1:
- continue loop;
- default:
- break block;
- };
+ loop : while (1) switch (1 | 0) {
+ case 1:
+ continue loop;
+ default:
+ break block;
};
}
}
function $1() {
block : {
- loop : while (1) {
- switch (1 | 0) {
- case 1:
- break block;
- default:
- continue loop;
- };
+ loop : while (1) switch (1 | 0) {
+ case 1:
+ break block;
+ default:
+ continue loop;
};
}
}