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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 807573003: Fix some bugs that blocked optimizations in the new IRs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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) 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 library tree_ir_builder; 5 library tree_ir_builder;
6 6
7 import '../dart2jslib.dart' as dart2js; 7 import '../dart2jslib.dart' as dart2js;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 191
192 192
193 List<Expression> translateArguments(List<cps_ir.Reference> args) { 193 List<Expression> translateArguments(List<cps_ir.Reference> args) {
194 return new List<Expression>.generate(args.length, 194 return new List<Expression>.generate(args.length,
195 (int index) => getVariableReference(args[index]), 195 (int index) => getVariableReference(args[index]),
196 growable: false); 196 growable: false);
197 } 197 }
198 198
199 List<Variable> translatePhiArguments(List<cps_ir.Reference> args) { 199 List<Variable> translatePhiArguments(List<cps_ir.Reference> args) {
200 return new List<Variable>.generate(args.length, 200 return new List<Variable>.generate(args.length,
201 (int index) => getVariableReference(args[index])); 201 (int index) => getVariable(args[index].definition));
asgerf 2015/01/15 12:08:00 getVariableReference() increases readCount. getVar
sigurdm 2015/01/15 12:21:03 Maybe put this explanation in a comment in the cod
asgerf 2015/01/15 13:05:37 Done.
202 } 202 }
203 203
204 Statement buildContinuationAssignment( 204 Statement buildContinuationAssignment(
205 cps_ir.Parameter parameter, 205 cps_ir.Parameter parameter,
206 Expression argument, 206 Expression argument,
207 Statement buildRest()) { 207 Statement buildRest()) {
208 Variable variable = getVariable(parameter); 208 Variable variable = getVariable(parameter);
209 Statement assignment; 209 Statement assignment;
210 if (variable == null) { 210 if (variable == null) {
211 assignment = new ExpressionStatement(argument, null); 211 assignment = new ExpressionStatement(argument, null);
(...skipping 28 matching lines...) Expand all
240 } 240 }
241 List<int> list = rightHand[arg]; 241 List<int> list = rightHand[arg];
242 if (list == null) { 242 if (list == null) {
243 rightHand[arg] = list = <int>[]; 243 rightHand[arg] = list = <int>[];
244 } 244 }
245 list.add(i); 245 list.add(i);
246 } 246 }
247 247
248 Statement first, current; 248 Statement first, current;
249 void addAssignment(Variable dst, Variable src) { 249 void addAssignment(Variable dst, Variable src) {
250 ++src.readCount;
251 // `dst.writeCount` will be updated by the Assign constructor.
250 if (first == null) { 252 if (first == null) {
251 first = current = new Assign(dst, src, null); 253 first = current = new Assign(dst, src, null);
252 } else { 254 } else {
253 current = current.next = new Assign(dst, src, null); 255 current = current.next = new Assign(dst, src, null);
254 } 256 }
255 } 257 }
256 258
257 List<Variable> assignmentSrc = new List<Variable>(parameters.length); 259 List<Variable> assignmentSrc = new List<Variable>(parameters.length);
258 List<bool> done = new List<bool>(parameters.length); 260 List<bool> done = new List<bool>(parameters.length);
259 void visitAssignment(int i) { 261 void visitAssignment(int i) {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // visited. 546 // visited.
545 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); 547 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.');
546 return null; 548 return null;
547 } 549 }
548 550
549 Expression visitIsTrue(cps_ir.IsTrue node) { 551 Expression visitIsTrue(cps_ir.IsTrue node) {
550 return getVariableReference(node.value); 552 return getVariableReference(node.value);
551 } 553 }
552 } 554 }
553 555
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698