Chromium Code Reviews| 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; |
| } |