diff options
author | Alon Zakai <azakai@google.com> | 2020-07-22 18:25:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-22 18:25:56 -0700 |
commit | 9bfade13c4cd5ebce7ae70681c655302f0f02ce7 (patch) | |
tree | 582fa6e0f14bf86839ed8c640e175bdff21af439 /test/wasm2js/left-to-right.2asm.js | |
parent | 3ac849384aa861382d2ca9636a89556e237e55d6 (diff) | |
download | binaryen-9bfade13c4cd5ebce7ae70681c655302f0f02ce7.tar.gz binaryen-9bfade13c4cd5ebce7ae70681c655302f0f02ce7.tar.bz2 binaryen-9bfade13c4cd5ebce7ae70681c655302f0f02ce7.zip |
wasm2js: coerce function pointer indexes (#2979)
We emit FUNCTION_TABLE[ptr], where FUNCTION_TABLE is a JS
array. That is a rare case where true is handled differently than 1
(a typed array or an add would cast, etc.), so we must explicitly cast
there.
Fixes an issue that existed before, but became a problem due to
#2869 which optimized some selects into a form that emitted a true
or a false, and if that was a function pointer, it could be bad, see
https://app.circleci.com/pipelines/github/emscripten-core/emscripten/6699/workflows/0c4da49c-75d0-4b0a-8fac-686a8330a3fe/jobs/336520
The new test/wasm2js/indirect-select.2asm.js.opt output shows
what happened there.
Verified as passing emscripten's wasm2js1 wasm2js2 test suites.
Diffstat (limited to 'test/wasm2js/left-to-right.2asm.js')
-rw-r--r-- | test/wasm2js/left-to-right.2asm.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/wasm2js/left-to-right.2asm.js b/test/wasm2js/left-to-right.2asm.js index f5f19a1cd..4c595c3b0 100644 --- a/test/wasm2js/left-to-right.2asm.js +++ b/test/wasm2js/left-to-right.2asm.js @@ -408,7 +408,7 @@ function asmFunc(global, env, buffer) { function $62() { var wasm2js_i32$0 = 0, wasm2js_i32$1 = 0, wasm2js_i32$2 = 0; reset(); - ((wasm2js_i32$1 = i32_left() | 0, wasm2js_i32$2 = i32_right() | 0), wasm2js_i32$0 = i32_callee() | 0), FUNCTION_TABLE[wasm2js_i32$0](wasm2js_i32$1 | 0, wasm2js_i32$2 | 0) | 0; + ((wasm2js_i32$1 = i32_left() | 0, wasm2js_i32$2 = i32_right() | 0), wasm2js_i32$0 = i32_callee() | 0 | 0), FUNCTION_TABLE[wasm2js_i32$0](wasm2js_i32$1 | 0, wasm2js_i32$2 | 0) | 0; return get() | 0 | 0; } @@ -972,7 +972,7 @@ function asmFunc(global, env, buffer) { $1$hi = i64toi32_i32$0; i64toi32_i32$0 = $0$hi; i64toi32_i32$1 = $1$hi; - FUNCTION_TABLE[i64_callee() | 0]($0, i64toi32_i32$0, $1, i64toi32_i32$1) | 0; + FUNCTION_TABLE[i64_callee() | 0 | 0]($0, i64toi32_i32$0, $1, i64toi32_i32$1) | 0; return get() | 0 | 0; } @@ -1087,7 +1087,7 @@ function asmFunc(global, env, buffer) { function $109() { var wasm2js_i32$0 = 0, wasm2js_f32$0 = Math_fround(0), wasm2js_f32$1 = Math_fround(0); reset(); - ((wasm2js_f32$0 = Math_fround(f32_left()), wasm2js_f32$1 = Math_fround(f32_right())), wasm2js_i32$0 = f32_callee() | 0), FUNCTION_TABLE[wasm2js_i32$0](Math_fround(wasm2js_f32$0), Math_fround(wasm2js_f32$1)) | 0; + ((wasm2js_f32$0 = Math_fround(f32_left()), wasm2js_f32$1 = Math_fround(f32_right())), wasm2js_i32$0 = f32_callee() | 0 | 0), FUNCTION_TABLE[wasm2js_i32$0](Math_fround(wasm2js_f32$0), Math_fround(wasm2js_f32$1)) | 0; return get() | 0 | 0; } @@ -1216,7 +1216,7 @@ function asmFunc(global, env, buffer) { function $126() { var wasm2js_i32$0 = 0, wasm2js_f64$0 = 0.0, wasm2js_f64$1 = 0.0; reset(); - ((wasm2js_f64$0 = +f64_left(), wasm2js_f64$1 = +f64_right()), wasm2js_i32$0 = f64_callee() | 0), FUNCTION_TABLE[wasm2js_i32$0](+wasm2js_f64$0, +wasm2js_f64$1) | 0; + ((wasm2js_f64$0 = +f64_left(), wasm2js_f64$1 = +f64_right()), wasm2js_i32$0 = f64_callee() | 0 | 0), FUNCTION_TABLE[wasm2js_i32$0](+wasm2js_f64$0, +wasm2js_f64$1) | 0; return get() | 0 | 0; } |