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

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

Issue 18055004: Fix a bug in allocation sinking and load elimination. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: improved unit test 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
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 var a = new A<int>(); 96 var a = new A<int>();
97 a.x = x; 97 a.x = x;
98 a.y = x; 98 a.y = x;
99 if (x is int) return a.x + a.y; 99 if (x is int) return a.x + a.y;
100 Expect.isFalse(a is A<double>); 100 Expect.isFalse(a is A<double>);
101 Expect.isTrue(a is A<int>); 101 Expect.isTrue(a is A<int>);
102 Expect.isTrue(a is A); 102 Expect.isTrue(a is A);
103 return a.x - a.y; 103 return a.x - a.y;
104 } 104 }
105 105
106 class WithFinal {
107 final _x;
108 WithFinal(this._x);
109 }
110
111 testInitialValueForFinalField(x) {
112 new WithFinal(x);
113 }
114
115 testFinalField() {
116 for (var i = 0; i < 10000; i++) {
117 testInitialValueForFinalField(1);
118 }
119 }
120
121 class V {
122 var x = 0;
123 }
124
125 test_vm_field() {
126 var obj;
127 inner() => obj.x = 42;
128 var a = new V();
129 obj = a;
130 var t1 = a.x;
131 var t2 = inner();
132 return a.x + t1 + t2;
133 }
134
135 testVMField() {
136 Expect.equals(84, test_vm_field());
137 for (var i=0; i<15000; i++) test_vm_field();
138 Expect.equals(84, test_vm_field());
139 }
140
106 main() { 141 main() {
107 var c = new C(new Point(0.1, 0.2)); 142 var c = new C(new Point(0.1, 0.2));
108 143
109 // Compute initial values. 144 // Compute initial values.
110 final x0 = test1(c, 11.11, 22.22); 145 final x0 = test1(c, 11.11, 22.22);
111 final y0 = testForwardingThroughEffects(c, 11.11, 22.22); 146 final y0 = testForwardingThroughEffects(c, 11.11, 22.22);
112 final z0 = testIdentity(c.p); 147 final z0 = testIdentity(c.p);
113 148
114 // Force optimization. 149 // Force optimization.
115 for (var i = 0; i < 10000; i++) { 150 for (var i = 0; i < 10000; i++) {
(...skipping 24 matching lines...) Expand all
140 Expect.equals(6008, (y2 * 100).floor()); 175 Expect.equals(6008, (y2 * 100).floor());
141 Expect.equals(y0, y1); 176 Expect.equals(y0, y1);
142 Expect.equals(y0, y2); 177 Expect.equals(y0, y2);
143 178
144 // Test that identity of materialized objects is preserved correctly and 179 // Test that identity of materialized objects is preserved correctly and
145 // no copies are materialized. 180 // no copies are materialized.
146 final z1 = testIdentity(c.p); 181 final z1 = testIdentity(c.p);
147 final z2 = testIdentity(new F(c.p)); 182 final z2 = testIdentity(new F(c.p));
148 Expect.equals(z0, z1); 183 Expect.equals(z0, z1);
149 Expect.equals(z0, z2); 184 Expect.equals(z0, z2);
185
186 testFinalField();
187 testVMField();
150 } 188 }
OLDNEW
« runtime/vm/flow_graph_optimizer.cc ('K') | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698