Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: test/mjsunit/harmony/atomics-value-check.js

Issue 2799863002: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor (Closed)
Patch Set: [Atomics] use TFJ builtins for atomic add, sub, and, or, and xor Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/atomics-value-check.js
diff --git a/test/mjsunit/harmony/atomics-value-check.js b/test/mjsunit/harmony/atomics-value-check.js
new file mode 100644
index 0000000000000000000000000000000000000000..b953863daf42784ef0418604e8bb11c69a839f38
--- /dev/null
+++ b/test/mjsunit/harmony/atomics-value-check.js
@@ -0,0 +1,44 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-sharedarraybuffer
+//
+
+var sab = new SharedArrayBuffer(4);
+var sta = new Int8Array(sab);
+sta[0] = 5;
+var workerScript =
+ `onmessage=function(msg) {
+ postMessage(0);
+ };`;
+var worker = new Worker(workerScript);
+
+var value_obj = {
+ valueOf: function() {worker.postMessage({sab:sab}, [sta.buffer]);
+ return 5}
+}
+var value = Object.create(value_obj);
+
+assertThrows(function() {Atomics.exchange(sta, 0, value)});
+assertThrows(function() {Atomics.compareExchange(sta, 0, 5, value)});
+assertThrows(function() {Atomics.compareExchange(sta, 0, value, 5)});
+assertThrows(function() {Atomics.add(sta, 0, value)});
+assertThrows(function() {Atomics.sub(sta, 0, value)});
+assertThrows(function() {Atomics.and(sta, 0, value)});
+assertThrows(function() {Atomics.or(sta, 0, value)});
+assertThrows(function() {Atomics.xor(sta, 0, value)});
+
+var index_obj = {
+ valueOf: function() {worker.postMessage({sab:sab}, [sta.buffer]);
+ return 0}
+}
+var index = Object.create(index_obj);
+
+assertThrows(function() {Atomics.exchange(sta, index, 1)});
+assertThrows(function() {Atomics.compareExchange(sta, index, 5, 2)});
+assertThrows(function() {Atomics.add(sta, index, 3)});
+assertThrows(function() {Atomics.sub(sta, index, 4)});
+assertThrows(function() {Atomics.and(sta, index, 5)});
+assertThrows(function() {Atomics.or(sta, index, 6)});
+assertThrows(function() {Atomics.xor(sta, index, 7)});
« src/builtins/builtins-sharedarraybuffer-gen.cc ('K') | « src/runtime/runtime-atomics.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698