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

Side by Side Diff: src/harmony-atomics.js

Issue 1390023003: Use simple/fast macro version of MinMax in JS (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: avoid debug directory Created 5 years, 2 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/harmony-array.js ('k') | src/harmony-typedarray.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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var GlobalObject = global.Object; 14 var GlobalObject = global.Object;
15 var MathMax;
16 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 15 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
17 16
18 utils.Import(function(from) {
19 MathMax = from.MathMax;
20 });
21
22 // ------------------------------------------------------------------- 17 // -------------------------------------------------------------------
23 18
24 19
25 function CheckSharedIntegerTypedArray(ia) { 20 function CheckSharedIntegerTypedArray(ia) {
26 if (!%IsSharedIntegerTypedArray(ia)) { 21 if (!%IsSharedIntegerTypedArray(ia)) {
27 throw MakeTypeError(kNotIntegerSharedTypedArray, ia); 22 throw MakeTypeError(kNotIntegerSharedTypedArray, ia);
28 } 23 }
29 } 24 }
30 25
31 function CheckSharedInteger32TypedArray(ia) { 26 function CheckSharedInteger32TypedArray(ia) {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { 134 if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
140 return UNDEFINED; 135 return UNDEFINED;
141 } 136 }
142 if (IS_UNDEFINED(timeout)) { 137 if (IS_UNDEFINED(timeout)) {
143 timeout = INFINITY; 138 timeout = INFINITY;
144 } else { 139 } else {
145 timeout = TO_NUMBER(timeout); 140 timeout = TO_NUMBER(timeout);
146 if (NUMBER_IS_NAN(timeout)) { 141 if (NUMBER_IS_NAN(timeout)) {
147 timeout = INFINITY; 142 timeout = INFINITY;
148 } else { 143 } else {
149 timeout = MathMax(0, timeout); 144 timeout = MAX_SIMPLE(0, timeout);
150 } 145 }
151 } 146 }
152 return %AtomicsFutexWait(ia, index, value, timeout); 147 return %AtomicsFutexWait(ia, index, value, timeout);
153 } 148 }
154 149
155 function AtomicsFutexWakeJS(ia, index, count) { 150 function AtomicsFutexWakeJS(ia, index, count) {
156 CheckSharedInteger32TypedArray(ia); 151 CheckSharedInteger32TypedArray(ia);
157 index = TO_INTEGER(index); 152 index = TO_INTEGER(index);
158 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { 153 if (index < 0 || index >= %_TypedArrayGetLength(ia)) {
159 return UNDEFINED; 154 return UNDEFINED;
160 } 155 }
161 count = MathMax(0, TO_INTEGER(count)); 156 count = MAX_SIMPLE(0, TO_INTEGER(count));
Michael Starzinger 2015/10/07 19:02:23 I don't have a machine where I could verify this r
162 return %AtomicsFutexWake(ia, index, count); 157 return %AtomicsFutexWake(ia, index, count);
163 } 158 }
164 159
165 function AtomicsFutexWakeOrRequeueJS(ia, index1, count, value, index2) { 160 function AtomicsFutexWakeOrRequeueJS(ia, index1, count, value, index2) {
166 CheckSharedInteger32TypedArray(ia); 161 CheckSharedInteger32TypedArray(ia);
167 index1 = TO_INTEGER(index1); 162 index1 = TO_INTEGER(index1);
168 count = MathMax(0, TO_INTEGER(count)); 163 count = MAX_SIMPLE(0, TO_INTEGER(count));
Michael Starzinger 2015/10/07 19:02:23 Likewise.
169 value = TO_INT32(value); 164 value = TO_INT32(value);
170 index2 = TO_INTEGER(index2); 165 index2 = TO_INTEGER(index2);
171 if (index1 < 0 || index1 >= %_TypedArrayGetLength(ia) || 166 if (index1 < 0 || index1 >= %_TypedArrayGetLength(ia) ||
172 index2 < 0 || index2 >= %_TypedArrayGetLength(ia)) { 167 index2 < 0 || index2 >= %_TypedArrayGetLength(ia)) {
173 return UNDEFINED; 168 return UNDEFINED;
174 } 169 }
175 return %AtomicsFutexWakeOrRequeue(ia, index1, count, value, index2); 170 return %AtomicsFutexWakeOrRequeue(ia, index1, count, value, index2);
176 } 171 }
177 172
178 // ------------------------------------------------------------------- 173 // -------------------------------------------------------------------
(...skipping 25 matching lines...) Expand all
204 "or", AtomicsOrJS, 199 "or", AtomicsOrJS,
205 "xor", AtomicsXorJS, 200 "xor", AtomicsXorJS,
206 "exchange", AtomicsExchangeJS, 201 "exchange", AtomicsExchangeJS,
207 "isLockFree", AtomicsIsLockFreeJS, 202 "isLockFree", AtomicsIsLockFreeJS,
208 "futexWait", AtomicsFutexWaitJS, 203 "futexWait", AtomicsFutexWaitJS,
209 "futexWake", AtomicsFutexWakeJS, 204 "futexWake", AtomicsFutexWakeJS,
210 "futexWakeOrRequeue", AtomicsFutexWakeOrRequeueJS, 205 "futexWakeOrRequeue", AtomicsFutexWakeOrRequeueJS,
211 ]); 206 ]);
212 207
213 }) 208 })
OLDNEW
« no previous file with comments | « src/harmony-array.js ('k') | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698