| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
| 8 String get name; | 8 String get name; |
| 9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
| 10 } | 10 } |
| (...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 } | 1033 } |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 void moveLoopInvariantCodeFromBlock(HBasicBlock block, | 1036 void moveLoopInvariantCodeFromBlock(HBasicBlock block, |
| 1037 HBasicBlock loopHeader, | 1037 HBasicBlock loopHeader, |
| 1038 int changesFlags) { | 1038 int changesFlags) { |
| 1039 assert(block.parentLoopHeader == loopHeader || block == loopHeader); | 1039 assert(block.parentLoopHeader == loopHeader || block == loopHeader); |
| 1040 HBasicBlock preheader = loopHeader.predecessors[0]; | 1040 HBasicBlock preheader = loopHeader.predecessors[0]; |
| 1041 int dependsFlags = SideEffects.computeDependsOnFlags(changesFlags); | 1041 int dependsFlags = SideEffects.computeDependsOnFlags(changesFlags); |
| 1042 HInstruction instruction = block.first; | 1042 HInstruction instruction = block.first; |
| 1043 bool firstInstructionInLoop = block == loopHeader; | 1043 bool firstInstructionInLoop = block == loopHeader |
| 1044 // Compensate for lack of code motion. |
| 1045 || (blockChangesFlags[loopHeader.id] == 0 |
| 1046 && loopHeader.successors[0] == block); |
| 1044 while (instruction != null) { | 1047 while (instruction != null) { |
| 1045 HInstruction next = instruction.next; | 1048 HInstruction next = instruction.next; |
| 1046 if (instruction.useGvn() | 1049 if (instruction.useGvn() |
| 1047 && (!instruction.canThrow() || firstInstructionInLoop) | 1050 && (!instruction.canThrow() || firstInstructionInLoop) |
| 1048 && !instruction.sideEffects.dependsOn(dependsFlags)) { | 1051 && !instruction.sideEffects.dependsOn(dependsFlags)) { |
| 1049 bool loopInvariantInputs = true; | 1052 bool loopInvariantInputs = true; |
| 1050 List<HInstruction> inputs = instruction.inputs; | 1053 List<HInstruction> inputs = instruction.inputs; |
| 1051 for (int i = 0, length = inputs.length; i < length; i++) { | 1054 for (int i = 0, length = inputs.length; i < length; i++) { |
| 1052 if (isInputDefinedAfterDominator(inputs[i], preheader)) { | 1055 if (isInputDefinedAfterDominator(inputs[i], preheader)) { |
| 1053 loopInvariantInputs = false; | 1056 loopInvariantInputs = false; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 // that knows it is not of a specific Type. | 1342 // that knows it is not of a specific Type. |
| 1340 } | 1343 } |
| 1341 | 1344 |
| 1342 for (HIf ifUser in notIfUsers) { | 1345 for (HIf ifUser in notIfUsers) { |
| 1343 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); | 1346 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); |
| 1344 // TODO(ngeoffray): Also change uses for the then block on a HType | 1347 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1345 // that knows it is not of a specific Type. | 1348 // that knows it is not of a specific Type. |
| 1346 } | 1349 } |
| 1347 } | 1350 } |
| 1348 } | 1351 } |
| OLD | NEW |