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

Unified Diff: pkg/compiler/lib/src/tree_ir/optimization/copy_propagator.dart

Issue 980853002: dart2dart: Bugfix in copy propagator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renamed Assign.definition -> value and break up long condition Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/tree_ir/optimization/copy_propagator.dart
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/copy_propagator.dart b/pkg/compiler/lib/src/tree_ir/optimization/copy_propagator.dart
index 2f3761db4262d7f41dd1c2e282065160fbc19ad1..ae1e96c0060ce44aafaa166fdc39ab964b857773 100644
--- a/pkg/compiler/lib/src/tree_ir/optimization/copy_propagator.dart
+++ b/pkg/compiler/lib/src/tree_ir/optimization/copy_propagator.dart
@@ -23,6 +23,9 @@ class CopyPropagator extends RecursiveVisitor with PassMixin {
ExecutableElement currentElement;
+ /// Number of try blocks enclosing the currently visited node.
+ int enclosingTrys = 0;
+
void rewriteExecutableDefinition(ExecutableDefinition root) {
currentElement = root.element;
root.body = visitStatement(root.body);
@@ -111,8 +114,8 @@ class CopyPropagator extends RecursiveVisitor with PassMixin {
void invalidateMovingAssignment(Variable w) {
Assign movingAssignment = inverseMove.remove(w);
if (movingAssignment != null) {
- VariableUse def = movingAssignment.definition;
- move.remove(def.variable);
+ VariableUse value = movingAssignment.value;
+ move.remove(value.variable);
}
}
@@ -144,7 +147,7 @@ class CopyPropagator extends RecursiveVisitor with PassMixin {
// Make w := w.
// We can't remove the statement from here because we don't have
// parent pointers. So just make it a no-op so it can be removed later.
- movingAssign.definition = new VariableUse(w);
+ movingAssign.value = new VariableUse(w);
// The intermediate variable 'v' should now be orphaned, so don't bother
// updating its read/write counters.
@@ -164,16 +167,19 @@ class CopyPropagator extends RecursiveVisitor with PassMixin {
// the moving assignment is no longer a candidate for copy propagation.
invalidateMovingAssignment(node.variable);
- visitExpression(node.definition);
+ visitExpression(node.value);
// If this is a moving assignment w := v, with this being the only use of v,
// try to propagate it backwards. Do not propagate assignments where w
- // is from an outer function scope.
- if (node.definition is VariableUse) {
- VariableUse definition = node.definition;
- if (definition.variable.readCount == 1 &&
- node.variable.host == currentElement) {
- move[definition.variable] = node;
+ // is captured or if where are inside a try block, because then we can't
+ // isolate the uses of w to a given basic block.
Kevin Millikin (Google) 2015/03/06 10:27:30 Could you just update this comment to explain here
asgerf 2015/03/06 10:49:20 Done.
+ if (node.value is VariableUse &&
+ !node.isDeclaration &&
+ !node.variable.isCaptured &&
+ enclosingTrys == 0) {
+ VariableUse value = node.value;
+ if (value.variable.readCount == 1) {
+ move[value.variable] = node;
inverseMove[node.variable] = node;
}
}
@@ -217,7 +223,9 @@ class CopyPropagator extends RecursiveVisitor with PassMixin {
}
Statement visitTry(Try node) {
+ enclosingTrys++;
node.tryBody = visitBasicBlock(node.tryBody);
+ enclosingTrys--;
node.catchBody = visitBasicBlock(node.catchBody);
return node;
}
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/codegen.dart ('k') | pkg/compiler/lib/src/tree_ir/optimization/logical_rewriter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698