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

Side by Side Diff: test/mjsunit/harmony/atomics.js

Issue 1617503003: [Atomics] code stubs for atomic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove unnecessary CSA additions Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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-sharedarraybuffer 5 // Flags: --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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 clearArray(array.buffer); 203 clearArray(array.buffer);
204 var name = Object.prototype.toString.call(array); 204 var name = Object.prototype.toString.call(array);
205 for (var i = 0; i < array.length; ++i) { 205 for (var i = 0; i < array.length; ++i) {
206 array[i] = 0; 206 array[i] = 0;
207 assertEquals(0, Atomics.load(array, i), name); 207 assertEquals(0, Atomics.load(array, i), name);
208 array[i] = 50; 208 array[i] = 50;
209 assertEquals(50, Atomics.load(array, i), name); 209 assertEquals(50, Atomics.load(array, i), name);
210 } 210 }
211 }) 211 })
212 }); 212 });
213
214 // Test Smi range
215 (function () {
216 var sab = new SharedArrayBuffer(4);
217 var i32 = new Int32Array(sab);
218 var u32 = new Uint32Array(sab);
219
220 function testLoad(signedValue, unsignedValue) {
221 u32[0] = unsignedValue;
222 assertEquals(unsignedValue, Atomics.load(u32, 0));
223 assertEquals(signedValue, Atomics.load(i32, 0));
224 }
225
226 testLoad(0x3fffffff, 0x3fffffff); // 2**30-1 (always smi)
227 testLoad(0x40000000, 0x40000000); // 2**30 (smi if signed and 32-bits)
228 testLoad(0x80000000, -0x80000000); // 2**31 (smi if signed and 32-bits)
229 testLoad(0xffffffff, -1); // 2**31 (smi if signed)
230 });
213 })(); 231 })();
214 232
215 (function TestStore() { 233 (function TestStore() {
216 IntegerTypedArrayConstructors.forEach(function(t) { 234 IntegerTypedArrayConstructors.forEach(function(t) {
217 var sab = new SharedArrayBuffer(10 * t.constr.BYTES_PER_ELEMENT); 235 var sab = new SharedArrayBuffer(10 * t.constr.BYTES_PER_ELEMENT);
218 var sta = new t.constr(sab); 236 var sta = new t.constr(sab);
219 var sta2 = new t.constr(sab, 5 * t.constr.BYTES_PER_ELEMENT); 237 var sta2 = new t.constr(sab, 5 * t.constr.BYTES_PER_ELEMENT);
220 238
221 [sta, sta2].forEach(function(array) { 239 [sta, sta2].forEach(function(array) {
222 clearArray(array.buffer); 240 clearArray(array.buffer);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 // Exchange 538 // Exchange
521 sta[0] = val = 0x12; 539 sta[0] = val = 0x12;
522 operand = 0x22 + offset; 540 operand = 0x22 + offset;
523 valWrapped = t.toRange(operand); 541 valWrapped = t.toRange(operand);
524 assertEquals(val, Atomics.exchange(sta, 0, operand), name); 542 assertEquals(val, Atomics.exchange(sta, 0, operand), name);
525 assertEquals(valWrapped, sta[0], name); 543 assertEquals(valWrapped, sta[0], name);
526 } 544 }
527 545
528 }); 546 });
529 })(); 547 })();
OLDNEW
« src/compiler/code-stub-assembler.cc ('K') | « test/mjsunit/asm/atomics-load.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698