diff options
author | Alon Zakai <azakai@google.com> | 2019-04-24 15:27:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-24 15:27:05 -0700 |
commit | c3ed0f176b36a502ef2e1fd915550a808b8d8f0b (patch) | |
tree | 6abff96331025a74e18cfa4f173a997d3c800559 /test/wasm2js/conversions-modified.2asm.js | |
parent | bc0a605e8864324d40aafbd00e8de0e50240ce26 (diff) | |
download | binaryen-c3ed0f176b36a502ef2e1fd915550a808b8d8f0b.tar.gz binaryen-c3ed0f176b36a502ef2e1fd915550a808b8d8f0b.tar.bz2 binaryen-c3ed0f176b36a502ef2e1fd915550a808b8d8f0b.zip |
wasm2js: more js optimization (#2050)
* Emit ints as signed, so -1 isn't a big unsigned number.
* x - -c (where c is a constant) is larger than x + c in js (but not wasm)
* +(+x) => +x
* Avoid unnecessary coercions on calls, return, load, etc. - we just need coercions when entering or exiting "wasm" (not internally), and on actual operations that need them.
Diffstat (limited to 'test/wasm2js/conversions-modified.2asm.js')
-rw-r--r-- | test/wasm2js/conversions-modified.2asm.js | 91 |
1 files changed, 32 insertions, 59 deletions
diff --git a/test/wasm2js/conversions-modified.2asm.js b/test/wasm2js/conversions-modified.2asm.js index f5998445e..bb8392de3 100644 --- a/test/wasm2js/conversions-modified.2asm.js +++ b/test/wasm2js/conversions-modified.2asm.js @@ -200,7 +200,7 @@ function asmFunc(global, env, buffer) { function $13(x) { x = x | 0; - return +(+(x | 0)); + return +(x | 0); } function $14(x, x$hi) { @@ -226,7 +226,7 @@ function asmFunc(global, env, buffer) { function $17(x) { x = x | 0; - return +(+(x >>> 0)); + return +(x >>> 0); } function $18(x, x$hi) { @@ -239,7 +239,7 @@ function asmFunc(global, env, buffer) { function $19(x) { x = Math_fround(x); - return +(+x); + return +x; } function $20(x) { @@ -259,7 +259,7 @@ function asmFunc(global, env, buffer) { i64toi32_i32$0 = x$hi; wasm2js_scratch_store_i32(0 | 0, x | 0); wasm2js_scratch_store_i32(1 | 0, i64toi32_i32$0 | 0); - return +(+wasm2js_scratch_load_f64()); + return +wasm2js_scratch_load_f64(); } function $23(x) { @@ -278,9 +278,8 @@ function asmFunc(global, env, buffer) { } function legalstub$0($0_1) { - $0_1 = $0_1 | 0; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $0($0_1 | 0) | 0; + i64toi32_i32$0 = $0($0_1); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -301,13 +300,12 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } function legalstub$1($0_1) { - $0_1 = $0_1 | 0; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $1($0_1 | 0) | 0; + i64toi32_i32$0 = $1($0_1); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -328,12 +326,10 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } function legalstub$2($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $10_1 = 0, $3_1 = 0, $3$hi = 0, $6$hi = 0; i64toi32_i32$0 = 0; $3_1 = $0_1; @@ -360,23 +356,20 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $6$hi; i64toi32_i32$3 = $10_1; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return $2(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0) | 0; + return $2(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$3($0_1) { - $0_1 = +$0_1; - return $3(Math_fround(Math_fround($0_1))) | 0; + return $3(Math_fround($0_1)); } function legalstub$4($0_1) { - $0_1 = +$0_1; - return $4(Math_fround(Math_fround($0_1))) | 0; + return $4(Math_fround($0_1)); } function legalstub$7($0_1) { - $0_1 = +$0_1; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $7(Math_fround(Math_fround($0_1))) | 0; + i64toi32_i32$0 = $7(Math_fround($0_1)); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -397,13 +390,12 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } function legalstub$8($0_1) { - $0_1 = +$0_1; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $8(Math_fround(Math_fround($0_1))) | 0; + i64toi32_i32$0 = $8(Math_fround($0_1)); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -424,13 +416,12 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } function legalstub$9($0_1) { - $0_1 = +$0_1; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $9(+$0_1) | 0; + i64toi32_i32$0 = $9($0_1); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -451,13 +442,12 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } function legalstub$10($0_1) { - $0_1 = +$0_1; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $10(+$0_1) | 0; + i64toi32_i32$0 = $10($0_1); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -478,17 +468,14 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } function legalstub$11($0_1) { - $0_1 = $0_1 | 0; - return +(+Math_fround($11($0_1 | 0))); + return +$11($0_1); } function legalstub$12($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $10_1 = 0, $3_1 = 0, $3$hi = 0, $6$hi = 0; i64toi32_i32$0 = 0; $3_1 = $0_1; @@ -515,12 +502,10 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $6$hi; i64toi32_i32$3 = $10_1; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return +(+Math_fround($12(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0))); + return +$12(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$14($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $10_1 = 0, $3_1 = 0, $3$hi = 0, $6$hi = 0; i64toi32_i32$0 = 0; $3_1 = $0_1; @@ -547,17 +532,14 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $6$hi; i64toi32_i32$3 = $10_1; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return +(+$14(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0)); + return $14(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$15($0_1) { - $0_1 = $0_1 | 0; - return +(+Math_fround($15($0_1 | 0))); + return +$15($0_1); } function legalstub$16($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $10_1 = 0, $3_1 = 0, $3$hi = 0, $6$hi = 0; i64toi32_i32$0 = 0; $3_1 = $0_1; @@ -584,12 +566,10 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $6$hi; i64toi32_i32$3 = $10_1; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return +(+Math_fround($16(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0))); + return +$16(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$18($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $10_1 = 0, $3_1 = 0, $3$hi = 0, $6$hi = 0; i64toi32_i32$0 = 0; $3_1 = $0_1; @@ -616,27 +596,22 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $6$hi; i64toi32_i32$3 = $10_1; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return +(+$18(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0)); + return $18(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$19($0_1) { - $0_1 = +$0_1; - return +(+$19(Math_fround(Math_fround($0_1)))); + return $19(Math_fround($0_1)); } function legalstub$20($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($20(+$0_1))); + return +$20($0_1); } function legalstub$21($0_1) { - $0_1 = $0_1 | 0; - return +(+Math_fround($21($0_1 | 0))); + return +$21($0_1); } function legalstub$22($0_1, $1_1) { - $0_1 = $0_1 | 0; - $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $10_1 = 0, $3_1 = 0, $3$hi = 0, $6$hi = 0; i64toi32_i32$0 = 0; $3_1 = $0_1; @@ -663,18 +638,16 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $6$hi; i64toi32_i32$3 = $10_1; i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return +(+$22(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0)); + return $22(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$23($0_1) { - $0_1 = +$0_1; - return $23(Math_fround(Math_fround($0_1))) | 0; + return $23(Math_fround($0_1)); } function legalstub$24($0_1) { - $0_1 = +$0_1; var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $8_1 = 0, $1_1 = 0, $1$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $24(+$0_1) | 0; + i64toi32_i32$0 = $24($0_1); i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $1_1 = i64toi32_i32$0; $1$hi = i64toi32_i32$1; @@ -695,7 +668,7 @@ function asmFunc(global, env, buffer) { } setTempRet0($8_1 | 0); i64toi32_i32$0 = $1$hi; - return $1_1 | 0; + return $1_1; } var FUNCTION_TABLE = []; |