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 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 throw %make_range_error(kInvalidAtomicAccessIndex); | 45 throw %make_range_error(kInvalidAtomicAccessIndex); |
46 } | 46 } |
47 if (accessIndex < 0 || accessIndex >= length) { | 47 if (accessIndex < 0 || accessIndex >= length) { |
48 throw %make_range_error(kInvalidAtomicAccessIndex); | 48 throw %make_range_error(kInvalidAtomicAccessIndex); |
49 } | 49 } |
50 return accessIndex; | 50 return accessIndex; |
51 } | 51 } |
52 | 52 |
53 //------------------------------------------------------------------- | 53 //------------------------------------------------------------------- |
54 | 54 |
55 function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) { | |
56 CheckSharedIntegerTypedArray(sta); | |
57 index = ValidateIndex(index, %_TypedArrayGetLength(sta)); | |
58 oldValue = TO_NUMBER(oldValue); | |
59 newValue = TO_NUMBER(newValue); | |
60 return %_AtomicsCompareExchange(sta, index, oldValue, newValue); | |
61 } | |
62 | |
63 function AtomicsAddJS(ia, index, value) { | 55 function AtomicsAddJS(ia, index, value) { |
64 CheckSharedIntegerTypedArray(ia); | 56 CheckSharedIntegerTypedArray(ia); |
65 index = ValidateIndex(index, %_TypedArrayGetLength(ia)); | 57 index = ValidateIndex(index, %_TypedArrayGetLength(ia)); |
66 value = TO_NUMBER(value); | 58 value = TO_NUMBER(value); |
67 return %_AtomicsAdd(ia, index, value); | 59 return %_AtomicsAdd(ia, index, value); |
68 } | 60 } |
69 | 61 |
70 function AtomicsSubJS(ia, index, value) { | 62 function AtomicsSubJS(ia, index, value) { |
71 CheckSharedIntegerTypedArray(ia); | 63 CheckSharedIntegerTypedArray(ia); |
72 index = ValidateIndex(index, %_TypedArrayGetLength(ia)); | 64 index = ValidateIndex(index, %_TypedArrayGetLength(ia)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 123 |
132 var Atomics = global.Atomics; | 124 var Atomics = global.Atomics; |
133 | 125 |
134 // The Atomics global is defined by the bootstrapper. | 126 // The Atomics global is defined by the bootstrapper. |
135 | 127 |
136 %AddNamedProperty(Atomics, toStringTagSymbol, "Atomics", READ_ONLY | DONT_ENUM); | 128 %AddNamedProperty(Atomics, toStringTagSymbol, "Atomics", READ_ONLY | DONT_ENUM); |
137 | 129 |
138 utils.InstallFunctions(Atomics, DONT_ENUM, [ | 130 utils.InstallFunctions(Atomics, DONT_ENUM, [ |
139 // TODO(binji): remove the rest of the (non futex) Atomics functions as they | 131 // TODO(binji): remove the rest of the (non futex) Atomics functions as they |
140 // become builtins. | 132 // become builtins. |
141 "compareExchange", AtomicsCompareExchangeJS, | |
142 "add", AtomicsAddJS, | 133 "add", AtomicsAddJS, |
143 "sub", AtomicsSubJS, | 134 "sub", AtomicsSubJS, |
144 "and", AtomicsAndJS, | 135 "and", AtomicsAndJS, |
145 "or", AtomicsOrJS, | 136 "or", AtomicsOrJS, |
146 "xor", AtomicsXorJS, | 137 "xor", AtomicsXorJS, |
147 "isLockFree", AtomicsIsLockFreeJS, | 138 "isLockFree", AtomicsIsLockFreeJS, |
148 "wait", AtomicsWaitJS, | 139 "wait", AtomicsWaitJS, |
149 "wake", AtomicsWakeJS, | 140 "wake", AtomicsWakeJS, |
150 ]); | 141 ]); |
151 | 142 |
152 }) | 143 }) |
OLD | NEW |