| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 for (Continuation cont in node.continuations) { | 184 for (Continuation cont in node.continuations) { |
| 185 if (!isJoinContinuation(cont)) continue; | 185 if (!isJoinContinuation(cont)) continue; |
| 186 // Create a phi parameter for every mutable variable in scope. | 186 // Create a phi parameter for every mutable variable in scope. |
| 187 // At the same time, build the environment to use for processing | 187 // At the same time, build the environment to use for processing |
| 188 // the continuation (mapping mutables to phi parameters). | 188 // the continuation (mapping mutables to phi parameters). |
| 189 continuationPhiCount[cont] = mutableVariables.length; | 189 continuationPhiCount[cont] = mutableVariables.length; |
| 190 Map<MutableVariable, Primitive> environment = | 190 Map<MutableVariable, Primitive> environment = |
| 191 <MutableVariable, Primitive>{}; | 191 <MutableVariable, Primitive>{}; |
| 192 for (MutableVariable variable in mutableVariables) { | 192 for (MutableVariable variable in mutableVariables) { |
| 193 Parameter phi = new Parameter(variable.hint); | 193 Parameter phi = new Parameter(variable.hint); |
| 194 phi.type = variable.type; |
| 194 cont.parameters.add(phi); | 195 cont.parameters.add(phi); |
| 195 phi.parent = cont; | 196 phi.parent = cont; |
| 196 environment[variable] = phi; | 197 environment[variable] = phi; |
| 197 } | 198 } |
| 198 stack.add(new ContinuationItem(cont, environment)); | 199 stack.add(new ContinuationItem(cont, environment)); |
| 199 } | 200 } |
| 200 } else if (node is LetHandler) { | 201 } else if (node is LetHandler) { |
| 201 // Process the catch block later and continue into the try block. | 202 // Process the catch block later and continue into the try block. |
| 202 // We can use the same environment object for the try and catch blocks. | 203 // We can use the same environment object for the try and catch blocks. |
| 203 // The current environment bindings cannot change inside the try block | 204 // The current environment bindings cannot change inside the try block |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 class VariableItem extends StackItem {} | 247 class VariableItem extends StackItem {} |
| 247 | 248 |
| 248 /// Represents a yet unprocessed continuation together with the | 249 /// Represents a yet unprocessed continuation together with the |
| 249 /// environment in which to process it. | 250 /// environment in which to process it. |
| 250 class ContinuationItem extends StackItem { | 251 class ContinuationItem extends StackItem { |
| 251 final Continuation continuation; | 252 final Continuation continuation; |
| 252 final Map<MutableVariable, Primitive> environment; | 253 final Map<MutableVariable, Primitive> environment; |
| 253 | 254 |
| 254 ContinuationItem(this.continuation, this.environment); | 255 ContinuationItem(this.continuation, this.environment); |
| 255 } | 256 } |
| OLD | NEW |