OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/base/platform/time.h" | 8 #include "src/base/platform/time.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/futex-emulation.h" | 10 #include "src/futex-emulation.h" |
(...skipping 11 matching lines...) Loading... |
22 DCHECK_EQ(4, args.length()); | 22 DCHECK_EQ(4, args.length()); |
23 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 23 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
24 CONVERT_SIZE_ARG_CHECKED(index, 1); | 24 CONVERT_SIZE_ARG_CHECKED(index, 1); |
25 CONVERT_INT32_ARG_CHECKED(value, 2); | 25 CONVERT_INT32_ARG_CHECKED(value, 2); |
26 CONVERT_DOUBLE_ARG_CHECKED(timeout, 3); | 26 CONVERT_DOUBLE_ARG_CHECKED(timeout, 3); |
27 CHECK(sta->GetBuffer()->is_shared()); | 27 CHECK(sta->GetBuffer()->is_shared()); |
28 CHECK_LT(index, NumberToSize(sta->length())); | 28 CHECK_LT(index, NumberToSize(sta->length())); |
29 CHECK_EQ(sta->type(), kExternalInt32Array); | 29 CHECK_EQ(sta->type(), kExternalInt32Array); |
30 CHECK(timeout == V8_INFINITY || !std::isnan(timeout)); | 30 CHECK(timeout == V8_INFINITY || !std::isnan(timeout)); |
31 | 31 |
| 32 if (!isolate->allow_atomics_wait()) { |
| 33 THROW_NEW_ERROR_RETURN_FAILURE( |
| 34 isolate, NewTypeError(MessageTemplate::kAtomicsWaitNotAllowed)); |
| 35 } |
| 36 |
32 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); | 37 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); |
33 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); | 38 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); |
34 | 39 |
35 return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout); | 40 return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout); |
36 } | 41 } |
37 | 42 |
38 RUNTIME_FUNCTION(Runtime_AtomicsWake) { | 43 RUNTIME_FUNCTION(Runtime_AtomicsWake) { |
39 HandleScope scope(isolate); | 44 HandleScope scope(isolate); |
40 DCHECK_EQ(3, args.length()); | 45 DCHECK_EQ(3, args.length()); |
41 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 46 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
(...skipping 16 matching lines...) Loading... |
58 CONVERT_SIZE_ARG_CHECKED(index, 1); | 63 CONVERT_SIZE_ARG_CHECKED(index, 1); |
59 CHECK(sta->GetBuffer()->is_shared()); | 64 CHECK(sta->GetBuffer()->is_shared()); |
60 CHECK_LT(index, NumberToSize(sta->length())); | 65 CHECK_LT(index, NumberToSize(sta->length())); |
61 CHECK_EQ(sta->type(), kExternalInt32Array); | 66 CHECK_EQ(sta->type(), kExternalInt32Array); |
62 | 67 |
63 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); | 68 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); |
64 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); | 69 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); |
65 | 70 |
66 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr); | 71 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr); |
67 } | 72 } |
| 73 |
| 74 RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) { |
| 75 HandleScope scope(isolate); |
| 76 DCHECK_EQ(1, args.length()); |
| 77 CONVERT_BOOLEAN_ARG_CHECKED(set, 0); |
| 78 |
| 79 isolate->set_allow_atomics_wait(set); |
| 80 return isolate->heap()->undefined_value(); |
| 81 } |
68 } // namespace internal | 82 } // namespace internal |
69 } // namespace v8 | 83 } // namespace v8 |
OLD | NEW |