summaryrefslogtreecommitdiff
path: root/test/wasm2asm.traps.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-10-03 15:20:42 -0700
committerGitHub <noreply@github.com>2017-10-03 15:20:42 -0700
commit7c491995ea89685f1381bd37227857820dbc0a34 (patch)
tree52c44bcdefe8eea33a33d227761475f2718eba12 /test/wasm2asm.traps.js
parent47c37d0c4457ede9f4343abca0d56e2baa7f3d8a (diff)
downloadbinaryen-7c491995ea89685f1381bd37227857820dbc0a34.tar.gz
binaryen-7c491995ea89685f1381bd37227857820dbc0a34.tar.bz2
binaryen-7c491995ea89685f1381bd37227857820dbc0a34.zip
Flattening rewrite (#1201)
Rename flatten-control-flow to flatten, which now flattens everything, not just control flow, so e.g. (i32.add (call $x) (call $y) ) ==> (block (set_local $temp_x (call $x)) (set_local $temp_y (call $y)) (i32.add (get_local $x) (get_local $y) ) ) This uses more locals than before, but is much simpler and avoids a bunch of corner cases and fuzz bugs the old one hit. We can optimize later if necessary.
Diffstat (limited to 'test/wasm2asm.traps.js')
-rw-r--r--test/wasm2asm.traps.js97
1 files changed, 84 insertions, 13 deletions
diff --git a/test/wasm2asm.traps.js b/test/wasm2asm.traps.js
index 4b89f5b89..2f4ddb0d9 100644
--- a/test/wasm2asm.traps.js
+++ b/test/wasm2asm.traps.js
@@ -19,50 +19,121 @@ function asmFunc(global, env, buffer) {
function $$1(x, y) {
x = x | 0;
y = y | 0;
- return x + y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 + $$3 | 0;
+ return $$4 | 0;
}
function $$2(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) / (y | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) / ($$3 | 0) | 0;
+ return $$4 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {