Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 // Run trivial instruction simplification first to optimize | 39 // Run trivial instruction simplification first to optimize |
| 40 // some patterns useful for type conversion. | 40 // some patterns useful for type conversion. |
| 41 new SsaInstructionSimplifier(constantSystem, backend, work), | 41 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 42 new SsaTypeConversionInserter(compiler), | 42 new SsaTypeConversionInserter(compiler), |
| 43 new SsaRedundantPhiEliminator(), | 43 new SsaRedundantPhiEliminator(), |
| 44 new SsaDeadPhiEliminator(), | 44 new SsaDeadPhiEliminator(), |
| 45 new SsaTypePropagator(compiler), | 45 new SsaTypePropagator(compiler), |
| 46 // After type propagation, more instructions can be | 46 // After type propagation, more instructions can be |
| 47 // simplified. | 47 // simplified. |
| 48 new SsaInstructionSimplifier(constantSystem, backend, work), | 48 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 49 new SsaCheckInserter(backend, work, context.boundsChecked), | 49 new SsaCheckInserter(compiler, backend, work, context.boundsChecked), |
| 50 new SsaInstructionSimplifier(constantSystem, backend, work), | 50 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 51 new SsaCheckInserter(backend, work, context.boundsChecked), | 51 new SsaCheckInserter(compiler, backend, work, context.boundsChecked), |
| 52 new SsaTypePropagator(compiler), | 52 new SsaTypePropagator(compiler), |
| 53 // Run a dead code eliminator before LICM because dead | 53 // Run a dead code eliminator before LICM because dead |
| 54 // interceptors are often in the way of LICM'able instructions. | 54 // interceptors are often in the way of LICM'able instructions. |
| 55 new SsaDeadCodeEliminator(compiler), | 55 new SsaDeadCodeEliminator(compiler), |
| 56 new SsaGlobalValueNumberer(compiler), | 56 new SsaGlobalValueNumberer(compiler), |
| 57 // After GVN, some instructions might need their type to be | 57 // After GVN, some instructions might need their type to be |
| 58 // updated because they now have different inputs. | 58 // updated because they now have different inputs. |
| 59 new SsaTypePropagator(compiler), | 59 new SsaTypePropagator(compiler), |
| 60 new SsaCodeMotion(), | 60 new SsaCodeMotion(), |
| 61 new SsaLoadElimination(compiler), | 61 new SsaLoadElimination(compiler), |
| 62 new SsaDeadPhiEliminator(), | 62 new SsaDeadPhiEliminator(), |
| 63 new SsaTypePropagator(compiler), | 63 new SsaTypePropagator(compiler), |
| 64 new SsaValueRangeAnalyzer(compiler, constantSystem, work), | 64 new SsaValueRangeAnalyzer(compiler, constantSystem, work), |
| 65 // Previous optimizations may have generated new | 65 // Previous optimizations may have generated new |
| 66 // opportunities for instruction simplification. | 66 // opportunities for instruction simplification. |
| 67 new SsaInstructionSimplifier(constantSystem, backend, work), | 67 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 68 new SsaCheckInserter(backend, work, context.boundsChecked), | 68 new SsaCheckInserter(compiler, backend, work, context.boundsChecked), |
| 69 new SsaSimplifyInterceptors(compiler, constantSystem, work), | 69 new SsaSimplifyInterceptors(compiler, constantSystem, work), |
| 70 dce = new SsaDeadCodeEliminator(compiler), | 70 dce = new SsaDeadCodeEliminator(compiler), |
| 71 new SsaTypePropagator(compiler)]; | 71 new SsaTypePropagator(compiler)]; |
| 72 runPhases(graph, phases); | 72 runPhases(graph, phases); |
| 73 if (dce.eliminatedSideEffects) { | 73 if (dce.eliminatedSideEffects) { |
| 74 phases = <OptimizationPhase>[ | 74 phases = <OptimizationPhase>[ |
| 75 new SsaGlobalValueNumberer(compiler), | 75 new SsaGlobalValueNumberer(compiler), |
| 76 new SsaCodeMotion(), | 76 new SsaCodeMotion(), |
| 77 new SsaValueRangeAnalyzer(compiler, constantSystem, work), | 77 new SsaValueRangeAnalyzer(compiler, constantSystem, work), |
| 78 new SsaInstructionSimplifier(constantSystem, backend, work), | 78 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 79 new SsaCheckInserter(backend, work, context.boundsChecked), | 79 new SsaCheckInserter( |
| 80 compiler, backend, work, context.boundsChecked), | |
| 80 new SsaSimplifyInterceptors(compiler, constantSystem, work), | 81 new SsaSimplifyInterceptors(compiler, constantSystem, work), |
| 81 new SsaDeadCodeEliminator(compiler)]; | 82 new SsaDeadCodeEliminator(compiler)]; |
| 82 } else { | 83 } else { |
| 83 phases = <OptimizationPhase>[ | 84 phases = <OptimizationPhase>[ |
| 84 // Run the simplifier to remove unneeded type checks inserted | 85 // Run the simplifier to remove unneeded type checks inserted |
| 85 // by type propagation. | 86 // by type propagation. |
| 86 new SsaInstructionSimplifier(constantSystem, backend, work)]; | 87 new SsaInstructionSimplifier(constantSystem, backend, work)]; |
| 87 } | 88 } |
| 88 runPhases(graph, phases); | 89 runPhases(graph, phases); |
| 89 }); | 90 }); |
| (...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 } | 880 } |
| 880 | 881 |
| 881 HInstruction visitOneShotInterceptor(HOneShotInterceptor node) { | 882 HInstruction visitOneShotInterceptor(HOneShotInterceptor node) { |
| 882 return handleInterceptedCall(node); | 883 return handleInterceptedCall(node); |
| 883 } | 884 } |
| 884 } | 885 } |
| 885 | 886 |
| 886 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { | 887 class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase { |
| 887 final Set<HInstruction> boundsChecked; | 888 final Set<HInstruction> boundsChecked; |
| 888 final CodegenWorkItem work; | 889 final CodegenWorkItem work; |
| 890 final Compiler compiler; | |
| 889 final JavaScriptBackend backend; | 891 final JavaScriptBackend backend; |
| 890 final String name = "SsaCheckInserter"; | 892 final String name = "SsaCheckInserter"; |
| 891 HGraph graph; | 893 HGraph graph; |
| 892 | 894 |
| 893 SsaCheckInserter(this.backend, | 895 SsaCheckInserter(this.compiler, |
| 896 this.backend, | |
| 894 this.work, | 897 this.work, |
| 895 this.boundsChecked); | 898 this.boundsChecked); |
| 896 | 899 |
| 897 void visitGraph(HGraph graph) { | 900 void visitGraph(HGraph graph) { |
| 898 this.graph = graph; | 901 this.graph = graph; |
| 902 | |
| 903 // In --trust-primitives mode we don't add bounds checks. This is better | |
| 904 // than trying to remove them later as the limit expression would become | |
| 905 // dead and require DCE. | |
| 906 if (compiler.trustPrimitives) return; | |
|
floitsch
2014/11/11 10:02:04
Ok for this CL, but in the future (i.e. the CPS IR
sra1
2014/11/12 02:27:37
I passed the bool.
| |
| 907 | |
| 899 visitDominatorTree(graph); | 908 visitDominatorTree(graph); |
| 900 } | 909 } |
| 901 | 910 |
| 902 void visitBasicBlock(HBasicBlock block) { | 911 void visitBasicBlock(HBasicBlock block) { |
| 903 HInstruction instruction = block.first; | 912 HInstruction instruction = block.first; |
| 904 while (instruction != null) { | 913 while (instruction != null) { |
| 905 HInstruction next = instruction.next; | 914 HInstruction next = instruction.next; |
| 906 instruction = instruction.accept(this); | 915 instruction = instruction.accept(this); |
| 907 instruction = next; | 916 instruction = next; |
| 908 } | 917 } |
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2142 | 2151 |
| 2143 keyedValues.forEach((receiver, values) { | 2152 keyedValues.forEach((receiver, values) { |
| 2144 result.keyedValues[receiver] = | 2153 result.keyedValues[receiver] = |
| 2145 new Map<HInstruction, HInstruction>.from(values); | 2154 new Map<HInstruction, HInstruction>.from(values); |
| 2146 }); | 2155 }); |
| 2147 | 2156 |
| 2148 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2157 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 2149 return result; | 2158 return result; |
| 2150 } | 2159 } |
| 2151 } | 2160 } |
| OLD | NEW |