diff options
author | Alon Zakai <azakai@google.com> | 2020-07-20 19:24:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 19:24:56 -0700 |
commit | 2e18aff8c9d4867d9c8e7db81948a672c028348f (patch) | |
tree | b8ef6b8ec097e8d2d5bcdc313c621b91728e26f8 /test/wasm2js/endianness.2asm.js | |
parent | 4b60d34d807bf803cefee8fd16b9000bcfc1bdc7 (diff) | |
download | binaryen-2e18aff8c9d4867d9c8e7db81948a672c028348f.tar.gz binaryen-2e18aff8c9d4867d9c8e7db81948a672c028348f.tar.bz2 binaryen-2e18aff8c9d4867d9c8e7db81948a672c028348f.zip |
wasm2js: Fix a bug with adjacent reinterprets (#2964)
i64 reinterprets were lowered in the i64 pass, and i32s at the very end, in
wasm2js itself. This could break since in between the i64 pass and wasm2js
we run optimizations, and the optimizer was not aware of what we lower
the i32 reinterprets to - calls to use scratch memory. Those calls have a
side effect of altering scratch memory. The optimizer just saw an i32
reinterpret, and moved it across the i64 reinterpret's scratch memory calls.
This makes 32-bit reinterprets use separate scratch memory from 64-bit ones,
which means they can never interfere with each other.
Diffstat (limited to 'test/wasm2js/endianness.2asm.js')
-rw-r--r-- | test/wasm2js/endianness.2asm.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/wasm2js/endianness.2asm.js b/test/wasm2js/endianness.2asm.js index 2146a9840..171af7d6c 100644 --- a/test/wasm2js/endianness.2asm.js +++ b/test/wasm2js/endianness.2asm.js @@ -1,7 +1,7 @@ import { setTempRet0 } from 'env'; - var scratchBuffer = new ArrayBuffer(8); + var scratchBuffer = new ArrayBuffer(16); var i32ScratchView = new Int32Array(scratchBuffer); var f32ScratchView = new Float32Array(scratchBuffer); var f64ScratchView = new Float64Array(scratchBuffer); @@ -23,11 +23,11 @@ import { setTempRet0 } from 'env'; } function wasm2js_scratch_store_f32(value) { - f32ScratchView[0] = value; + f32ScratchView[2] = value; } function wasm2js_scratch_load_f32() { - return f32ScratchView[0]; + return f32ScratchView[2]; } function asmFunc(global, env, buffer) { @@ -209,7 +209,7 @@ function asmFunc(global, env, buffer) { function $14(value) { value = Math_fround(value); - i32_store_little(0 | 0, (wasm2js_scratch_store_f32(value), wasm2js_scratch_load_i32(0)) | 0); + i32_store_little(0 | 0, (wasm2js_scratch_store_f32(value), wasm2js_scratch_load_i32(2)) | 0); return Math_fround(Math_fround(HEAPF32[0 >> 2])); } @@ -275,7 +275,7 @@ function asmFunc(global, env, buffer) { function $21(value) { value = Math_fround(value); HEAPF32[0 >> 2] = value; - return Math_fround((wasm2js_scratch_store_i32(0, i32_load_little(0 | 0) | 0), wasm2js_scratch_load_f32())); + return Math_fround((wasm2js_scratch_store_i32(2, i32_load_little(0 | 0) | 0), wasm2js_scratch_load_f32())); } function $22(value) { |