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

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

Issue 1124813005: WIP Atomics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix AtomicsLoad type in typer.cc Created 5 years, 7 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 | « src/runtime/runtime-utils.h ('k') | test/mjsunit/harmony/atomics.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-shared-typed-arrays
6
7 function Module(stdlib, foreign, heap) {
8 "use asm";
9 var MEM8 = new stdlib.SharedInt8Array(heap);
10 var MEM16 = new stdlib.SharedInt16Array(heap);
11 var MEM32 = new stdlib.SharedInt32Array(heap);
12 var MEMF32 = new stdlib.SharedFloat32Array(heap);
13 var MEMF64 = new stdlib.SharedFloat64Array(heap);
14 var load = stdlib.Atomics.load;
15
16 function loadi8(i) {
17 i = i | 0;
18 return load(MEM8, i)|0;
19 }
20
21 function loadi16(i) {
22 i = i | 0;
23 return load(MEM16, i)|0;
24 }
25
26 function loadi32(i) {
27 i = i | 0;
28 return load(MEM32, i)|0;
29 }
30
31 function loadf32(i) {
32 i = i | 0;
33 return +load(MEMF32, i);
34 }
35
36 function loadf64(i) {
37 i = i | 0;
38 return +load(MEMF64, i);
39 }
40
41 return {
42 loadi8: loadi8,
43 loadi16: loadi16,
44 loadi32: loadi32,
45 loadf32: loadf32,
46 loadf64: loadf64
47 };
48 }
49
50 var sab = new SharedArrayBuffer(16);
51 var m = Module(this, {}, sab);
52
53 function testElementType(taConstr, f, oobValue) {
54 var ta = new taConstr(sab);
55 var name = Object.prototype.toString.call(ta);
56 ta[0] = 10;
57 assertEquals(10, f(0), name);
58 assertEquals(0, f(1), name);
59 // out of bounds
60 assertEquals(oobValue, f(-1), name);
61 assertEquals(oobValue, f(ta.length), name);
62 }
63
64 testElementType(SharedInt8Array, m.loadi8, 0);
65 testElementType(SharedInt16Array, m.loadi16, 0);
66 testElementType(SharedInt32Array, m.loadi32, 0);
67 testElementType(SharedFloat32Array, m.loadf32, NaN);
68 testElementType(SharedFloat64Array, m.loadf64, NaN);
OLDNEW
« no previous file with comments | « src/runtime/runtime-utils.h ('k') | test/mjsunit/harmony/atomics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698