| 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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 HInstruction receiver = instruction.getDartReceiver(compiler); | 1005 HInstruction receiver = instruction.getDartReceiver(compiler); |
| 1006 HInstruction current = instruction.next; | 1006 HInstruction current = instruction.next; |
| 1007 do { | 1007 do { |
| 1008 if ((current.getDartReceiver(compiler) == receiver) | 1008 if ((current.getDartReceiver(compiler) == receiver) |
| 1009 && current.canThrow()) { | 1009 && current.canThrow()) { |
| 1010 return true; | 1010 return true; |
| 1011 } | 1011 } |
| 1012 if (current.canThrow() || current.sideEffects.hasSideEffects()) { | 1012 if (current.canThrow() || current.sideEffects.hasSideEffects()) { |
| 1013 return false; | 1013 return false; |
| 1014 } | 1014 } |
| 1015 if (current.next == null && current is HGoto) { | 1015 HInstruction next = current.next; |
| 1016 // We do not merge blocks in our SSA graph, so if this block | 1016 if (next == null) { |
| 1017 // just jumps to a single predecessor, visit this predecessor. | 1017 // We do not merge blocks in our SSA graph, so if this block just jumps |
| 1018 assert(current.block.successors.length == 1); | 1018 // to a single successor, visit the successor, avoiding back-edges. |
| 1019 current = current.block.successors[0].first; | 1019 HBasicBlock successor; |
| 1020 } else { | 1020 if (current is HGoto) { |
| 1021 current = current.next; | 1021 successor = current.block.successors.single; |
| 1022 } else if (current is HIf) { |
| 1023 // We also leave HIf nodes in place when one branch is dead. |
| 1024 HInstruction condition = current.inputs.first; |
| 1025 if (condition is HConstant) { |
| 1026 bool isTrue = condition.constant.isTrue; |
| 1027 successor = isTrue ? current.thenBlock : current.elseBlock; |
| 1028 assert(!analyzer.isDeadBlock(successor)); |
| 1029 } |
| 1030 } |
| 1031 if (successor != null && successor.id > current.block.id) { |
| 1032 next = successor.first; |
| 1033 } |
| 1022 } | 1034 } |
| 1035 current = next; |
| 1023 } while (current != null); | 1036 } while (current != null); |
| 1024 return false; | 1037 return false; |
| 1025 } | 1038 } |
| 1026 | 1039 |
| 1027 bool isTrivialDeadStoreReceiver(HInstruction instruction) { | 1040 bool isTrivialDeadStoreReceiver(HInstruction instruction) { |
| 1028 // For an allocation, if all the loads are dead (awaiting removal after | 1041 // For an allocation, if all the loads are dead (awaiting removal after |
| 1029 // SsaLoadElimination) and the only other uses are stores, then the | 1042 // SsaLoadElimination) and the only other uses are stores, then the |
| 1030 // allocation does not escape which makes all the stores dead too. | 1043 // allocation does not escape which makes all the stores dead too. |
| 1031 bool isDeadUse(HInstruction use) { | 1044 bool isDeadUse(HInstruction use) { |
| 1032 if (use is HFieldSet) { | 1045 if (use is HFieldSet) { |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2189 | 2202 |
| 2190 keyedValues.forEach((receiver, values) { | 2203 keyedValues.forEach((receiver, values) { |
| 2191 result.keyedValues[receiver] = | 2204 result.keyedValues[receiver] = |
| 2192 new Map<HInstruction, HInstruction>.from(values); | 2205 new Map<HInstruction, HInstruction>.from(values); |
| 2193 }); | 2206 }); |
| 2194 | 2207 |
| 2195 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2208 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 2196 return result; | 2209 return result; |
| 2197 } | 2210 } |
| 2198 } | 2211 } |
| OLD | NEW |