| 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 } |
| 11 | 11 |
| 12 class SsaOptimizerTask extends CompilerTask { | 12 class SsaOptimizerTask extends CompilerTask { |
| 13 final JavaScriptBackend backend; | 13 final JavaScriptBackend backend; |
| 14 SsaOptimizerTask(JavaScriptBackend backend) | 14 SsaOptimizerTask(JavaScriptBackend backend) |
| 15 : this.backend = backend, | 15 : this.backend = backend, |
| 16 super(backend.compiler); | 16 super(backend.compiler); |
| 17 String get name => 'SSA optimizer'; | 17 String get name => 'SSA optimizer'; |
| 18 Compiler get compiler => backend.compiler; | 18 Compiler get compiler => backend.compiler; |
| 19 | 19 |
| 20 void runPhases(HGraph graph, List<OptimizationPhase> phases) { | 20 void runPhases(HGraph graph, List<OptimizationPhase> phases) { |
| 21 for (OptimizationPhase phase in phases) { | 21 for (OptimizationPhase phase in phases) { |
| 22 runPhase(graph, phase); | 22 runPhase(graph, phase); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 void runPhase(HGraph graph, OptimizationPhase phase) { | 26 void runPhase(HGraph graph, OptimizationPhase phase) { |
| 27 phase.visitGraph(graph); | 27 phase.visitGraph(graph); |
| 28 compiler.tracer.traceGraph(phase.name, graph); | 28 compiler.tracer.traceGraph(phase.name, graph); |
| 29 assert(graph.isValid()); |
| 29 } | 30 } |
| 30 | 31 |
| 31 void optimize(WorkItem work, HGraph graph, bool speculative) { | 32 void optimize(WorkItem work, HGraph graph, bool speculative) { |
| 32 ConstantSystem constantSystem = compiler.backend.constantSystem; | 33 ConstantSystem constantSystem = compiler.backend.constantSystem; |
| 33 JavaScriptItemCompilationContext context = work.compilationContext; | 34 JavaScriptItemCompilationContext context = work.compilationContext; |
| 34 HTypeMap types = context.types; | 35 HTypeMap types = context.types; |
| 35 measure(() { | 36 measure(() { |
| 36 List<OptimizationPhase> phases = <OptimizationPhase>[ | 37 List<OptimizationPhase> phases = <OptimizationPhase>[ |
| 37 // Run trivial constant folding first to optimize | 38 // Run trivial constant folding first to optimize |
| 38 // some patterns useful for type conversion. | 39 // some patterns useful for type conversion. |
| (...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 HInstruction receiver = interceptor.receiver; | 1478 HInstruction receiver = interceptor.receiver; |
| 1478 for (var user in receiver.usedBy) { | 1479 for (var user in receiver.usedBy) { |
| 1479 if (user is HInterceptor && interceptor.dominates(user)) { | 1480 if (user is HInterceptor && interceptor.dominates(user)) { |
| 1480 user.interceptedClasses = interceptor.interceptedClasses; | 1481 user.interceptedClasses = interceptor.interceptedClasses; |
| 1481 } | 1482 } |
| 1482 } | 1483 } |
| 1483 } | 1484 } |
| 1484 | 1485 |
| 1485 // TODO(ngeoffray): Also implement it for non-intercepted calls. | 1486 // TODO(ngeoffray): Also implement it for non-intercepted calls. |
| 1486 } | 1487 } |
| OLD | NEW |