| 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 ToNumber; | 15 var ToNumber; |
| 17 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 16 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
| 18 | 17 |
| 19 utils.Import(function(from) { | 18 utils.Import(function(from) { |
| 20 MathMax = from.MathMax; | |
| 21 ToNumber = from.ToNumber; | 19 ToNumber = from.ToNumber; |
| 22 }); | 20 }); |
| 23 | 21 |
| 24 // ------------------------------------------------------------------- | 22 // ------------------------------------------------------------------- |
| 25 | 23 |
| 26 | 24 |
| 27 function CheckSharedIntegerTypedArray(ia) { | 25 function CheckSharedIntegerTypedArray(ia) { |
| 28 if (!%IsSharedIntegerTypedArray(ia)) { | 26 if (!%IsSharedIntegerTypedArray(ia)) { |
| 29 throw MakeTypeError(kNotIntegerSharedTypedArray, ia); | 27 throw MakeTypeError(kNotIntegerSharedTypedArray, ia); |
| 30 } | 28 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { | 139 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
| 142 return UNDEFINED; | 140 return UNDEFINED; |
| 143 } | 141 } |
| 144 if (IS_UNDEFINED(timeout)) { | 142 if (IS_UNDEFINED(timeout)) { |
| 145 timeout = INFINITY; | 143 timeout = INFINITY; |
| 146 } else { | 144 } else { |
| 147 timeout = ToNumber(timeout); | 145 timeout = ToNumber(timeout); |
| 148 if (NUMBER_IS_NAN(timeout)) { | 146 if (NUMBER_IS_NAN(timeout)) { |
| 149 timeout = INFINITY; | 147 timeout = INFINITY; |
| 150 } else { | 148 } else { |
| 151 timeout = MathMax(0, timeout); | 149 timeout = MAX_SIMPLE(0, timeout); |
| 152 } | 150 } |
| 153 } | 151 } |
| 154 return %AtomicsFutexWait(ia, index, value, timeout); | 152 return %AtomicsFutexWait(ia, index, value, timeout); |
| 155 } | 153 } |
| 156 | 154 |
| 157 function AtomicsFutexWakeJS(ia, index, count) { | 155 function AtomicsFutexWakeJS(ia, index, count) { |
| 158 CheckSharedInteger32TypedArray(ia); | 156 CheckSharedInteger32TypedArray(ia); |
| 159 index = $toInteger(index); | 157 index = $toInteger(index); |
| 160 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { | 158 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
| 161 return UNDEFINED; | 159 return UNDEFINED; |
| 162 } | 160 } |
| 163 count = MathMax(0, $toInteger(count)); | 161 count = MAX_SIMPLE(0, $toInteger(count)); |
| 164 return %AtomicsFutexWake(ia, index, count); | 162 return %AtomicsFutexWake(ia, index, count); |
| 165 } | 163 } |
| 166 | 164 |
| 167 function AtomicsFutexWakeOrRequeueJS(ia, index1, count, value, index2) { | 165 function AtomicsFutexWakeOrRequeueJS(ia, index1, count, value, index2) { |
| 168 CheckSharedInteger32TypedArray(ia); | 166 CheckSharedInteger32TypedArray(ia); |
| 169 index1 = $toInteger(index1); | 167 index1 = $toInteger(index1); |
| 170 count = MathMax(0, $toInteger(count)); | 168 count = MAX_SIMPLE(0, $toInteger(count)); |
| 171 value = TO_INT32(value); | 169 value = TO_INT32(value); |
| 172 index2 = $toInteger(index2); | 170 index2 = $toInteger(index2); |
| 173 if (index1 < 0 || index1 >= %_TypedArrayGetLength(ia) || | 171 if (index1 < 0 || index1 >= %_TypedArrayGetLength(ia) || |
| 174 index2 < 0 || index2 >= %_TypedArrayGetLength(ia)) { | 172 index2 < 0 || index2 >= %_TypedArrayGetLength(ia)) { |
| 175 return UNDEFINED; | 173 return UNDEFINED; |
| 176 } | 174 } |
| 177 return %AtomicsFutexWakeOrRequeue(ia, index1, count, value, index2); | 175 return %AtomicsFutexWakeOrRequeue(ia, index1, count, value, index2); |
| 178 } | 176 } |
| 179 | 177 |
| 180 // ------------------------------------------------------------------- | 178 // ------------------------------------------------------------------- |
| (...skipping 25 matching lines...) Expand all Loading... |
| 206 "or", AtomicsOrJS, | 204 "or", AtomicsOrJS, |
| 207 "xor", AtomicsXorJS, | 205 "xor", AtomicsXorJS, |
| 208 "exchange", AtomicsExchangeJS, | 206 "exchange", AtomicsExchangeJS, |
| 209 "isLockFree", AtomicsIsLockFreeJS, | 207 "isLockFree", AtomicsIsLockFreeJS, |
| 210 "futexWait", AtomicsFutexWaitJS, | 208 "futexWait", AtomicsFutexWaitJS, |
| 211 "futexWake", AtomicsFutexWakeJS, | 209 "futexWake", AtomicsFutexWakeJS, |
| 212 "futexWakeOrRequeue", AtomicsFutexWakeOrRequeueJS, | 210 "futexWakeOrRequeue", AtomicsFutexWakeOrRequeueJS, |
| 213 ]); | 211 ]); |
| 214 | 212 |
| 215 }) | 213 }) |
| OLD | NEW |