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

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

Issue 1462833002: Support offset-TypedArray in futex API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/futex-emulation.cc ('k') | test/mjsunit/harmony/futex.js » ('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"
(...skipping 12 matching lines...) Expand all
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 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); 27 RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
28 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); 28 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
29 RUNTIME_ASSERT(sta->type() == kExternalInt32Array); 29 RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
30 RUNTIME_ASSERT(timeout == V8_INFINITY || !std::isnan(timeout)); 30 RUNTIME_ASSERT(timeout == V8_INFINITY || !std::isnan(timeout));
31 31
32 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 32 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
33 size_t addr = index << 2; 33 size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
34 34
35 return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout); 35 return FutexEmulation::Wait(isolate, array_buffer, addr, value, timeout);
36 } 36 }
37 37
38 38
39 RUNTIME_FUNCTION(Runtime_AtomicsFutexWake) { 39 RUNTIME_FUNCTION(Runtime_AtomicsFutexWake) {
40 HandleScope scope(isolate); 40 HandleScope scope(isolate);
41 DCHECK(args.length() == 3); 41 DCHECK(args.length() == 3);
42 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); 42 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
43 CONVERT_SIZE_ARG_CHECKED(index, 1); 43 CONVERT_SIZE_ARG_CHECKED(index, 1);
44 CONVERT_INT32_ARG_CHECKED(count, 2); 44 CONVERT_INT32_ARG_CHECKED(count, 2);
45 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); 45 RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
46 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); 46 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
47 RUNTIME_ASSERT(sta->type() == kExternalInt32Array); 47 RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
48 48
49 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 49 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
50 size_t addr = index << 2; 50 size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
51 51
52 return FutexEmulation::Wake(isolate, array_buffer, addr, count); 52 return FutexEmulation::Wake(isolate, array_buffer, addr, count);
53 } 53 }
54 54
55 55
56 RUNTIME_FUNCTION(Runtime_AtomicsFutexWakeOrRequeue) { 56 RUNTIME_FUNCTION(Runtime_AtomicsFutexWakeOrRequeue) {
57 HandleScope scope(isolate); 57 HandleScope scope(isolate);
58 DCHECK(args.length() == 5); 58 DCHECK(args.length() == 5);
59 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); 59 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
60 CONVERT_SIZE_ARG_CHECKED(index1, 1); 60 CONVERT_SIZE_ARG_CHECKED(index1, 1);
61 CONVERT_INT32_ARG_CHECKED(count, 2); 61 CONVERT_INT32_ARG_CHECKED(count, 2);
62 CONVERT_INT32_ARG_CHECKED(value, 3); 62 CONVERT_INT32_ARG_CHECKED(value, 3);
63 CONVERT_SIZE_ARG_CHECKED(index2, 4); 63 CONVERT_SIZE_ARG_CHECKED(index2, 4);
64 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); 64 RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
65 RUNTIME_ASSERT(index1 < NumberToSize(isolate, sta->length())); 65 RUNTIME_ASSERT(index1 < NumberToSize(isolate, sta->length()));
66 RUNTIME_ASSERT(index2 < NumberToSize(isolate, sta->length())); 66 RUNTIME_ASSERT(index2 < NumberToSize(isolate, sta->length()));
67 RUNTIME_ASSERT(sta->type() == kExternalInt32Array); 67 RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
68 68
69 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 69 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
70 size_t addr1 = index1 << 2; 70 size_t addr1 = (index1 << 2) + NumberToSize(isolate, sta->byte_offset());
71 size_t addr2 = index2 << 2; 71 size_t addr2 = (index2 << 2) + NumberToSize(isolate, sta->byte_offset());
72 72
73 return FutexEmulation::WakeOrRequeue(isolate, array_buffer, addr1, count, 73 return FutexEmulation::WakeOrRequeue(isolate, array_buffer, addr1, count,
74 value, addr2); 74 value, addr2);
75 } 75 }
76 76
77 77
78 RUNTIME_FUNCTION(Runtime_AtomicsFutexNumWaitersForTesting) { 78 RUNTIME_FUNCTION(Runtime_AtomicsFutexNumWaitersForTesting) {
79 HandleScope scope(isolate); 79 HandleScope scope(isolate);
80 DCHECK(args.length() == 2); 80 DCHECK(args.length() == 2);
81 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); 81 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
82 CONVERT_SIZE_ARG_CHECKED(index, 1); 82 CONVERT_SIZE_ARG_CHECKED(index, 1);
83 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); 83 RUNTIME_ASSERT(sta->GetBuffer()->is_shared());
84 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); 84 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length()));
85 RUNTIME_ASSERT(sta->type() == kExternalInt32Array); 85 RUNTIME_ASSERT(sta->type() == kExternalInt32Array);
86 86
87 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 87 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
88 size_t addr = index << 2; 88 size_t addr = (index << 2) + NumberToSize(isolate, sta->byte_offset());
89 89
90 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr); 90 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr);
91 } 91 }
92 } // namespace internal 92 } // namespace internal
93 } // namespace v8 93 } // namespace v8
OLDNEW
« no previous file with comments | « src/futex-emulation.cc ('k') | test/mjsunit/harmony/futex.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698