From 74d026b9afb7b11bf01639e900a382b32bacfb33 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 20 Oct 2017 11:11:30 -0700 Subject: Atomics support in interpreter + optimizer + fuzz fixes for that (#1227) --- src/wasm/wasm-binary.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/wasm/wasm-binary.cpp') 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: -- cgit v1.2.3