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

Side by Side Diff: tests/language/allocation_sinking_vm_test.dart

Issue 16799003: Support type arguments for allocation sinking in certain conditions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: rebased Created 7 years, 5 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/flow_graph_optimizer.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) 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 allocation sinking optimization. 4 // Test allocation sinking optimization.
5 5
6 import 'package:expect/expect.dart'; 6 import 'package:expect/expect.dart';
7 7
8 class Point { 8 class Point {
9 var x, y; 9 var x, y;
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 PointP(this.x, this.y); 81 PointP(this.x, this.y);
82 82
83 operator * (other) { 83 operator * (other) {
84 return x * other.x + y * other.y; 84 return x * other.x + y * other.y;
85 } 85 }
86 } 86 }
87 87
88 foo2() => new PointP<int>(1, 3) * new PointP<num>(5, 6); 88 foo2() => new PointP<int>(1, 3) * new PointP<num>(5, 6);
89 89
90 class A<T> {
91 var x, y;
92 }
93
94 foo3(x) {
95 // Test materialization of type arguments.
96 var a = new A<int>();
97 a.x = x;
98 a.y = x;
99 if (x is int) return a.x + a.y;
100 Expect.isFalse(a is A<double>);
101 Expect.isTrue(a is A<int>);
102 Expect.isTrue(a is A);
103 return a.x - a.y;
104 }
105
90 main() { 106 main() {
91 var c = new C(new Point(0.1, 0.2)); 107 var c = new C(new Point(0.1, 0.2));
92 108
93 // Compute initial values. 109 // Compute initial values.
94 final x0 = test1(c, 11.11, 22.22); 110 final x0 = test1(c, 11.11, 22.22);
95 final y0 = testForwardingThroughEffects(c, 11.11, 22.22); 111 final y0 = testForwardingThroughEffects(c, 11.11, 22.22);
96 final z0 = testIdentity(c.p); 112 final z0 = testIdentity(c.p);
97 113
98 // Force optimization. 114 // Force optimization.
99 for (var i = 0; i < 10000; i++) { 115 for (var i = 0; i < 10000; i++) {
100 test1(c, i.toDouble(), i.toDouble()); 116 test1(c, i.toDouble(), i.toDouble());
101 testForwardingThroughEffects(c, i.toDouble(), i.toDouble()); 117 testForwardingThroughEffects(c, i.toDouble(), i.toDouble());
102 testIdentity(c.p); 118 testIdentity(c.p);
103 foo2(); 119 foo2();
120 Expect.equals(10, foo3(5));
104 } 121 }
122 Expect.equals(0.0, foo3(0.5));
105 123
106 // Test returned value after optimization. 124 // Test returned value after optimization.
107 final x1 = test1(c, 11.11, 22.22); 125 final x1 = test1(c, 11.11, 22.22);
108 final y1 = testForwardingThroughEffects(c, 11.11, 22.22); 126 final y1 = testForwardingThroughEffects(c, 11.11, 22.22);
109 127
110 // Test returned value after deopt. 128 // Test returned value after deopt.
111 final x2 = test1(new D(c.p), 11.11, 22.22); 129 final x2 = test1(new D(c.p), 11.11, 22.22);
112 final y2 = testForwardingThroughEffects(new D(c.p), 11.11, 22.22); 130 final y2 = testForwardingThroughEffects(new D(c.p), 11.11, 22.22);
113 131
114 Expect.equals(6465, (x0 * 100).floor()); 132 Expect.equals(6465, (x0 * 100).floor());
115 Expect.equals(6465, (x1 * 100).floor()); 133 Expect.equals(6465, (x1 * 100).floor());
116 Expect.equals(6465, (x2 * 100).floor()); 134 Expect.equals(6465, (x2 * 100).floor());
117 Expect.equals(x0, x1); 135 Expect.equals(x0, x1);
118 Expect.equals(x0, x2); 136 Expect.equals(x0, x2);
119 137
120 Expect.equals(6008, (y0 * 100).floor()); 138 Expect.equals(6008, (y0 * 100).floor());
121 Expect.equals(6008, (y1 * 100).floor()); 139 Expect.equals(6008, (y1 * 100).floor());
122 Expect.equals(6008, (y2 * 100).floor()); 140 Expect.equals(6008, (y2 * 100).floor());
123 Expect.equals(y0, y1); 141 Expect.equals(y0, y1);
124 Expect.equals(y0, y2); 142 Expect.equals(y0, y2);
125 143
126 // Test that identity of materialized objects is preserved correctly and 144 // Test that identity of materialized objects is preserved correctly and
127 // no copies are materialized. 145 // no copies are materialized.
128 final z1 = testIdentity(c.p); 146 final z1 = testIdentity(c.p);
129 final z2 = testIdentity(new F(c.p)); 147 final z2 = testIdentity(new F(c.p));
130 Expect.equals(z0, z1); 148 Expect.equals(z0, z1);
131 Expect.equals(z0, z2); 149 Expect.equals(z0, z2);
132 } 150 }
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698