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 15 matching lines...) Expand all Loading... |
26 if (!%_IsSharedIntegerTypedArray(ia)) { | 26 if (!%_IsSharedIntegerTypedArray(ia)) { |
27 throw MakeTypeError(kNotIntegerSharedTypedArray, ia); | 27 throw MakeTypeError(kNotIntegerSharedTypedArray, ia); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 //------------------------------------------------------------------- | 31 //------------------------------------------------------------------- |
32 | 32 |
33 function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) { | 33 function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) { |
34 CheckSharedTypedArray(sta); | 34 CheckSharedTypedArray(sta); |
35 index = $toInteger(index); | 35 index = $toInteger(index); |
36 if (index < 0 || index >= sta.length) { | 36 if (index < 0 || index >= %_TypedArrayGetLength(sta)) { |
37 return UNDEFINED; | 37 return UNDEFINED; |
38 } | 38 } |
39 return %_AtomicsCompareExchange(sta, index, oldValue, newValue); | 39 return %_AtomicsCompareExchange(sta, index, oldValue, newValue); |
40 } | 40 } |
41 | 41 |
42 function AtomicsLoadJS(sta, index) { | 42 function AtomicsLoadJS(sta, index) { |
43 CheckSharedTypedArray(sta); | 43 CheckSharedTypedArray(sta); |
44 index = $toInteger(index); | 44 index = $toInteger(index); |
45 if (index < 0 || index >= sta.length) { | 45 if (index < 0 || index >= %_TypedArrayGetLength(sta)) { |
46 return UNDEFINED; | 46 return UNDEFINED; |
47 } | 47 } |
48 return %_AtomicsLoad(sta, index); | 48 return %_AtomicsLoad(sta, index); |
49 } | 49 } |
50 | 50 |
51 function AtomicsStoreJS(sta, index, value) { | 51 function AtomicsStoreJS(sta, index, value) { |
52 CheckSharedTypedArray(sta); | 52 CheckSharedTypedArray(sta); |
53 index = $toInteger(index); | 53 index = $toInteger(index); |
54 if (index < 0 || index >= sta.length) { | 54 if (index < 0 || index >= %_TypedArrayGetLength(sta)) { |
55 return UNDEFINED; | 55 return UNDEFINED; |
56 } | 56 } |
57 return %_AtomicsStore(sta, index, value); | 57 return %_AtomicsStore(sta, index, value); |
58 } | 58 } |
59 | 59 |
60 function AtomicsAddJS(ia, index, value) { | 60 function AtomicsAddJS(ia, index, value) { |
61 CheckSharedIntegerTypedArray(ia); | 61 CheckSharedIntegerTypedArray(ia); |
62 index = $toInteger(index); | 62 index = $toInteger(index); |
63 if (index < 0 || index >= ia.length) { | 63 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
64 return UNDEFINED; | 64 return UNDEFINED; |
65 } | 65 } |
66 return %_AtomicsAdd(ia, index, value); | 66 return %_AtomicsAdd(ia, index, value); |
67 } | 67 } |
68 | 68 |
69 function AtomicsSubJS(ia, index, value) { | 69 function AtomicsSubJS(ia, index, value) { |
70 CheckSharedIntegerTypedArray(ia); | 70 CheckSharedIntegerTypedArray(ia); |
71 index = $toInteger(index); | 71 index = $toInteger(index); |
72 if (index < 0 || index >= ia.length) { | 72 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
73 return UNDEFINED; | 73 return UNDEFINED; |
74 } | 74 } |
75 return %_AtomicsSub(ia, index, value); | 75 return %_AtomicsSub(ia, index, value); |
76 } | 76 } |
77 | 77 |
78 function AtomicsAndJS(ia, index, value) { | 78 function AtomicsAndJS(ia, index, value) { |
79 CheckSharedIntegerTypedArray(ia); | 79 CheckSharedIntegerTypedArray(ia); |
80 index = $toInteger(index); | 80 index = $toInteger(index); |
81 if (index < 0 || index >= ia.length) { | 81 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
82 return UNDEFINED; | 82 return UNDEFINED; |
83 } | 83 } |
84 return %_AtomicsAnd(ia, index, value); | 84 return %_AtomicsAnd(ia, index, value); |
85 } | 85 } |
86 | 86 |
87 function AtomicsOrJS(ia, index, value) { | 87 function AtomicsOrJS(ia, index, value) { |
88 CheckSharedIntegerTypedArray(ia); | 88 CheckSharedIntegerTypedArray(ia); |
89 index = $toInteger(index); | 89 index = $toInteger(index); |
90 if (index < 0 || index >= ia.length) { | 90 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
91 return UNDEFINED; | 91 return UNDEFINED; |
92 } | 92 } |
93 return %_AtomicsOr(ia, index, value); | 93 return %_AtomicsOr(ia, index, value); |
94 } | 94 } |
95 | 95 |
96 function AtomicsXorJS(ia, index, value) { | 96 function AtomicsXorJS(ia, index, value) { |
97 CheckSharedIntegerTypedArray(ia); | 97 CheckSharedIntegerTypedArray(ia); |
98 index = $toInteger(index); | 98 index = $toInteger(index); |
99 if (index < 0 || index >= ia.length) { | 99 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
100 return UNDEFINED; | 100 return UNDEFINED; |
101 } | 101 } |
102 return %_AtomicsXor(ia, index, value); | 102 return %_AtomicsXor(ia, index, value); |
103 } | 103 } |
104 | 104 |
105 function AtomicsExchangeJS(ia, index, value) { | 105 function AtomicsExchangeJS(ia, index, value) { |
106 CheckSharedIntegerTypedArray(ia); | 106 CheckSharedIntegerTypedArray(ia); |
107 index = $toInteger(index); | 107 index = $toInteger(index); |
108 if (index < 0 || index >= ia.length) { | 108 if (index < 0 || index >= %_TypedArrayGetLength(ia)) { |
109 return UNDEFINED; | 109 return UNDEFINED; |
110 } | 110 } |
111 return %_AtomicsExchange(ia, index, value); | 111 return %_AtomicsExchange(ia, index, value); |
112 } | 112 } |
113 | 113 |
114 function AtomicsIsLockFreeJS(size) { | 114 function AtomicsIsLockFreeJS(size) { |
115 return %_AtomicsIsLockFree(size); | 115 return %_AtomicsIsLockFree(size); |
116 } | 116 } |
117 | 117 |
118 // ------------------------------------------------------------------- | 118 // ------------------------------------------------------------------- |
(...skipping 15 matching lines...) Expand all Loading... |
134 "add", AtomicsAddJS, | 134 "add", AtomicsAddJS, |
135 "sub", AtomicsSubJS, | 135 "sub", AtomicsSubJS, |
136 "and", AtomicsAndJS, | 136 "and", AtomicsAndJS, |
137 "or", AtomicsOrJS, | 137 "or", AtomicsOrJS, |
138 "xor", AtomicsXorJS, | 138 "xor", AtomicsXorJS, |
139 "exchange", AtomicsExchangeJS, | 139 "exchange", AtomicsExchangeJS, |
140 "isLockFree", AtomicsIsLockFreeJS, | 140 "isLockFree", AtomicsIsLockFreeJS, |
141 ]); | 141 ]); |
142 | 142 |
143 }) | 143 }) |
OLD | NEW |