OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --harmony-sharedarraybuffer |
| 6 // |
| 7 |
| 8 var sab = new SharedArrayBuffer(4); |
| 9 var sta = new Int8Array(sab); |
| 10 sta[0] = 5; |
| 11 var workerScript = |
| 12 `onmessage=function(msg) { |
| 13 postMessage(0); |
| 14 };`; |
| 15 var worker = new Worker(workerScript); |
| 16 |
| 17 var value_obj = { |
| 18 valueOf: function() {worker.postMessage({sab:sab}, [sta.buffer]); |
| 19 return 5} |
| 20 } |
| 21 var value = Object.create(value_obj); |
| 22 |
| 23 assertThrows(function() {Atomics.exchange(sta, 0, value)}); |
| 24 assertThrows(function() {Atomics.compareExchange(sta, 0, 5, value)}); |
| 25 assertThrows(function() {Atomics.compareExchange(sta, 0, value, 5)}); |
| 26 assertThrows(function() {Atomics.add(sta, 0, value)}); |
| 27 assertThrows(function() {Atomics.sub(sta, 0, value)}); |
| 28 assertThrows(function() {Atomics.and(sta, 0, value)}); |
| 29 assertThrows(function() {Atomics.or(sta, 0, value)}); |
| 30 assertThrows(function() {Atomics.xor(sta, 0, value)}); |
| 31 |
| 32 var index_obj = { |
| 33 valueOf: function() {worker.postMessage({sab:sab}, [sta.buffer]); |
| 34 return 0} |
| 35 } |
| 36 var index = Object.create(index_obj); |
| 37 |
| 38 assertThrows(function() {Atomics.exchange(sta, index, 1)}); |
| 39 assertThrows(function() {Atomics.compareExchange(sta, index, 5, 2)}); |
| 40 assertThrows(function() {Atomics.add(sta, index, 3)}); |
| 41 assertThrows(function() {Atomics.sub(sta, index, 4)}); |
| 42 assertThrows(function() {Atomics.and(sta, index, 5)}); |
| 43 assertThrows(function() {Atomics.or(sta, index, 6)}); |
| 44 assertThrows(function() {Atomics.xor(sta, index, 7)}); |
OLD | NEW |