OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 // Flags: --harmony-atomics --harmony-sharedarraybuffer | 5 // Flags: --harmony-atomics --harmony-sharedarraybuffer |
6 // | 6 // |
7 | 7 |
8 function toRangeWrapped(value) { | 8 function toRangeWrapped(value) { |
9 var range = this.max - this.min + 1; | 9 var range = this.max - this.min + 1; |
10 while (value < this.min) { | 10 while (value < this.min) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 assertEquals(undefined, Atomics.compareExchange(si32a, i, 0, 0), name); | 116 assertEquals(undefined, Atomics.compareExchange(si32a, i, 0, 0), name); |
117 assertEquals(undefined, Atomics.load(si32a, i), name); | 117 assertEquals(undefined, Atomics.load(si32a, i), name); |
118 assertEquals(undefined, Atomics.store(si32a, i, 0), name); | 118 assertEquals(undefined, Atomics.store(si32a, i, 0), name); |
119 assertEquals(undefined, Atomics.add(si32a, i, 0), name); | 119 assertEquals(undefined, Atomics.add(si32a, i, 0), name); |
120 assertEquals(undefined, Atomics.sub(si32a, i, 0), name); | 120 assertEquals(undefined, Atomics.sub(si32a, i, 0), name); |
121 assertEquals(undefined, Atomics.and(si32a, i, 0), name); | 121 assertEquals(undefined, Atomics.and(si32a, i, 0), name); |
122 assertEquals(undefined, Atomics.or(si32a, i, 0), name); | 122 assertEquals(undefined, Atomics.or(si32a, i, 0), name); |
123 assertEquals(undefined, Atomics.xor(si32a, i, 0), name); | 123 assertEquals(undefined, Atomics.xor(si32a, i, 0), name); |
124 assertEquals(undefined, Atomics.exchange(si32a, i, 0), name); | 124 assertEquals(undefined, Atomics.exchange(si32a, i, 0), name); |
125 }); | 125 }); |
| 126 |
| 127 // Monkey-patch length and make sure these functions still return undefined. |
| 128 Object.defineProperty(si32a, 'length', {get: function() { return 1000; }}); |
| 129 [2, 100].forEach(function(i) { |
| 130 var name = String(i); |
| 131 assertEquals(undefined, Atomics.compareExchange(si32a, i, 0, 0), name); |
| 132 assertEquals(undefined, Atomics.load(si32a, i), name); |
| 133 assertEquals(undefined, Atomics.store(si32a, i, 0), name); |
| 134 assertEquals(undefined, Atomics.add(si32a, i, 0), name); |
| 135 assertEquals(undefined, Atomics.sub(si32a, i, 0), name); |
| 136 assertEquals(undefined, Atomics.and(si32a, i, 0), name); |
| 137 assertEquals(undefined, Atomics.or(si32a, i, 0), name); |
| 138 assertEquals(undefined, Atomics.xor(si32a, i, 0), name); |
| 139 assertEquals(undefined, Atomics.exchange(si32a, i, 0), name); |
| 140 }); |
126 })(); | 141 })(); |
127 | 142 |
128 (function TestGoodIndex() { | 143 (function TestGoodIndex() { |
129 var sab = new SharedArrayBuffer(64); | 144 var sab = new SharedArrayBuffer(64); |
130 var si32a = new Int32Array(sab); | 145 var si32a = new Int32Array(sab); |
131 | 146 |
132 var valueOf = {valueOf: function(){ return 3;}}; | 147 var valueOf = {valueOf: function(){ return 3;}}; |
133 var toString = {toString: function(){ return '3';}}; | 148 var toString = {toString: function(){ return '3';}}; |
134 | 149 |
135 [3, 3.5, '3', '3.5', valueOf, toString].forEach(function(i) { | 150 [3, 3.5, '3', '3.5', valueOf, toString].forEach(function(i) { |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 // Exchange | 450 // Exchange |
436 sta[0] = val = 0x12; | 451 sta[0] = val = 0x12; |
437 operand = 0x22 + offset; | 452 operand = 0x22 + offset; |
438 valWrapped = t.toRange(operand); | 453 valWrapped = t.toRange(operand); |
439 assertEquals(val, Atomics.exchange(sta, 0, operand), name); | 454 assertEquals(val, Atomics.exchange(sta, 0, operand), name); |
440 assertEquals(valWrapped, sta[0], name); | 455 assertEquals(valWrapped, sta[0], name); |
441 } | 456 } |
442 | 457 |
443 }); | 458 }); |
444 })(); | 459 })(); |
OLD | NEW |