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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 | 1030 |
1031 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { | 1031 class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase { |
1032 final String name = "SsaDeadCodeEliminator"; | 1032 final String name = "SsaDeadCodeEliminator"; |
1033 | 1033 |
1034 final Compiler compiler; | 1034 final Compiler compiler; |
1035 final SsaOptimizerTask optimizer; | 1035 final SsaOptimizerTask optimizer; |
1036 SsaLiveBlockAnalyzer analyzer; | 1036 SsaLiveBlockAnalyzer analyzer; |
1037 Map<HInstruction, bool> trivialDeadStoreReceivers = | 1037 Map<HInstruction, bool> trivialDeadStoreReceivers = |
1038 new Maplet<HInstruction, bool>(); | 1038 new Maplet<HInstruction, bool>(); |
1039 bool eliminatedSideEffects = false; | 1039 bool eliminatedSideEffects = false; |
| 1040 |
1040 SsaDeadCodeEliminator(this.compiler, this.optimizer); | 1041 SsaDeadCodeEliminator(this.compiler, this.optimizer); |
1041 | 1042 |
1042 HInstruction zapInstructionCache; | 1043 HInstruction zapInstructionCache; |
1043 HInstruction get zapInstruction { | 1044 HInstruction get zapInstruction { |
1044 if (zapInstructionCache == null) { | 1045 if (zapInstructionCache == null) { |
1045 // A constant with no type does not pollute types at phi nodes. | 1046 // A constant with no type does not pollute types at phi nodes. |
1046 ConstantValue constant = | 1047 ConstantValue constant = |
1047 new DummyConstantValue(const TypeMask.nonNullEmpty()); | 1048 new SyntheticConstantValue( |
| 1049 SyntheticConstantKind.EMPTY_VALUE, |
| 1050 const TypeMask.nonNullEmpty()); |
1048 zapInstructionCache = analyzer.graph.addConstant(constant, compiler); | 1051 zapInstructionCache = analyzer.graph.addConstant(constant, compiler); |
1049 } | 1052 } |
1050 return zapInstructionCache; | 1053 return zapInstructionCache; |
1051 } | 1054 } |
1052 | 1055 |
1053 /// Returns true of [foreign] will throw an noSuchMethod error if | 1056 /// Returns true of [foreign] will throw an noSuchMethod error if |
1054 /// receiver is `null` before having any other side-effects. | 1057 /// receiver is `null` before having any other side-effects. |
1055 bool templateThrowsNSMonNull(HForeignCode foreign, HInstruction receiver) { | 1058 bool templateThrowsNSMonNull(HForeignCode foreign, HInstruction receiver) { |
1056 if (foreign.inputs.length < 1) return false; | 1059 if (foreign.inputs.length < 1) return false; |
1057 if (foreign.inputs.first != receiver) return false; | 1060 if (foreign.inputs.first != receiver) return false; |
(...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 | 2298 |
2296 keyedValues.forEach((receiver, values) { | 2299 keyedValues.forEach((receiver, values) { |
2297 result.keyedValues[receiver] = | 2300 result.keyedValues[receiver] = |
2298 new Map<HInstruction, HInstruction>.from(values); | 2301 new Map<HInstruction, HInstruction>.from(values); |
2299 }); | 2302 }); |
2300 | 2303 |
2301 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2304 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
2302 return result; | 2305 return result; |
2303 } | 2306 } |
2304 } | 2307 } |
OLD | NEW |