diff options
Diffstat (limited to 'src/runtime/runtime-futex.cc')
-rw-r--r-- | src/runtime/runtime-futex.cc | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/runtime/runtime-futex.cc b/src/runtime/runtime-futex.cc index a93bb236..b6582ffc 100644 --- a/src/runtime/runtime-futex.cc +++ b/src/runtime/runtime-futex.cc @@ -19,7 +19,7 @@ namespace internal { RUNTIME_FUNCTION(Runtime_AtomicsWait) { HandleScope scope(isolate); - DCHECK(args.length() == 4); + DCHECK_EQ(4, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); CONVERT_SIZE_ARG_CHECKED(index, 1); CONVERT_INT32_ARG_CHECKED(value, 2); @@ -29,6 +29,11 @@ RUNTIME_FUNCTION(Runtime_AtomicsWait) { CHECK_EQ(sta->type(), kExternalInt32Array); CHECK(timeout == V8_INFINITY || !std::isnan(timeout)); + if (!isolate->allow_atomics_wait()) { + THROW_NEW_ERROR_RETURN_FAILURE( + isolate, NewTypeError(MessageTemplate::kAtomicsWaitNotAllowed)); + } + Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); @@ -37,10 +42,10 @@ RUNTIME_FUNCTION(Runtime_AtomicsWait) { RUNTIME_FUNCTION(Runtime_AtomicsWake) { HandleScope scope(isolate); - DCHECK(args.length() == 3); + DCHECK_EQ(3, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); CONVERT_SIZE_ARG_CHECKED(index, 1); - CONVERT_INT32_ARG_CHECKED(count, 2); + CONVERT_UINT32_ARG_CHECKED(count, 2); CHECK(sta->GetBuffer()->is_shared()); CHECK_LT(index, NumberToSize(sta->length())); CHECK_EQ(sta->type(), kExternalInt32Array); @@ -53,7 +58,7 @@ RUNTIME_FUNCTION(Runtime_AtomicsWake) { RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) { HandleScope scope(isolate); - DCHECK(args.length() == 2); + DCHECK_EQ(2, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); CONVERT_SIZE_ARG_CHECKED(index, 1); CHECK(sta->GetBuffer()->is_shared()); @@ -65,5 +70,14 @@ RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) { return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr); } + +RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) { + HandleScope scope(isolate); + DCHECK_EQ(1, args.length()); + CONVERT_BOOLEAN_ARG_CHECKED(set, 0); + + isolate->set_allow_atomics_wait(set); + return isolate->heap()->undefined_value(); +} } // namespace internal } // namespace v8 |