Chromium Code Reviews| 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 tree_ir.optimization.variable_merger; | 5 library tree_ir.optimization.variable_merger; |
| 6 | 6 |
| 7 import 'optimization.dart' show Pass; | 7 import 'optimization.dart' show Pass; |
| 8 import '../tree_ir_nodes.dart'; | 8 import '../tree_ir_nodes.dart'; |
| 9 import '../../elements/elements.dart' show Local, ParameterElement; | 9 import '../../elements/elements.dart' show Local, ParameterElement; |
| 10 | 10 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 List<Variable> variables = interference.keys.toList(); | 414 List<Variable> variables = interference.keys.toList(); |
| 415 variables.sort((x, y) => interference[y].length - interference[x].length); | 415 variables.sort((x, y) => interference[y].length - interference[x].length); |
| 416 | 416 |
| 417 Map<String, List<Variable>> registers = <String, List<Variable>>{}; | 417 Map<String, List<Variable>> registers = <String, List<Variable>>{}; |
| 418 Map<Variable, Variable> subst = <Variable, Variable>{}; | 418 Map<Variable, Variable> subst = <Variable, Variable>{}; |
| 419 | 419 |
| 420 // Parameters are special in that they must have a ParameterElement and | 420 // Parameters are special in that they must have a ParameterElement and |
| 421 // cannot be merged with each other. Ensure that they are not substituted. | 421 // cannot be merged with each other. Ensure that they are not substituted. |
| 422 // Other variables can still be substituted by a parameter. | 422 // Other variables can still be substituted by a parameter. |
| 423 for (Variable parameter in parameters) { | 423 for (Variable parameter in parameters) { |
| 424 if (parameter.isCaptured) continue; | |
|
asgerf
2015/04/15 10:43:39
This is a bug that snuck in with the last change.
| |
| 424 subst[parameter] = parameter; | 425 subst[parameter] = parameter; |
| 425 registers[group(parameter)] = <Variable>[parameter]; | 426 registers[group(parameter)] = <Variable>[parameter]; |
| 426 } | 427 } |
| 427 | 428 |
| 428 for (Variable v1 in variables) { | 429 for (Variable v1 in variables) { |
| 429 // Parameters have already been assigned a substitute; skip those. | 430 // Parameters have already been assigned a substitute; skip those. |
| 430 if (subst.containsKey(v1)) continue; | 431 if (subst.containsKey(v1)) continue; |
| 431 | 432 |
| 432 List<Variable> register = registers[group(v1)]; | 433 List<Variable> register = registers[group(v1)]; |
| 433 | 434 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 // VariableDeclaration is only used for captured variables, which are never | 541 // VariableDeclaration is only used for captured variables, which are never |
| 541 // merged, so this is not strictly necessary. But it's nicer if this class | 542 // merged, so this is not strictly necessary. But it's nicer if this class |
| 542 // works for arbitrary substitution maps. | 543 // works for arbitrary substitution maps. |
| 543 node.variable = replaceWrite(node.variable); | 544 node.variable = replaceWrite(node.variable); |
| 544 node.value = visitExpression(node.value); | 545 node.value = visitExpression(node.value); |
| 545 node.next = visitStatement(node.next); | 546 node.next = visitStatement(node.next); |
| 546 return node; | 547 return node; |
| 547 } | 548 } |
| 548 | 549 |
| 549 } | 550 } |
| OLD | NEW |