OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Test correct handling reusable boxes. | 4 // Test correct handling reusable boxes. |
5 // VMOptions=--optimization_counter_threshold=100 --no-background_compilation | 5 // VMOptions=--optimization_counter_threshold=100 --no-background_compilation |
6 | 6 |
7 library reusable_boxes_test; | 7 library reusable_boxes_test; |
8 | 8 |
9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 25 matching lines...) Expand all Loading... |
36 Expect.equals(20.0, r); | 36 Expect.equals(20.0, r); |
37 // Trigger a deopt of test. | 37 // Trigger a deopt of test. |
38 f.testParam(new Float32x4(1.0, 2.0, 3.0, 4.0), new Float32x4.zero()); | 38 f.testParam(new Float32x4(1.0, 2.0, 3.0, 4.0), new Float32x4.zero()); |
39 r = 0.0; | 39 r = 0.0; |
40 for (var i = 0; i < 20; i++) { | 40 for (var i = 0; i < 20; i++) { |
41 r += f.test(); | 41 r += f.test(); |
42 } | 42 } |
43 Expect.equals(20.0, r); | 43 Expect.equals(20.0, r); |
44 } | 44 } |
45 | 45 |
46 | |
47 class F { | 46 class F { |
48 var a = new Float32x4.zero(); | 47 var a = new Float32x4.zero(); |
49 var b = new Float32x4(1.0, 2.0, 3.0, 4.0); | 48 var b = new Float32x4(1.0, 2.0, 3.0, 4.0); |
50 var c = new Float32x4.zero(); | 49 var c = new Float32x4.zero(); |
51 test() { | 50 test() { |
52 a = new Float32x4.zero(); | 51 a = new Float32x4.zero(); |
53 b = new Float32x4(1.0, 2.0, 3.0, 4.0); | 52 b = new Float32x4(1.0, 2.0, 3.0, 4.0); |
54 c = a + b; | 53 c = a + b; |
55 return c; | 54 return c; |
56 } | 55 } |
57 | 56 |
58 testParam(x, y) { | 57 testParam(x, y) { |
59 x = x * x; | 58 x = x * x; |
60 y = y * y; | 59 y = y * y; |
61 c = x + y; | 60 c = x + y; |
62 } | 61 } |
63 | |
64 } | 62 } |
65 | 63 |
66 testF() { | 64 testF() { |
67 var f = new F(); | 65 var f = new F(); |
68 var r = new Float32x4.zero(); | 66 var r = new Float32x4.zero(); |
69 for (var i = 0; i < 20; i++) { | 67 for (var i = 0; i < 20; i++) { |
70 r += f.test(); | 68 r += f.test(); |
71 } | 69 } |
72 Expect.equals(20.0, r.x); | 70 Expect.equals(20.0, r.x); |
73 Expect.equals(40.0, r.y); | 71 Expect.equals(40.0, r.y); |
74 Expect.equals(60.0, r.z); | 72 Expect.equals(60.0, r.z); |
75 Expect.equals(80.0, r.w); | 73 Expect.equals(80.0, r.w); |
76 // Trigger a deopt of test. | 74 // Trigger a deopt of test. |
77 f.testParam(1.0, 2.0); | 75 f.testParam(1.0, 2.0); |
78 r = new Float32x4.zero(); | 76 r = new Float32x4.zero(); |
79 for (var i = 0; i < 20; i++) { | 77 for (var i = 0; i < 20; i++) { |
80 r += f.test(); | 78 r += f.test(); |
81 } | 79 } |
82 Expect.equals(20.0, r.x); | 80 Expect.equals(20.0, r.x); |
83 Expect.equals(40.0, r.y); | 81 Expect.equals(40.0, r.y); |
84 Expect.equals(60.0, r.z); | 82 Expect.equals(60.0, r.z); |
85 Expect.equals(80.0, r.w); | 83 Expect.equals(80.0, r.w); |
86 } | 84 } |
87 | 85 |
88 | |
89 main() { | 86 main() { |
90 testD(); | 87 testD(); |
91 testF(); | 88 testF(); |
92 } | 89 } |
OLD | NEW |