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

Side by Side Diff: test/mjsunit/asm/int16array-outofbounds.js

Issue 2663243002: [asm] Fix lots of invalid asm.js tests (Closed)
Patch Set: Rebase Created 3 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
« no previous file with comments | « test/mjsunit/asm/int16array-negative-offset.js ('k') | test/mjsunit/asm/int32-div.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 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 function Module(stdlib, foreign, heap) { 5 function Module(stdlib, foreign, heap) {
6 "use asm"; 6 "use asm";
7 var MEM16 = new stdlib.Int16Array(heap); 7 var MEM16 = new stdlib.Int16Array(heap);
8 function load(i) { 8 function load(i) {
9 i = i|0; 9 i = i|0;
10 i = MEM16[i >> 1] | 0; 10 i = MEM16[i >> 1] | 0;
11 return i; 11 return i | 0;
12 } 12 }
13 function loadm1() { 13 function loadm1() {
14 return MEM16[-1] | 0; 14 var i = -1 << 1;
15 return MEM16[i >> 1] | 0;
16 return 0;
15 } 17 }
16 function store(i, v) { 18 function store(i, v) {
17 i = i|0; 19 i = i | 0;
18 v = v|0; 20 v = v | 0;
19 MEM16[i >> 1] = v; 21 MEM16[i >> 1] = v;
20 } 22 }
21 function storem1(v) { 23 function storem1(v) {
22 v = v|0; 24 v = v | 0;
23 MEM16[-1] = v; 25 var i = -1 << 1;
26 MEM16[i >> 1] = v;
24 } 27 }
25 return {load: load, loadm1: loadm1, store: store, storem1: storem1}; 28 return {load: load, loadm1: loadm1, store: store, storem1: storem1};
26 } 29 }
27 30
28 var m = Module(this, {}, new ArrayBuffer(2)); 31 var m = Module(this, {}, new ArrayBuffer(2));
29 32
30 m.store(-1000, 4); 33 m.store(-1000, 4);
31 assertEquals(0, m.load(-1000)); 34 assertEquals(0, m.load(-1000));
32 assertEquals(0, m.loadm1()); 35 assertEquals(0, m.loadm1());
33 m.storem1(1); 36 m.storem1(1);
34 assertEquals(0, m.loadm1()); 37 assertEquals(0, m.loadm1());
35 m.store(0, 32767); 38 m.store(0, 32767);
36 for (var i = 1; i < 64; ++i) { 39 for (var i = 1; i < 64; ++i) {
37 m.store(i * 2 * 32 * 1024, i); 40 m.store(i * 2 * 32 * 1024, i);
38 } 41 }
39 assertEquals(32767, m.load(0)); 42 assertEquals(32767, m.load(0));
40 for (var i = 1; i < 64; ++i) { 43 for (var i = 1; i < 64; ++i) {
41 assertEquals(0, m.load(i * 2 * 32 * 1024)); 44 assertEquals(0, m.load(i * 2 * 32 * 1024));
42 } 45 }
OLDNEW
« no previous file with comments | « test/mjsunit/asm/int16array-negative-offset.js ('k') | test/mjsunit/asm/int32-div.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698