summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-10-20 11:11:30 -0700
committerGitHub <noreply@github.com>2017-10-20 11:11:30 -0700
commit74d026b9afb7b11bf01639e900a382b32bacfb33 (patch)
tree89fa8acb6b69250fc30e01c2c76a6c6f3d0e6e0f /src/wasm/wasm-binary.cpp
parent939706d9c4d7584a2a1c2627986f977512490058 (diff)
downloadbinaryen-74d026b9afb7b11bf01639e900a382b32bacfb33.tar.gz
binaryen-74d026b9afb7b11bf01639e900a382b32bacfb33.tar.bz2
binaryen-74d026b9afb7b11bf01639e900a382b32bacfb33.zip
Atomics support in interpreter + optimizer + fuzz fixes for that (#1227)
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index ceb230f73..f98eff670 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -791,6 +791,11 @@ void WasmBinaryWriter::visitLoad(Load *curr) {
default: WASM_UNREACHABLE();
}
} else {
+ if (curr->type == unreachable) {
+ // don't even emit it; we don't know the right type
+ o << int8_t(BinaryConsts::Unreachable);
+ return;
+ }
o << int8_t(BinaryConsts::AtomicPrefix);
switch (curr->type) {
case i32: {
@@ -849,6 +854,11 @@ void WasmBinaryWriter::visitStore(Store *curr) {
default: abort();
}
} else {
+ if (curr->type == unreachable) {
+ // don't even emit it; we don't know the right type
+ o << int8_t(BinaryConsts::Unreachable);
+ return;
+ }
o << int8_t(BinaryConsts::AtomicPrefix);
switch (curr->valueType) {
case i32: {
@@ -881,6 +891,12 @@ void WasmBinaryWriter::visitAtomicRMW(AtomicRMW *curr) {
recurse(curr->ptr);
recurse(curr->value);
+ if (curr->type == unreachable) {
+ // don't even emit it; we don't know the right type
+ o << int8_t(BinaryConsts::Unreachable);
+ return;
+ }
+
o << int8_t(BinaryConsts::AtomicPrefix);
#define CASE_FOR_OP(Op) \
@@ -927,6 +943,12 @@ void WasmBinaryWriter::visitAtomicCmpxchg(AtomicCmpxchg *curr) {
recurse(curr->expected);
recurse(curr->replacement);
+ if (curr->type == unreachable) {
+ // don't even emit it; we don't know the right type
+ o << int8_t(BinaryConsts::Unreachable);
+ return;
+ }
+
o << int8_t(BinaryConsts::AtomicPrefix);
switch (curr->type) {
case i32: