| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 i32a[0] = 1; | 88 i32a[0] = 1; |
| 89 assertEquals("not-equal", Atomics.wait(i32a, 0, 0)); | 89 assertEquals("not-equal", Atomics.wait(i32a, 0, 0)); |
| 90 })(); | 90 })(); |
| 91 | 91 |
| 92 (function TestWaitNegativeTimeout() { | 92 (function TestWaitNegativeTimeout() { |
| 93 var i32a = new Int32Array(new SharedArrayBuffer(16)); | 93 var i32a = new Int32Array(new SharedArrayBuffer(16)); |
| 94 assertEquals("timed-out", Atomics.wait(i32a, 0, 0, -1)); | 94 assertEquals("timed-out", Atomics.wait(i32a, 0, 0, -1)); |
| 95 assertEquals("timed-out", Atomics.wait(i32a, 0, 0, -Infinity)); | 95 assertEquals("timed-out", Atomics.wait(i32a, 0, 0, -Infinity)); |
| 96 })(); | 96 })(); |
| 97 | 97 |
| 98 (function TestWaitNotAllowed() { |
| 99 %SetAllowAtomicsWait(false); |
| 100 var i32a = new Int32Array(new SharedArrayBuffer(16)); |
| 101 assertThrows(function() { |
| 102 Atomics.wait(i32a, 0, 0, -1); |
| 103 }); |
| 104 %SetAllowAtomicsWait(true); |
| 105 })(); |
| 106 |
| 98 //// WORKER ONLY TESTS | 107 //// WORKER ONLY TESTS |
| 99 | 108 |
| 100 if (this.Worker) { | 109 if (this.Worker) { |
| 101 | 110 |
| 102 var TestWaitWithTimeout = function(timeout) { | 111 var TestWaitWithTimeout = function(timeout) { |
| 103 var sab = new SharedArrayBuffer(16); | 112 var sab = new SharedArrayBuffer(16); |
| 104 var i32a = new Int32Array(sab); | 113 var i32a = new Int32Array(sab); |
| 105 | 114 |
| 106 var workerScript = | 115 var workerScript = |
| 107 `onmessage = function(msg) { | 116 `onmessage = function(msg) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // Finally wake the last waiter. | 221 // Finally wake the last waiter. |
| 213 assertEquals(1, Atomics.wake(i32a, 4, 1)); | 222 assertEquals(1, Atomics.wake(i32a, 4, 1)); |
| 214 assertEquals("ok", workers[waitingId].getMessage()); | 223 assertEquals("ok", workers[waitingId].getMessage()); |
| 215 workers[waitingId].terminate(); | 224 workers[waitingId].terminate(); |
| 216 | 225 |
| 217 assertEquals(0, %AtomicsNumWaitersForTesting(i32a, 4)); | 226 assertEquals(0, %AtomicsNumWaitersForTesting(i32a, 4)); |
| 218 | 227 |
| 219 })(); | 228 })(); |
| 220 | 229 |
| 221 } | 230 } |
| OLD | NEW |