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

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

Issue 2613723002: [runtime] Use DCHECK_EQ instead of DCHECK for number of args. (Closed)
Patch Set: Rebase. Created 3 years, 11 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-function.cc ('k') | src/runtime/runtime-generator.cc » ('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) { 20 RUNTIME_FUNCTION(Runtime_AtomicsWait) {
21 HandleScope scope(isolate); 21 HandleScope scope(isolate);
22 DCHECK(args.length() == 4); 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 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 32 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
33 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); 33 size_t addr = (index << 2) + NumberToSize(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 RUNTIME_FUNCTION(Runtime_AtomicsWake) { 38 RUNTIME_FUNCTION(Runtime_AtomicsWake) {
39 HandleScope scope(isolate); 39 HandleScope scope(isolate);
40 DCHECK(args.length() == 3); 40 DCHECK_EQ(3, args.length());
41 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); 41 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
42 CONVERT_SIZE_ARG_CHECKED(index, 1); 42 CONVERT_SIZE_ARG_CHECKED(index, 1);
43 CONVERT_INT32_ARG_CHECKED(count, 2); 43 CONVERT_INT32_ARG_CHECKED(count, 2);
44 CHECK(sta->GetBuffer()->is_shared()); 44 CHECK(sta->GetBuffer()->is_shared());
45 CHECK_LT(index, NumberToSize(sta->length())); 45 CHECK_LT(index, NumberToSize(sta->length()));
46 CHECK_EQ(sta->type(), kExternalInt32Array); 46 CHECK_EQ(sta->type(), kExternalInt32Array);
47 47
48 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 48 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
49 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); 49 size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
50 50
51 return FutexEmulation::Wake(isolate, array_buffer, addr, count); 51 return FutexEmulation::Wake(isolate, array_buffer, addr, count);
52 } 52 }
53 53
54 RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) { 54 RUNTIME_FUNCTION(Runtime_AtomicsNumWaitersForTesting) {
55 HandleScope scope(isolate); 55 HandleScope scope(isolate);
56 DCHECK(args.length() == 2); 56 DCHECK_EQ(2, args.length());
57 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); 57 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0);
58 CONVERT_SIZE_ARG_CHECKED(index, 1); 58 CONVERT_SIZE_ARG_CHECKED(index, 1);
59 CHECK(sta->GetBuffer()->is_shared()); 59 CHECK(sta->GetBuffer()->is_shared());
60 CHECK_LT(index, NumberToSize(sta->length())); 60 CHECK_LT(index, NumberToSize(sta->length()));
61 CHECK_EQ(sta->type(), kExternalInt32Array); 61 CHECK_EQ(sta->type(), kExternalInt32Array);
62 62
63 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer(); 63 Handle<JSArrayBuffer> array_buffer = sta->GetBuffer();
64 size_t addr = (index << 2) + NumberToSize(sta->byte_offset()); 64 size_t addr = (index << 2) + NumberToSize(sta->byte_offset());
65 65
66 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr); 66 return FutexEmulation::NumWaitersForTesting(isolate, array_buffer, addr);
67 } 67 }
68 } // namespace internal 68 } // namespace internal
69 } // namespace v8 69 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | src/runtime/runtime-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698