| 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 18 matching lines...) Expand all Loading... |
| 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 >= sta.length) { |
| 37 return UNDEFINED; | 37 return UNDEFINED; |
| 38 } | 38 } |
| 39 oldValue = $toNumber(oldValue); |
| 40 newValue = $toNumber(newValue); |
| 39 return %_AtomicsCompareExchange(sta, index, oldValue, newValue); | 41 return %_AtomicsCompareExchange(sta, index, oldValue, newValue); |
| 40 } | 42 } |
| 41 | 43 |
| 42 function AtomicsLoadJS(sta, index) { | 44 function AtomicsLoadJS(sta, index) { |
| 43 CheckSharedTypedArray(sta); | 45 CheckSharedTypedArray(sta); |
| 44 index = $toInteger(index); | 46 index = $toInteger(index); |
| 45 if (index < 0 || index >= sta.length) { | 47 if (index < 0 || index >= sta.length) { |
| 46 return UNDEFINED; | 48 return UNDEFINED; |
| 47 } | 49 } |
| 48 return %_AtomicsLoad(sta, index); | 50 return %_AtomicsLoad(sta, index); |
| 49 } | 51 } |
| 50 | 52 |
| 51 function AtomicsStoreJS(sta, index, value) { | 53 function AtomicsStoreJS(sta, index, value) { |
| 52 CheckSharedTypedArray(sta); | 54 CheckSharedTypedArray(sta); |
| 53 index = $toInteger(index); | 55 index = $toInteger(index); |
| 54 if (index < 0 || index >= sta.length) { | 56 if (index < 0 || index >= sta.length) { |
| 55 return UNDEFINED; | 57 return UNDEFINED; |
| 56 } | 58 } |
| 59 value = $toNumber(value); |
| 57 return %_AtomicsStore(sta, index, value); | 60 return %_AtomicsStore(sta, index, value); |
| 58 } | 61 } |
| 59 | 62 |
| 60 function AtomicsAddJS(ia, index, value) { | 63 function AtomicsAddJS(ia, index, value) { |
| 61 CheckSharedIntegerTypedArray(ia); | 64 CheckSharedIntegerTypedArray(ia); |
| 62 index = $toInteger(index); | 65 index = $toInteger(index); |
| 63 if (index < 0 || index >= ia.length) { | 66 if (index < 0 || index >= ia.length) { |
| 64 return UNDEFINED; | 67 return UNDEFINED; |
| 65 } | 68 } |
| 69 value = $toNumber(value); |
| 66 return %_AtomicsAdd(ia, index, value); | 70 return %_AtomicsAdd(ia, index, value); |
| 67 } | 71 } |
| 68 | 72 |
| 69 function AtomicsSubJS(ia, index, value) { | 73 function AtomicsSubJS(ia, index, value) { |
| 70 CheckSharedIntegerTypedArray(ia); | 74 CheckSharedIntegerTypedArray(ia); |
| 71 index = $toInteger(index); | 75 index = $toInteger(index); |
| 72 if (index < 0 || index >= ia.length) { | 76 if (index < 0 || index >= ia.length) { |
| 73 return UNDEFINED; | 77 return UNDEFINED; |
| 74 } | 78 } |
| 79 value = $toNumber(value); |
| 75 return %_AtomicsSub(ia, index, value); | 80 return %_AtomicsSub(ia, index, value); |
| 76 } | 81 } |
| 77 | 82 |
| 78 function AtomicsAndJS(ia, index, value) { | 83 function AtomicsAndJS(ia, index, value) { |
| 79 CheckSharedIntegerTypedArray(ia); | 84 CheckSharedIntegerTypedArray(ia); |
| 80 index = $toInteger(index); | 85 index = $toInteger(index); |
| 81 if (index < 0 || index >= ia.length) { | 86 if (index < 0 || index >= ia.length) { |
| 82 return UNDEFINED; | 87 return UNDEFINED; |
| 83 } | 88 } |
| 89 value = $toNumber(value); |
| 84 return %_AtomicsAnd(ia, index, value); | 90 return %_AtomicsAnd(ia, index, value); |
| 85 } | 91 } |
| 86 | 92 |
| 87 function AtomicsOrJS(ia, index, value) { | 93 function AtomicsOrJS(ia, index, value) { |
| 88 CheckSharedIntegerTypedArray(ia); | 94 CheckSharedIntegerTypedArray(ia); |
| 89 index = $toInteger(index); | 95 index = $toInteger(index); |
| 90 if (index < 0 || index >= ia.length) { | 96 if (index < 0 || index >= ia.length) { |
| 91 return UNDEFINED; | 97 return UNDEFINED; |
| 92 } | 98 } |
| 99 value = $toNumber(value); |
| 93 return %_AtomicsOr(ia, index, value); | 100 return %_AtomicsOr(ia, index, value); |
| 94 } | 101 } |
| 95 | 102 |
| 96 function AtomicsXorJS(ia, index, value) { | 103 function AtomicsXorJS(ia, index, value) { |
| 97 CheckSharedIntegerTypedArray(ia); | 104 CheckSharedIntegerTypedArray(ia); |
| 98 index = $toInteger(index); | 105 index = $toInteger(index); |
| 99 if (index < 0 || index >= ia.length) { | 106 if (index < 0 || index >= ia.length) { |
| 100 return UNDEFINED; | 107 return UNDEFINED; |
| 101 } | 108 } |
| 109 value = $toNumber(value); |
| 102 return %_AtomicsXor(ia, index, value); | 110 return %_AtomicsXor(ia, index, value); |
| 103 } | 111 } |
| 104 | 112 |
| 105 function AtomicsExchangeJS(ia, index, value) { | 113 function AtomicsExchangeJS(ia, index, value) { |
| 106 CheckSharedIntegerTypedArray(ia); | 114 CheckSharedIntegerTypedArray(ia); |
| 107 index = $toInteger(index); | 115 index = $toInteger(index); |
| 108 if (index < 0 || index >= ia.length) { | 116 if (index < 0 || index >= ia.length) { |
| 109 return UNDEFINED; | 117 return UNDEFINED; |
| 110 } | 118 } |
| 119 value = $toNumber(value); |
| 111 return %_AtomicsExchange(ia, index, value); | 120 return %_AtomicsExchange(ia, index, value); |
| 112 } | 121 } |
| 113 | 122 |
| 114 function AtomicsIsLockFreeJS(size) { | 123 function AtomicsIsLockFreeJS(size) { |
| 115 return %_AtomicsIsLockFree(size); | 124 return %_AtomicsIsLockFree(size); |
| 116 } | 125 } |
| 117 | 126 |
| 118 // ------------------------------------------------------------------- | 127 // ------------------------------------------------------------------- |
| 119 | 128 |
| 120 function AtomicsConstructor() {} | 129 function AtomicsConstructor() {} |
| (...skipping 13 matching lines...) Expand all Loading... |
| 134 "add", AtomicsAddJS, | 143 "add", AtomicsAddJS, |
| 135 "sub", AtomicsSubJS, | 144 "sub", AtomicsSubJS, |
| 136 "and", AtomicsAndJS, | 145 "and", AtomicsAndJS, |
| 137 "or", AtomicsOrJS, | 146 "or", AtomicsOrJS, |
| 138 "xor", AtomicsXorJS, | 147 "xor", AtomicsXorJS, |
| 139 "exchange", AtomicsExchangeJS, | 148 "exchange", AtomicsExchangeJS, |
| 140 "isLockFree", AtomicsIsLockFreeJS, | 149 "isLockFree", AtomicsIsLockFreeJS, |
| 141 ]); | 150 ]); |
| 142 | 151 |
| 143 }) | 152 }) |
| OLD | NEW |