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

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: Created 5 years, 10 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e9c82e0d068b63c6e853cc941d5d0a5b2b7f0aa8 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);
@@ -168,11 +171,12 @@ class CopyPropagator extends RecursiveVisitor with PassMixin {
// 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) {
+ // 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.
+ if (node.definition is VariableUse && !node.isDeclaration &&
Kevin Millikin (Google) 2015/03/06 09:30:33 I think it's confusing to call this field Assign.d
asgerf 2015/03/06 10:01:37 It's been bothering me too. I'll rename it to .val
+ !node.variable.isCaptured && enclosingTrys == 0) {
VariableUse definition = node.definition;
- if (definition.variable.readCount == 1 &&
- node.variable.host == currentElement) {
+ if (definition.variable.readCount == 1) {
move[definition.variable] = node;
inverseMove[node.variable] = node;
}
@@ -217,7 +221,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 | « no previous file | pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698