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

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

Issue 1676613002: [Atomics] Fix atomic access index validation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: merge master Created 4 years, 9 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-exchange.js ('k') | test/mjsunit/asm/atomics-or.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 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 function Module(stdlib, foreign, heap, offset) { 7 function Module(stdlib, foreign, heap, offset) {
8 "use asm"; 8 "use asm";
9 var MEM8 = new stdlib.Int8Array(heap, offset); 9 var MEM8 = new stdlib.Int8Array(heap, offset);
10 var MEM16 = new stdlib.Int16Array(heap, offset); 10 var MEM16 = new stdlib.Int16Array(heap, offset);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 }; 55 };
56 } 56 }
57 57
58 function clearArray() { 58 function clearArray() {
59 var ui8 = new Uint8Array(sab); 59 var ui8 = new Uint8Array(sab);
60 for (var i = 0; i < sab.byteLength; ++i) { 60 for (var i = 0; i < sab.byteLength; ++i) {
61 ui8[i] = 0; 61 ui8[i] = 0;
62 } 62 }
63 } 63 }
64 64
65 function testElementType(taConstr, f, oobValue, offset) { 65 function testElementType(taConstr, f, offset) {
66 clearArray(); 66 clearArray();
67 67
68 var ta = new taConstr(sab, offset); 68 var ta = new taConstr(sab, offset);
69 var name = Object.prototype.toString.call(ta); 69 var name = Object.prototype.toString.call(ta);
70 ta[0] = 10; 70 ta[0] = 10;
71 assertEquals(10, f(0), name); 71 assertEquals(10, f(0), name);
72 assertEquals(0, f(1), name); 72 assertEquals(0, f(1), name);
73 // out of bounds 73 // out of bounds
74 assertEquals(oobValue, f(-1), name); 74 assertThrows(function() { f(-1); });
75 assertEquals(oobValue, f(ta.length), name); 75 assertThrows(function() { f(ta.length); });
76 } 76 }
77 77
78 function testElement(m, offset) { 78 function testElement(m, offset) {
79 testElementType(Int8Array, m.loadi8, 0, offset); 79 testElementType(Int8Array, m.loadi8, offset);
80 testElementType(Int16Array, m.loadi16, 0, offset); 80 testElementType(Int16Array, m.loadi16, offset);
81 testElementType(Int32Array, m.loadi32, 0, offset); 81 testElementType(Int32Array, m.loadi32, offset);
82 testElementType(Uint8Array, m.loadu8, 0, offset); 82 testElementType(Uint8Array, m.loadu8, offset);
83 testElementType(Uint16Array, m.loadu16, 0, offset); 83 testElementType(Uint16Array, m.loadu16, offset);
84 testElementType(Uint32Array, m.loadu32, 0, offset); 84 testElementType(Uint32Array, m.loadu32, offset);
85 } 85 }
86 86
87 var offset = 0; 87 var offset = 0;
88 var sab = new SharedArrayBuffer(16); 88 var sab = new SharedArrayBuffer(16);
89 var m1 = Module(this, {}, sab, offset); 89 var m1 = Module(this, {}, sab, offset);
90 testElement(m1, offset); 90 testElement(m1, offset);
91 91
92 offset = 32; 92 offset = 32;
93 sab = new SharedArrayBuffer(64); 93 sab = new SharedArrayBuffer(64);
94 var m2 = Module(this, {}, sab, offset); 94 var m2 = Module(this, {}, sab, offset);
95 testElement(m2, offset); 95 testElement(m2, offset);
OLDNEW
« no previous file with comments | « test/mjsunit/asm/atomics-exchange.js ('k') | test/mjsunit/asm/atomics-or.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698