From 4c2fd721d61ca944e0c4dd46295da214b861d02b Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Tue, 3 Nov 2020 12:27:26 +0100 Subject: [PATCH] [wasm][interpreter] Check for shared memory in atomic.wait For atomic.wait we have to check in generated code if the memory is shared. If not, the code has to trap. In compiled code, this is done in the runtime function. In the interpreter, however, this check was missing. This CL adds the check to the interpreter. R=thibaudm@chromium.org Bug: chromium:1144603 Change-Id: If897e3f10b404ff677341ee14ad9eda7f5e64d16 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2512922 Reviewed-by: Thibaud Michaud Commit-Queue: Andreas Haas Cr-Commit-Position: refs/heads/master@{#70948} --- test/common/wasm/wasm-interpreter.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/common/wasm/wasm-interpreter.cc b/test/common/wasm/wasm-interpreter.cc index 6310c90fb4..6820e20449 100644 --- a/test/common/wasm/wasm-interpreter.cc +++ b/test/common/wasm/wasm-interpreter.cc @@ -2034,6 +2034,10 @@ class WasmInterpreterInternals { *len += 1; break; case kExprI32AtomicWait: { + if (!module()->has_shared_memory) { + DoTrap(kTrapUnreachable, pc); + return false; + } int32_t val; int64_t timeout; uint32_t buffer_offset; @@ -2050,6 +2054,10 @@ class WasmInterpreterInternals { break; } case kExprI64AtomicWait: { + if (!module()->has_shared_memory) { + DoTrap(kTrapUnreachable, pc); + return false; + } int64_t val; int64_t timeout; uint32_t buffer_offset; @@ -2072,6 +2080,10 @@ class WasmInterpreterInternals { &buffer_offset, &val)) { return false; } + if (!module()->has_shared_memory) { + Push(WasmValue(0)); + break; + } HandleScope handle_scope(isolate_); Handle array_buffer( instance_object_->memory_object().array_buffer(), isolate_);