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

Side by Side Diff: test/mjsunit/asm/atomics-or.js

Issue 1162503002: Implement Atomics API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add more symbols to anonymous namespace Created 5 years, 6 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
« no previous file with comments | « test/mjsunit/asm/atomics-load.js ('k') | test/mjsunit/asm/atomics-store.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --harmony-atomics --harmony-sharedarraybuffer
6
7 function Module(stdlib, foreign, heap) {
8 "use asm";
9 var MEM8 = new stdlib.Int8Array(heap);
10 var MEM16 = new stdlib.Int16Array(heap);
11 var MEM32 = new stdlib.Int32Array(heap);
12 var MEMU8 = new stdlib.Uint8Array(heap);
13 var MEMU16 = new stdlib.Uint16Array(heap);
14 var MEMU32 = new stdlib.Uint32Array(heap);
15 var or = stdlib.Atomics.or;
16 var fround = stdlib.Math.fround;
17
18 function ori8(i, x) {
19 i = i | 0;
20 x = x | 0;
21 return or(MEM8, i, x)|0;
22 }
23
24 function ori16(i, x) {
25 i = i | 0;
26 x = x | 0;
27 return or(MEM16, i, x)|0;
28 }
29
30 function ori32(i, x) {
31 i = i | 0;
32 x = x | 0;
33 return or(MEM32, i, x)|0;
34 }
35
36 function oru8(i, x) {
37 i = i | 0;
38 x = x >>> 0;
39 return or(MEMU8, i, x)>>>0;
40 }
41
42 function oru16(i, x) {
43 i = i | 0;
44 x = x >>> 0;
45 return or(MEMU16, i, x)>>>0;
46 }
47
48 function oru32(i, x) {
49 i = i | 0;
50 x = x >>> 0;
51 return or(MEMU32, i, x)>>>0;
52 }
53
54 return {
55 ori8: ori8,
56 ori16: ori16,
57 ori32: ori32,
58 oru8: oru8,
59 oru16: oru16,
60 oru32: oru32,
61 };
62 }
63
64 var sab = new SharedArrayBuffer(16);
65 var m = Module(this, {}, sab);
66
67 function clearArray() {
68 var ui8 = new Uint8Array(sab);
69 for (var i = 0; i < sab.byteLength; ++i) {
70 ui8[i] = 0;
71 }
72 }
73
74 function testElementType(taConstr, f) {
75 clearArray();
76
77 var ta = new taConstr(sab);
78 var name = Object.prototype.toString.call(ta);
79 assertEquals(0, f(0, 0xf), name);
80 assertEquals(0xf, ta[0]);
81 assertEquals(0xf, f(0, 0x11), name);
82 assertEquals(0x1f, ta[0]);
83 // out of bounds
84 assertEquals(0, f(-1, 0), name);
85 assertEquals(0, f(ta.length, 0), name);
86 }
87
88 testElementType(Int8Array, m.ori8);
89 testElementType(Int16Array, m.ori16);
90 testElementType(Int32Array, m.ori32);
91 testElementType(Uint8Array, m.oru8);
92 testElementType(Uint16Array, m.oru16);
93 testElementType(Uint32Array, m.oru32);
OLDNEW
« no previous file with comments | « test/mjsunit/asm/atomics-load.js ('k') | test/mjsunit/asm/atomics-store.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698