| 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 // Flags: --allow-natives-syntax --harmony-sharedarraybuffer | 5 // Flags: --allow-natives-syntax --harmony-sharedarraybuffer |
| 6 | 6 |
| 7 (function TestFailsWithNonSharedArray() { | 7 (function TestFailsWithNonSharedArray() { |
| 8 var ab = new ArrayBuffer(16); | 8 var ab = new ArrayBuffer(16); |
| 9 | 9 |
| 10 var i8a = new Int8Array(ab); | 10 var i8a = new Int8Array(ab); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 assertThrows(function() { Atomics.futexWakeOrRequeue(ta, 0, 1, 0, 0); }); | 44 assertThrows(function() { Atomics.futexWakeOrRequeue(ta, 0, 1, 0, 0); }); |
| 45 }); | 45 }); |
| 46 })(); | 46 })(); |
| 47 | 47 |
| 48 (function TestInvalidIndex() { | 48 (function TestInvalidIndex() { |
| 49 var sab = new SharedArrayBuffer(16); | 49 var sab = new SharedArrayBuffer(16); |
| 50 var i32a = new Int32Array(sab); | 50 var i32a = new Int32Array(sab); |
| 51 | 51 |
| 52 // Valid indexes are 0-3. | 52 // Valid indexes are 0-3. |
| 53 [-1, 4, 100].forEach(function(invalidIndex) { | 53 [-1, 4, 100].forEach(function(invalidIndex) { |
| 54 assertEquals(undefined, Atomics.futexWait(i32a, invalidIndex, 0)); | 54 assertThrows(function() { |
| 55 assertEquals(undefined, Atomics.futexWake(i32a, invalidIndex, 0)); | 55 Atomics.futexWait(i32a, invalidIndex, 0); |
| 56 }, RangeError); |
| 57 assertThrows(function() { |
| 58 Atomics.futexWake(i32a, invalidIndex, 0); |
| 59 }, RangeError); |
| 56 var validIndex = 0; | 60 var validIndex = 0; |
| 57 assertEquals(undefined, Atomics.futexWakeOrRequeue(i32a, invalidIndex, 0, 0, | 61 assertThrows(function() { |
| 58 validIndex)); | 62 Atomics.futexWakeOrRequeue(i32a, invalidIndex, 0, 0, validIndex); |
| 59 assertEquals(undefined, Atomics.futexWakeOrRequeue(i32a, validIndex, 0, 0, | 63 }, RangeError); |
| 60 invalidIndex)); | 64 assertThrows(function() { |
| 65 Atomics.futexWakeOrRequeue(i32a, validIndex, 0, 0, invalidIndex); |
| 66 }, RangeError); |
| 61 }); | 67 }); |
| 62 | 68 |
| 63 i32a = new Int32Array(sab, 8); | 69 i32a = new Int32Array(sab, 8); |
| 64 [-1, 2, 100].forEach(function(invalidIndex) { | 70 [-1, 2, 100].forEach(function(invalidIndex) { |
| 65 assertEquals(undefined, Atomics.futexWait(i32a, invalidIndex, 0)); | 71 assertThrows(function() { |
| 66 assertEquals(undefined, Atomics.futexWake(i32a, invalidIndex, 0)); | 72 Atomics.futexWait(i32a, invalidIndex, 0); |
| 73 }, RangeError); |
| 74 assertThrows(function() { |
| 75 Atomics.futexWake(i32a, invalidIndex, 0); |
| 76 }, RangeError); |
| 67 var validIndex = 0; | 77 var validIndex = 0; |
| 68 assertEquals(undefined, Atomics.futexWakeOrRequeue(i32a, invalidIndex, 0, 0, | 78 assertThrows(function() { |
| 69 validIndex)); | 79 Atomics.futexWakeOrRequeue(i32a, invalidIndex, 0, 0, validIndex); |
| 70 assertEquals(undefined, Atomics.futexWakeOrRequeue(i32a, validIndex, 0, 0, | 80 }, RangeError); |
| 71 invalidIndex)); | 81 assertThrows(function() { |
| 82 Atomics.futexWakeOrRequeue(i32a, validIndex, 0, 0, invalidIndex); |
| 83 }, RangeError); |
| 72 }); | 84 }); |
| 73 })(); | 85 })(); |
| 74 | 86 |
| 75 (function TestWaitTimeout() { | 87 (function TestWaitTimeout() { |
| 76 var i32a = new Int32Array(new SharedArrayBuffer(16)); | 88 var i32a = new Int32Array(new SharedArrayBuffer(16)); |
| 77 var waitMs = 100; | 89 var waitMs = 100; |
| 78 var startTime = new Date(); | 90 var startTime = new Date(); |
| 79 assertEquals(Atomics.TIMEDOUT, Atomics.futexWait(i32a, 0, 0, waitMs)); | 91 assertEquals(Atomics.TIMEDOUT, Atomics.futexWait(i32a, 0, 0, waitMs)); |
| 80 var endTime = new Date(); | 92 var endTime = new Date(); |
| 81 assertTrue(endTime - startTime >= waitMs); | 93 assertTrue(endTime - startTime >= waitMs); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 assertEquals(2, Atomics.futexWake(i32a2, index2, 2)); | 343 assertEquals(2, Atomics.futexWake(i32a2, index2, 2)); |
| 332 | 344 |
| 333 for (id = 0; id < 4; ++id) { | 345 for (id = 0; id < 4; ++id) { |
| 334 assertEquals(Atomics.OK, workers[id].getMessage()); | 346 assertEquals(Atomics.OK, workers[id].getMessage()); |
| 335 workers[id].terminate(); | 347 workers[id].terminate(); |
| 336 } | 348 } |
| 337 | 349 |
| 338 })(); | 350 })(); |
| 339 | 351 |
| 340 } | 352 } |
| OLD | NEW |