| 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 Map<HInstruction, Range> ranges = <HInstruction, Range>{}; | 19 Map<HInstruction, Range> ranges = <HInstruction, Range>{}; |
| 20 | 20 |
| 21 void optimize(CodegenWorkItem work, HGraph graph) { | 21 void optimize(CodegenWorkItem work, HGraph graph) { |
| 22 void runPhase(OptimizationPhase phase) { | 22 void runPhase(OptimizationPhase phase) { |
| 23 phase.visitGraph(graph); | 23 measureSubtask(phase.name, () => phase.visitGraph(graph)); |
| 24 compiler.tracer.traceGraph(phase.name, graph); | 24 compiler.tracer.traceGraph(phase.name, graph); |
| 25 assert(graph.isValid()); | 25 assert(graph.isValid()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 ConstantSystem constantSystem = compiler.backend.constantSystem; | 28 ConstantSystem constantSystem = compiler.backend.constantSystem; |
| 29 JavaScriptItemCompilationContext context = work.compilationContext; | 29 JavaScriptItemCompilationContext context = work.compilationContext; |
| 30 bool trustPrimitives = compiler.trustPrimitives; | 30 bool trustPrimitives = compiler.trustPrimitives; |
| 31 measure(() { | 31 measure(() { |
| 32 List<OptimizationPhase> phases = <OptimizationPhase>[ | 32 List<OptimizationPhase> phases = <OptimizationPhase>[ |
| 33 // Run trivial instruction simplification first to optimize | 33 // Run trivial instruction simplification first to optimize |
| (...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 | 2352 |
| 2353 keyedValues.forEach((receiver, values) { | 2353 keyedValues.forEach((receiver, values) { |
| 2354 result.keyedValues[receiver] = | 2354 result.keyedValues[receiver] = |
| 2355 new Map<HInstruction, HInstruction>.from(values); | 2355 new Map<HInstruction, HInstruction>.from(values); |
| 2356 }); | 2356 }); |
| 2357 | 2357 |
| 2358 result.nonEscapingReceivers.addAll(nonEscapingReceivers); | 2358 result.nonEscapingReceivers.addAll(nonEscapingReceivers); |
| 2359 return result; | 2359 return result; |
| 2360 } | 2360 } |
| 2361 } | 2361 } |
| OLD | NEW |