diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-02-19 16:08:09 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-02-19 16:08:09 -0800 |
commit | 33fc36930b2b73ff98eba6037138eaa8d3a20404 (patch) | |
tree | bc7c298bb9bfd27ba3668b9b871e731c521c62e1 /src | |
parent | 5a1adcc357995089766ed333a55ff93204fe75ae (diff) | |
download | binaryen-33fc36930b2b73ff98eba6037138eaa8d3a20404.tar.gz binaryen-33fc36930b2b73ff98eba6037138eaa8d3a20404.tar.bz2 binaryen-33fc36930b2b73ff98eba6037138eaa8d3a20404.zip |
make wasm.js tolerate wrong alignments, as per the wasm spec
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-js.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp index cbaf15fbb..723946891 100644 --- a/src/wasm-js.cpp +++ b/src/wasm-js.cpp @@ -201,7 +201,7 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { } Literal load(Load* load, size_t addr) override { - if (load->align < load->bytes) { + if (load->align < load->bytes || (addr & (load->bytes-1))) { double ret = EM_ASM_DOUBLE({ var addr = $0; var bytes = $1; @@ -268,8 +268,8 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { } void store(Store* store, size_t addr, Literal value) override { - if (store->align < store->bytes) { - double ret = EM_ASM_DOUBLE({ + if (store->align < store->bytes || (addr & (store->bytes-1))) { + EM_ASM_DOUBLE({ var addr = $0; var bytes = $1; var isFloat = $2; @@ -290,7 +290,6 @@ extern "C" void EMSCRIPTEN_KEEPALIVE instantiate() { HEAPU8[addr + i] = HEAPU8[i]; } HEAP32[0] = save0; HEAP32[1] = save1; - return ret; }, addr, store->bytes, isWasmTypeFloat(store->type), isWasmTypeFloat(store->type) ? value.getFloat() : (double)value.getInteger()); return; } |