| 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.redundant_join_elimination; | 5 library dart2js.cps_ir.redundant_join_elimination; |
| 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 /// Eliminates redundant join points. | 10 /// Eliminates redundant join points. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 // Create new parameters and update the environment. | 242 // Create new parameters and update the environment. |
| 243 for (int i = 0; i < cont.parameters.length; ++i) { | 243 for (int i = 0; i < cont.parameters.length; ++i) { |
| 244 Parameter param = cont.parameters[i]; | 244 Parameter param = cont.parameters[i]; |
| 245 shadowedKeys.add(param); | 245 shadowedKeys.add(param); |
| 246 shadowedValues.add(renaming.remove(param)); | 246 shadowedValues.add(renaming.remove(param)); |
| 247 // If the parameter appears to belong to another continuation, | 247 // If the parameter appears to belong to another continuation, |
| 248 // create a new parameter object for this continuation. | 248 // create a new parameter object for this continuation. |
| 249 if (param.parent != cont) { | 249 if (param.parent != cont) { |
| 250 Parameter newParam = new Parameter(param.hint); | 250 Parameter newParam = new Parameter(param.hint); |
| 251 newParam.type = param.type; |
| 251 renaming[param] = newParam; | 252 renaming[param] = newParam; |
| 252 cont.parameters[i] = newParam; | 253 cont.parameters[i] = newParam; |
| 253 newParam.parent = cont; | 254 newParam.parent = cont; |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 | 257 |
| 257 pushAction(() { | 258 pushAction(() { |
| 258 // Restore the original environment. | 259 // Restore the original environment. |
| 259 for (int i = 0; i < cont.parameters.length; ++i) { | 260 for (int i = 0; i < cont.parameters.length; ++i) { |
| 260 renaming.remove(cont.parameters[i]); | 261 renaming.remove(cont.parameters[i]); |
| 261 if (shadowedValues[i] != null) { | 262 if (shadowedValues[i] != null) { |
| 262 renaming[shadowedKeys[i]] = shadowedValues[i]; | 263 renaming[shadowedKeys[i]] = shadowedValues[i]; |
| 263 } | 264 } |
| 264 } | 265 } |
| 265 }); | 266 }); |
| 266 } | 267 } |
| 267 | 268 |
| 268 processReference(Reference ref) { | 269 processReference(Reference ref) { |
| 269 Parameter target = renaming[ref.definition]; | 270 Parameter target = renaming[ref.definition]; |
| 270 if (target != null) { | 271 if (target != null) { |
| 271 ref.changeTo(target); | 272 ref.changeTo(target); |
| 272 } | 273 } |
| 273 } | 274 } |
| 274 } | 275 } |
| OLD | NEW |