OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 Mint representations and type propagation issue. | 5 // Dart Mint representations and type propagation issue. |
6 // Testing Int32List and Uint32List loads. | 6 // Testing Int32List and Uint32List loads. |
7 // | 7 // |
8 // VMOptions=--optimization-counter-threshold=5 --no-use-osr --no-background-com
pilation | 8 // VMOptions=--optimization-counter-threshold=5 --no-use-osr --no-background-com
pilation |
9 | 9 |
10 import 'dart:typed_data'; | 10 import 'dart:typed_data'; |
11 import "package:expect/expect.dart"; | 11 import "package:expect/expect.dart"; |
12 | 12 |
13 main() { | 13 main() { |
14 var a = new Uint32List(100); | 14 var a = new Uint32List(100); |
15 a[2] = 3; | 15 a[2] = 3; |
16 var res = sumIt1(a, 2); | 16 var res = sumIt1(a, 2); |
17 Expect.equals(3 * 10, res); | 17 Expect.equals(3 * 10, res); |
18 res = sumIt1(a, 2); | 18 res = sumIt1(a, 2); |
19 Expect.equals(3 * 10, res); | 19 Expect.equals(3 * 10, res); |
20 a = new Int32List(100); | 20 var a1 = new Int32List(100); |
21 a[2] = 3; | 21 a1[2] = 3; |
22 res = sumIt2(a, 2); | 22 res = sumIt2(a1, 2); |
23 Expect.equals(3 * 10, res); | 23 Expect.equals(3 * 10, res); |
24 res = sumIt2(a, 2); | 24 res = sumIt2(a1, 2); |
25 Expect.equals(3 * 10, res); | 25 Expect.equals(3 * 10, res); |
26 } | 26 } |
27 | 27 |
28 sumIt1(Uint32List a, int n) { | 28 sumIt1(Uint32List a, int n) { |
29 var sum = 0; | 29 var sum = 0; |
30 for (int i = 0; i < 10; i++) { | 30 for (int i = 0; i < 10; i++) { |
31 sum += a[n]; | 31 sum += a[n]; |
32 } | 32 } |
33 return sum; | 33 return sum; |
34 } | 34 } |
35 | 35 |
36 sumIt2(Int32List a, int n) { | 36 sumIt2(Int32List a, int n) { |
37 var sum = 0; | 37 var sum = 0; |
38 for (int i = 0; i < 10; i++) { | 38 for (int i = 0; i < 10; i++) { |
39 sum += a[n]; | 39 sum += a[n]; |
40 } | 40 } |
41 return sum; | 41 return sum; |
42 } | 42 } |
OLD | NEW |