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

Side by Side Diff: tests/standalone/int_array_test.dart

Issue 11967012: Optimized loads/stores for scalar list: Uint8Clamped, Int8, Int16, Uint16. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Dart test program for testing native int arrays. 5 // Dart test program for testing native int arrays.
6 6
7 // Library tag to be able to run in html test framework. 7 // Library tag to be able to run in html test framework.
8 library IntArrayTest; 8 library IntArrayTest;
9 9
10 import 'dart:scalarlist'; 10 import 'dart:scalarlist';
11 11
12 void testInt16() {
13 Int16List intArray = new Int16List(4);
14 intArray[0] = 0;
15 intArray[1] = -1;
16 intArray[2] = -2;
17 intArray[3] = -3;
18 for (int i = 0; i < intArray.length; i++) {
19 intArray[i]++;
20 }
21 var x = intArray[0];
22 var y = intArray[1];
23 var z = intArray[2];
24 var w = intArray[3];
25 Expect.equals(1, x);
26 Expect.equals(0, y);
27 Expect.equals(-1, z);
28 Expect.equals(-2, w);
29 var t = y + 1;
30 intArray[0] = t;
31 Expect.equals(t, intArray[0]);
32 }
33
34 void testUint16() {
35 Uint16List intArray = new Uint16List(4);
36 intArray[0] = 0;
37 intArray[1] = 1;
38 intArray[2] = 2;
39 intArray[3] = 3;
40 for (int i = 0; i < intArray.length; i++) {
41 intArray[i]--;
42 }
43 var x = intArray[0];
44 var y = intArray[1];
45 var z = intArray[2];
46 var w = intArray[3];
47 Expect.equals(65535, x);
48 Expect.equals(0, y);
49 Expect.equals(1, z);
50 Expect.equals(2, w);
51 var t = y + 1;
52 intArray[0] = t;
53 Expect.equals(t, intArray[0]);
54 }
55
12 void testInt32ToSmi() { 56 void testInt32ToSmi() {
13 Int32List intArray; 57 Int32List intArray;
14 58
15 intArray = new Int32List(4); 59 intArray = new Int32List(4);
16 intArray[0] = 1073741823; // SmiMax 60 intArray[0] = 1073741823; // SmiMax
17 intArray[1] = -1073741824; // SmiMin 61 intArray[1] = -1073741824; // SmiMin
18 intArray[2] = 1073741824; // SmiMax+1 62 intArray[2] = 1073741824; // SmiMax+1
19 intArray[3] = -1073741825; // SmiMin-1 63 intArray[3] = -1073741825; // SmiMin-1
20 var x = intArray[0]; 64 var x = intArray[0];
21 var y = intArray[1]; 65 var y = intArray[1];
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 112
69 intArray = new Uint64List(4); 113 intArray = new Uint64List(4);
70 intArray[0] = 4611686018427387903; // SmiMax 114 intArray[0] = 4611686018427387903; // SmiMax
71 intArray[1] = -1; // 0xFFFFFFFFFFFFFFFF : 18446744073709551615 115 intArray[1] = -1; // 0xFFFFFFFFFFFFFFFF : 18446744073709551615
72 intArray[2] = 4611686018427387904; // SmiMax+1 116 intArray[2] = 4611686018427387904; // SmiMax+1
73 intArray[3] = 9223372036854775808; 117 intArray[3] = 9223372036854775808;
74 var x = intArray[0]; 118 var x = intArray[0];
75 var y = intArray[1]; 119 var y = intArray[1];
76 var z = intArray[2]; 120 var z = intArray[2];
77 var w = intArray[3]; 121 var w = intArray[3];
78 print(w);
79 Expect.equals(4611686018427387903, x); 122 Expect.equals(4611686018427387903, x);
80 Expect.equals(18446744073709551615, y); 123 Expect.equals(18446744073709551615, y);
81 Expect.equals(4611686018427387904, z); 124 Expect.equals(4611686018427387904, z);
82 Expect.equals(9223372036854775808, w); 125 Expect.equals(9223372036854775808, w);
83 } 126 }
84 127
85 128
86 main() { 129 main() {
87 testUint64ToSmi(); 130 testUint64ToSmi();
88 return;
89 for (int i = 0; i < 2000; i++) { 131 for (int i = 0; i < 2000; i++) {
132 testInt16();
133 testUint16();
90 testInt32ToSmi(); 134 testInt32ToSmi();
91 testUint32ToSmi(); 135 testUint32ToSmi();
92 testInt64ToSmi(); 136 testInt64ToSmi();
93 testUint64ToSmi(); 137 testUint64ToSmi();
94 } 138 }
95 } 139 }
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698