Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: src/runtime/runtime-futex.cc

Issue 2732213005: Revert "This is a speculative chain of reverts to improve a Chrome" (Closed)
Patch Set: merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-atomics.cc ('k') | src/snapshot/natives.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "src/globals.h" 11 #include "src/globals.h"
12 12
13 // Implement Futex API for SharedArrayBuffers as defined in the 13 // Implement Futex API for SharedArrayBuffers as defined in the
14 // SharedArrayBuffer draft spec, found here: 14 // SharedArrayBuffer draft spec, found here:
15 // https://github.com/tc39/ecmascript_sharedmem 15 // https://github.com/tc39/ecmascript_sharedmem
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 RUNTIME_FUNCTION(Runtime_AtomicsWait) {
21 HandleScope scope(isolate);
22 DCHECK_EQ(4, args.length());
23 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
24 CONVERT_SIZE_ARG_CHECKED(index, 1);
25 CONVERT_INT32_ARG_CHECKED(value, 2);
26 CONVERT_DOUBLE_ARG_CHECKED(timeout, 3);
27 CHECK(sta->GetBuffer()->is_shared());
28 CHECK_LT(index, NumberToSize(sta->length()));
29 CHECK_EQ(sta->type(), kExternalInt32Array);
30 CHECK(timeout == V8_INFINITY || !std::isnan(timeout));
31
32 if (!isolate->allow_atomics_wait()) {
33 THROW_NEW_ERROR_RETURN_FAILURE(
34 isolate, NewTypeError(MessageTemplate::kAtomicsWaitNotAllowed));
35 }
36
37 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
38 size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
39
40 return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout);
41 }
42
43 RUNTIME_FUNCTION(Runtime_AtomicsWake) {
44 HandleScope scope(isolate);
45 DCHECK_EQ(3, args.length());
46 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
47 CONVERT_SIZE_ARG_CHECKED(index, 1);
48 CONVERT_UINT32_ARG_CHECKED(count, 2);
49 CHECK(sta->GetBuffer()->is_shared());
50 CHECK_LT(index, NumberToSize(sta->length()));
51 CHECK_EQ(sta->type(), kExternalInt32Array);
52
53 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
54 size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
55
56 return FutexEmulation::Wake(isolate, array_buffer, addr, count);
57 }
58 20
59 RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) { 21 RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) {
60 HandleScope scope(isolate); 22 HandleScope scope(isolate);
61 DCHECK_EQ(2, args.length()); 23 DCHECK_EQ(2, args.length());
62 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); 24 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
63 CONVERT_SIZE_ARG_CHECKED(index, 1); 25 CONVERT_SIZE_ARG_CHECKED(index, 1);
64 CHECK(sta->GetBuffer()->is_shared()); 26 CHECK(sta->GetBuffer()->is_shared());
65 CHECK_LT(index, NumberToSize(sta->length())); 27 CHECK_LT(index, NumberToSize(sta->length()));
66 CHECK_EQ(sta->type(), kExternalInt32Array); 28 CHECK_EQ(sta->type(), kExternalInt32Array);
67 29
68 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 30 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
69 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); 31 size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
70 32
71 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr); 33 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr);
72 } 34 }
73 35
74 RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) { 36 RUNTIME_FUNCTION(Runtime_SetAllowAtomicsWait) {
75 HandleScope scope(isolate); 37 HandleScope scope(isolate);
76 DCHECK_EQ(1, args.length()); 38 DCHECK_EQ(1, args.length());
77 CONVERT_BOOLEAN_ARG_CHECKED(set, 0); 39 CONVERT_BOOLEAN_ARG_CHECKED(set, 0);
78 40
79 isolate->set_allow_atomics_wait(set); 41 isolate->set_allow_atomics_wait(set);
80 return isolate->heap()->undefined_value(); 42 return isolate->heap()->undefined_value();
81 } 43 }
82 } // namespace internal 44 } // namespace internal
83 } // namespace v8 45 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-atomics.cc ('k') | src/snapshot/natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698