[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 <thibaudm@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70948}
This commit is contained in:
Andreas Haas 2020-11-03 12:27:26 +01:00 committed by Commit Bot
parent 8574179a90
commit 4c2fd721d6

View File

@ -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<JSArrayBuffer> array_buffer(
instance_object_->memory_object().array_buffer(), isolate_);