diff options
author | Derek Schuff <dschuff@chromium.org> | 2017-08-24 12:43:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-24 12:43:12 -0700 |
commit | e60fcd0ba97ed75440c6f838619455be7a5e90a3 (patch) | |
tree | dbf187ed1eefcc9e16d5f5fac4be38b3fb539f94 /src/wasm/wasm-validator.cpp | |
parent | b07fafcebebab82dba46012256edc6445862cfce (diff) | |
download | binaryen-e60fcd0ba97ed75440c6f838619455be7a5e90a3.tar.gz binaryen-e60fcd0ba97ed75440c6f838619455be7a5e90a3.tar.bz2 binaryen-e60fcd0ba97ed75440c6f838619455be7a5e90a3.zip |
Add support for atomic wait and wake operators (#1140)
According to spec at https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait-and-wake-operators
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index aaf5a7fd5..819602608 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -261,6 +261,20 @@ void WasmValidator::visitAtomicCmpxchg(AtomicCmpxchg* curr) { shouldBeEqualOrFirstIsUnreachable(curr->replacement->type, curr->type, curr, "Cmpxchg result type must match replacement"); shouldBeIntOrUnreachable(curr->expected->type, curr, "Atomic operations are only valid on int types"); } +void WasmValidator::visitAtomicWait(AtomicWait* curr) { + if (!getModule()->memory.shared) fail("Atomic operation with non-shared memory", curr); + shouldBeEqualOrFirstIsUnreachable(curr->type, i32, curr, "AtomicWait must have type i32"); + shouldBeEqualOrFirstIsUnreachable(curr->ptr->type, i32, curr, "AtomicWait pointer type must be i32"); + shouldBeIntOrUnreachable(curr->expected->type, curr, "AtomicWait expected type must be int"); + shouldBeEqualOrFirstIsUnreachable(curr->expected->type, curr->expectedType, curr, "AtomicWait expected type must match operand"); + shouldBeEqualOrFirstIsUnreachable(curr->timeout->type, i64, curr, "AtomicWait timeout type must be i64"); +} +void WasmValidator::visitAtomicWake(AtomicWake* curr) { + if (!getModule()->memory.shared) fail("Atomic operation with non-shared memory", curr); + shouldBeEqualOrFirstIsUnreachable(curr->type, i32, curr, "AtomicWake must have type i32"); + shouldBeEqualOrFirstIsUnreachable(curr->ptr->type, i32, curr, "AtomicWake pointer type must be i32"); + shouldBeEqualOrFirstIsUnreachable(curr->wakeCount->type, i32, curr, "AtomicWake wakeCount type must be i32"); +} void WasmValidator::validateMemBytes(uint8_t bytes, WasmType type, Expression* curr) { switch (bytes) { case 1: |