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/float-ops.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/float-ops.2asm.js')
-rw-r--r-- | test/wasm2js/float-ops.2asm.js | 103 |
1 files changed, 30 insertions, 73 deletions
diff --git a/test/wasm2js/float-ops.2asm.js b/test/wasm2js/float-ops.2asm.js index ca6079c19..4d691213a 100644 --- a/test/wasm2js/float-ops.2asm.js +++ b/test/wasm2js/float-ops.2asm.js @@ -167,7 +167,7 @@ function asmFunc(global, env, buffer) { function $25($0) { $0 = Math_fround($0); - return +(+$0); + return +$0; } function $26($0) { @@ -212,7 +212,7 @@ function asmFunc(global, env, buffer) { function $36($0) { $0 = $0 | 0; - return +(+($0 | 0)); + return +($0 | 0); } function $37($0) { @@ -222,7 +222,7 @@ function asmFunc(global, env, buffer) { function $38($0) { $0 = $0 | 0; - return +(+($0 >>> 0)); + return +($0 >>> 0); } function $39($0) { @@ -358,125 +358,90 @@ function asmFunc(global, env, buffer) { } function legalstub$1($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return +(+Math_fround($1(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))))); + return +$1(Math_fround($0), Math_fround($1_1)); } function legalstub$2($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return +(+Math_fround($2(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))))); + return +$2(Math_fround($0), Math_fround($1_1)); } function legalstub$3($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return +(+Math_fround($3(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))))); + return +$3(Math_fround($0), Math_fround($1_1)); } function legalstub$4($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return +(+Math_fround($4(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))))); + return +$4(Math_fround($0), Math_fround($1_1)); } function legalstub$9($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return $9(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))) | 0; + return $9(Math_fround($0), Math_fround($1_1)); } function legalstub$10($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return $10(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))) | 0; + return $10(Math_fround($0), Math_fround($1_1)); } function legalstub$11($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return $11(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))) | 0; + return $11(Math_fround($0), Math_fround($1_1)); } function legalstub$12($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return $12(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))) | 0; + return $12(Math_fround($0), Math_fround($1_1)); } function legalstub$13($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return $13(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))) | 0; + return $13(Math_fround($0), Math_fround($1_1)); } function legalstub$14($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return $14(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))) | 0; + return $14(Math_fround($0), Math_fround($1_1)); } function legalstub$21($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return +(+Math_fround($21(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))))); + return +$21(Math_fround($0), Math_fround($1_1)); } function legalstub$22($0, $1_1) { - $0 = +$0; - $1_1 = +$1_1; - return +(+Math_fround($22(Math_fround(Math_fround($0)), Math_fround(Math_fround($1_1))))); + return +$22(Math_fround($0), Math_fround($1_1)); } function legalstub$25($0) { - $0 = +$0; - return +(+$25(Math_fround(Math_fround($0)))); + return $25(Math_fround($0)); } function legalstub$26($0) { - $0 = +$0; - return +(+Math_fround($26(+$0))); + return +$26($0); } function legalstub$27($0) { - $0 = +$0; - return +(+Math_fround($27(Math_fround(Math_fround($0))))); + return +$27(Math_fround($0)); } function legalstub$28($0) { - $0 = +$0; - return +(+Math_fround($28(Math_fround(Math_fround($0))))); + return +$28(Math_fround($0)); } function legalstub$31($0) { - $0 = +$0; - return +(+Math_fround($31(Math_fround(Math_fround($0))))); + return +$31(Math_fround($0)); } function legalstub$35($0) { - $0 = $0 | 0; - return +(+Math_fround($35($0 | 0))); + return +$35($0); } function legalstub$37($0) { - $0 = $0 | 0; - return +(+Math_fround($37($0 | 0))); + return +$37($0); } function legalstub$39($0) { - $0 = +$0; - return $39(Math_fround(Math_fround($0))) | 0; + return $39(Math_fround($0)); } function legalstub$41($0) { - $0 = +$0; - return $41(Math_fround(Math_fround($0))) | 0; + return $41(Math_fround($0)); } function legalstub$43($0, $1_1) { - $0 = $0 | 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; @@ -503,12 +468,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($43(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0))); + return +$43(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$44($0, $1_1) { - $0 = $0 | 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; @@ -535,12 +498,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 +(+$44(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0)); + return $44(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$45($0, $1_1) { - $0 = $0 | 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; @@ -567,12 +528,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($45(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0))); + return +$45(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$46($0, $1_1) { - $0 = $0 | 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; @@ -599,17 +558,15 @@ 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 +(+$46(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2 | 0)); + return $46(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); } function legalstub$47($0) { - $0 = +$0; - return $47(Math_fround(Math_fround($0))) | 0; + return $47(Math_fround($0)); } function legalstub$49($0) { - $0 = +$0; - return $49(Math_fround(Math_fround($0))) | 0; + return $49(Math_fround($0)); } var FUNCTION_TABLE = []; |