| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.cps_ir.mutable_ssa; | 5 library dart2js.cps_ir.mutable_ssa; |
| 6 | 6 |
| 7 import 'cps_ir_nodes.dart'; | 7 import 'cps_ir_nodes.dart'; |
| 8 import 'optimizers.dart'; | 8 import 'optimizers.dart'; |
| 9 | 9 |
| 10 /// Determines which mutable variables should be rewritten to phi assignments | 10 /// Determines which mutable variables should be rewritten to phi assignments |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 mergeHints(variable, setter.value.definition); | 161 mergeHints(variable, setter.value.definition); |
| 162 setter.value.unlink(); | 162 setter.value.unlink(); |
| 163 node.remove(); | 163 node.remove(); |
| 164 } | 164 } |
| 165 } else if (node is LetPrim && node.primitive is GetMutable) { | 165 } else if (node is LetPrim && node.primitive is GetMutable) { |
| 166 GetMutable getter = node.primitive; | 166 GetMutable getter = node.primitive; |
| 167 MutableVariable variable = getter.variable.definition; | 167 MutableVariable variable = getter.variable.definition; |
| 168 if (shouldRewrite(variable)) { | 168 if (shouldRewrite(variable)) { |
| 169 // Replace with the reaching definition from the environment. | 169 // Replace with the reaching definition from the environment. |
| 170 Primitive value = environment[variable]; | 170 Primitive value = environment[variable]; |
| 171 value.substituteFor(getter); | 171 getter.replaceUsesWith(value); |
| 172 mergeHints(variable, value); | 172 mergeHints(variable, value); |
| 173 node.remove(); | 173 node.remove(); |
| 174 } | 174 } |
| 175 } else if (node is LetCont) { | 175 } else if (node is LetCont) { |
| 176 // Create phi parameters for each join continuation bound here, and put | 176 // Create phi parameters for each join continuation bound here, and put |
| 177 // them on the stack for later processing. | 177 // them on the stack for later processing. |
| 178 // Note that non-join continuations are handled at the use-site. | 178 // Note that non-join continuations are handled at the use-site. |
| 179 for (Continuation cont in node.continuations) { | 179 for (Continuation cont in node.continuations) { |
| 180 if (!isJoinContinuation(cont)) continue; | 180 if (!isJoinContinuation(cont)) continue; |
| 181 // Create a phi parameter for every mutable variable in scope. | 181 // Create a phi parameter for every mutable variable in scope. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 class VariableItem extends StackItem {} | 242 class VariableItem extends StackItem {} |
| 243 | 243 |
| 244 /// Represents a yet unprocessed continuation together with the | 244 /// Represents a yet unprocessed continuation together with the |
| 245 /// environment in which to process it. | 245 /// environment in which to process it. |
| 246 class ContinuationItem extends StackItem { | 246 class ContinuationItem extends StackItem { |
| 247 final Continuation continuation; | 247 final Continuation continuation; |
| 248 final Map<MutableVariable, Primitive> environment; | 248 final Map<MutableVariable, Primitive> environment; |
| 249 | 249 |
| 250 ContinuationItem(this.continuation, this.environment); | 250 ContinuationItem(this.continuation, this.environment); |
| 251 } | 251 } |
| OLD | NEW |