Chromium Code Reviews| 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 (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 Loading... | |
| 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 Loading... | |
| 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 }) |
| OLD | NEW |