OLD | NEW |
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 float arrays. | 5 // Dart test program for testing native float arrays. |
6 | 6 |
| 7 // VMOptions=--optimization_counter_threshold=10 |
| 8 |
7 // Library tag to be able to run in html test framework. | 9 // Library tag to be able to run in html test framework. |
8 library FloatArrayTest; | 10 library FloatArrayTest; |
9 | 11 |
10 import "package:expect/expect.dart"; | 12 import "package:expect/expect.dart"; |
11 import 'dart:typed_data'; | 13 import 'dart:typed_data'; |
12 | 14 |
13 void testCreateFloat32Array() { | 15 void testCreateFloat32Array() { |
14 Float32List floatArray; | 16 Float32List floatArray; |
15 | 17 |
16 floatArray = new Float32List(0); | 18 floatArray = new Float32List(0); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 181 } |
180 | 182 |
181 storeIt32(Float32List a, int index, value) { | 183 storeIt32(Float32List a, int index, value) { |
182 a[index] = value; | 184 a[index] = value; |
183 } | 185 } |
184 | 186 |
185 storeIt64(Float64List a, int index, value) { | 187 storeIt64(Float64List a, int index, value) { |
186 a[index] = value; | 188 a[index] = value; |
187 } | 189 } |
188 | 190 |
| 191 testPolymorphicLoad(var list) { |
| 192 return list[0]; |
| 193 } |
| 194 |
189 main() { | 195 main() { |
190 var a32 = new Float32List(5); | 196 var a32 = new Float32List(5); |
191 for (int i = 0; i < 2000; i++) { | 197 for (int i = 0; i < 20; i++) { |
192 testCreateFloat32Array(); | 198 testCreateFloat32Array(); |
193 testSetRange32(); | 199 testSetRange32(); |
194 testIndexOutOfRange32(); | 200 testIndexOutOfRange32(); |
195 testIndexOf32(); | 201 testIndexOf32(); |
196 storeIt32(a32, 1, 2.0); | 202 storeIt32(a32, 1, 2.0); |
| 203 testPolymorphicLoad(a32); |
197 } | 204 } |
198 var a64 = new Float64List(5); | 205 var a64 = new Float64List(5); |
199 for (int i = 0; i < 2000; i++) { | 206 for (int i = 0; i < 20; i++) { |
200 testCreateFloat64Array(); | 207 testCreateFloat64Array(); |
201 testSetRange64(); | 208 testSetRange64(); |
202 testIndexOutOfRange64(); | 209 testIndexOutOfRange64(); |
203 testIndexOf64(); | 210 testIndexOf64(); |
204 storeIt64(a64, 1, 2.0); | 211 storeIt64(a64, 1, 2.0); |
| 212 testPolymorphicLoad(a64); |
205 } | 213 } |
| 214 var f32x4 = new Float32x4List(5); |
| 215 for (int i = 0; i < 20; i++) { |
| 216 testPolymorphicLoad(f32x4); |
| 217 } |
| 218 |
206 // These two take a long time in checked mode. | 219 // These two take a long time in checked mode. |
207 testBadValues32(); | 220 testBadValues32(); |
208 testBadValues64(); | 221 testBadValues64(); |
209 // Check optimized (inlined) version of []= | 222 // Check optimized (inlined) version of []= |
210 Expect.throws(() { | 223 Expect.throws(() { |
211 storeIt32(a32, 1, 2); | 224 storeIt32(a32, 1, 2); |
212 }); | 225 }); |
213 Expect.throws(() { | 226 Expect.throws(() { |
214 storeIt64(a64, 1, 2); | 227 storeIt64(a64, 1, 2); |
215 }); | 228 }); |
216 } | 229 } |
OLD | NEW |