summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/abi/js.h5
-rw-r--r--src/passes/I64ToI32Lowering.cpp4
-rw-r--r--src/wasm2js.h5
3 files changed, 8 insertions, 6 deletions
diff --git a/src/abi/js.h b/src/abi/js.h
index 735f71af7..d22376c13 100644
--- a/src/abi/js.h
+++ b/src/abi/js.h
@@ -82,8 +82,9 @@ inline void ensureHelpers(Module* wasm, IString specific = IString()) {
ensureImport(MEMORY_FILL, {Type::i32, Type::i32, Type::i32}, Type::none);
ensureImport(MEMORY_COPY, {Type::i32, Type::i32, Type::i32}, Type::none);
ensureImport(DATA_DROP, {Type::i32}, Type::none);
- ensureImport(
- ATOMIC_WAIT_I32, {Type::i32, Type::i32, Type::i32, Type::i32}, Type::i32);
+ ensureImport(ATOMIC_WAIT_I32,
+ {Type::i32, Type::i32, Type::i32, Type::i32, Type::i32},
+ Type::i32);
ensureImport(
ATOMIC_RMW_I64,
{Type::i32, Type::i32, Type::i32, Type::i32, Type::i32, Type::i32},
diff --git a/src/passes/I64ToI32Lowering.cpp b/src/passes/I64ToI32Lowering.cpp
index aee65c22a..dfcc65a51 100644
--- a/src/passes/I64ToI32Lowering.cpp
+++ b/src/passes/I64ToI32Lowering.cpp
@@ -478,10 +478,10 @@ struct I64ToI32Lowering : public WalkerPass<PostWalker<I64ToI32Lowering>> {
void visitAtomicWait(AtomicWait* curr) {
// The last parameter is an i64, so we cannot leave it as it is
- assert(curr->offset == 0);
replaceCurrent(builder->makeCall(
ABI::wasm2js::ATOMIC_WAIT_I32,
- {curr->ptr,
+ {builder->makeConst(int32_t(curr->offset)),
+ curr->ptr,
curr->expected,
curr->timeout,
builder->makeLocalGet(fetchOutParam(curr->timeout), Type::i32)},
diff --git a/src/wasm2js.h b/src/wasm2js.h
index eddb26866..08969b8ba 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -2989,7 +2989,8 @@ void Wasm2JSGlue::emitSpecialSupport() {
)";
} else if (import->base == ABI::wasm2js::ATOMIC_WAIT_I32) {
out << R"(
- function wasm2js_atomic_wait_i32(ptr, expected, timeoutLow, timeoutHigh) {
+ function wasm2js_atomic_wait_i32(offset, ptr, expected, timeoutLow, timeoutHigh) {
+ ptr = (ptr + offset) >> 2;
var timeout = Infinity;
if (timeoutHigh >= 0) {
// Convert from nanoseconds to milliseconds
@@ -2997,7 +2998,7 @@ void Wasm2JSGlue::emitSpecialSupport() {
timeout = ((timeoutLow >>> 0) / 1e6) + timeoutHigh * (4294967296 / 1e6);
}
var view = new Int32Array(bufferView.buffer); // TODO cache
- var result = Atomics.wait(view, ptr >> 2, expected, timeout);
+ var result = Atomics.wait(view, ptr, expected, timeout);
if (result == 'ok') return 0;
if (result == 'not-equal') return 1;
if (result == 'timed-out') return 2;