| 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 21 matching lines...) Expand all Loading... |
| 32 void optimize(CodegenWorkItem work, HGraph graph) { | 32 void optimize(CodegenWorkItem work, HGraph graph) { |
| 33 ConstantSystem constantSystem = compiler.backend.constantSystem; | 33 ConstantSystem constantSystem = compiler.backend.constantSystem; |
| 34 JavaScriptItemCompilationContext context = work.compilationContext; | 34 JavaScriptItemCompilationContext context = work.compilationContext; |
| 35 measure(() { | 35 measure(() { |
| 36 SsaDeadCodeEliminator dce; | 36 SsaDeadCodeEliminator dce; |
| 37 List<OptimizationPhase> phases = <OptimizationPhase>[ | 37 List<OptimizationPhase> phases = <OptimizationPhase>[ |
| 38 // Run trivial instruction simplification first to optimize | 38 // Run trivial instruction simplification first to optimize |
| 39 // some patterns useful for type conversion. | 39 // some patterns useful for type conversion. |
| 40 new SsaInstructionSimplifier(constantSystem, backend, work), | 40 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 41 new SsaTypeConversionInserter(compiler), | 41 new SsaTypeConversionInserter(compiler), |
| 42 new SsaRedundantPhiEliminator(), |
| 43 new SsaDeadPhiEliminator(), |
| 42 new SsaTypePropagator(compiler), | 44 new SsaTypePropagator(compiler), |
| 43 // After type propagation, more instructions can be | 45 // After type propagation, more instructions can be |
| 44 // simplified. | 46 // simplified. |
| 45 new SsaInstructionSimplifier(constantSystem, backend, work), | 47 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 46 new SsaCheckInserter(backend, work, context.boundsChecked), | 48 new SsaCheckInserter(backend, work, context.boundsChecked), |
| 47 new SsaRedundantPhiEliminator(), | |
| 48 new SsaDeadPhiEliminator(), | |
| 49 new SsaInstructionSimplifier(constantSystem, backend, work), | 49 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 50 new SsaCheckInserter(backend, work, context.boundsChecked), | 50 new SsaCheckInserter(backend, work, context.boundsChecked), |
| 51 new SsaTypePropagator(compiler), | 51 new SsaTypePropagator(compiler), |
| 52 // Run a dead code eliminator before LICM because dead | 52 // Run a dead code eliminator before LICM because dead |
| 53 // interceptors are often in the way of LICM'able instructions. | 53 // interceptors are often in the way of LICM'able instructions. |
| 54 new SsaDeadCodeEliminator(compiler), | 54 new SsaDeadCodeEliminator(compiler), |
| 55 new SsaGlobalValueNumberer(compiler), | 55 new SsaGlobalValueNumberer(compiler), |
| 56 // After GVN, some instructions might need their type to be |
| 57 // updated because they now have different inputs. |
| 58 new SsaTypePropagator(compiler), |
| 56 new SsaCodeMotion(), | 59 new SsaCodeMotion(), |
| 57 new SsaValueRangeAnalyzer(compiler, constantSystem, work), | 60 new SsaValueRangeAnalyzer(compiler, constantSystem, work), |
| 58 // Previous optimizations may have generated new | 61 // Previous optimizations may have generated new |
| 59 // opportunities for instruction simplification. | 62 // opportunities for instruction simplification. |
| 60 new SsaInstructionSimplifier(constantSystem, backend, work), | 63 new SsaInstructionSimplifier(constantSystem, backend, work), |
| 61 new SsaCheckInserter(backend, work, context.boundsChecked), | 64 new SsaCheckInserter(backend, work, context.boundsChecked), |
| 62 new SsaSimplifyInterceptors(compiler, constantSystem, work), | 65 new SsaSimplifyInterceptors(compiler, constantSystem, work), |
| 63 dce = new SsaDeadCodeEliminator(compiler)]; | 66 dce = new SsaDeadCodeEliminator(compiler)]; |
| 64 runPhases(graph, phases); | 67 runPhases(graph, phases); |
| 65 if (!dce.eliminatedSideEffects) return; | 68 if (!dce.eliminatedSideEffects) return; |
| (...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 // that knows it is not of a specific Type. | 1517 // that knows it is not of a specific Type. |
| 1515 } | 1518 } |
| 1516 | 1519 |
| 1517 for (HIf ifUser in notIfUsers) { | 1520 for (HIf ifUser in notIfUsers) { |
| 1518 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); | 1521 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); |
| 1519 // TODO(ngeoffray): Also change uses for the then block on a HType | 1522 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1520 // that knows it is not of a specific Type. | 1523 // that knows it is not of a specific Type. |
| 1521 } | 1524 } |
| 1522 } | 1525 } |
| 1523 } | 1526 } |
| OLD | NEW |