| 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 dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
| 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
| 9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
| 10 class ElementAst { | 10 class ElementAst { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 // Transformations on the CPS IR. | 153 // Transformations on the CPS IR. |
| 154 void applyCpsPass(cps_opt.Pass pass) { | 154 void applyCpsPass(cps_opt.Pass pass) { |
| 155 pass.rewrite(cpsDefinition); | 155 pass.rewrite(cpsDefinition); |
| 156 context.traceGraph(pass.passName, cpsDefinition); | 156 context.traceGraph(pass.passName, cpsDefinition); |
| 157 assert(checkCpsIntegrity(cpsDefinition)); | 157 assert(checkCpsIntegrity(cpsDefinition)); |
| 158 } | 158 } |
| 159 | 159 |
| 160 // TODO(karlklose): enable type propagation for dart2dart when constant | 160 // TODO(karlklose): enable type propagation for dart2dart when constant |
| 161 // types are correctly marked as instantiated (Issue 21880). | 161 // types are correctly marked as instantiated (Issue 21880). |
| 162 applyCpsPass(new TypePropagator(context.dartTypes, | 162 TypePropagator typePropagator = new TypePropagator( |
| 163 context.constantSystem, | 163 context.dartTypes, |
| 164 new UnitTypeSystem(), | 164 context.constantSystem, |
| 165 context.internalError)); | 165 new UnitTypeSystem(), |
| 166 context.internalError); |
| 167 applyCpsPass(typePropagator); |
| 166 applyCpsPass(new RedundantPhiEliminator()); | 168 applyCpsPass(new RedundantPhiEliminator()); |
| 167 applyCpsPass(new ShrinkingReducer()); | 169 applyCpsPass(new ShrinkingReducer()); |
| 168 | 170 |
| 169 // Do not rewrite the IR after variable allocation. Allocation | 171 // Do not rewrite the IR after variable allocation. Allocation |
| 170 // makes decisions based on an approximation of IR variable live | 172 // makes decisions based on an approximation of IR variable live |
| 171 // ranges that can be invalidated by transforming the IR. | 173 // ranges that can be invalidated by transforming the IR. |
| 172 new cps_ir.RegisterAllocator(context.internalError).visit(cpsDefinition); | 174 new cps_ir.RegisterAllocator(context.internalError).visit(cpsDefinition); |
| 173 | 175 |
| 174 tree_builder.Builder builder = | 176 tree_builder.Builder builder = |
| 175 new tree_builder.Builder(context.internalError); | 177 new tree_builder.Builder(context.internalError); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 562 } |
| 561 | 563 |
| 562 void traceGraph(String title, var irObject) { | 564 void traceGraph(String title, var irObject) { |
| 563 compiler.tracer.traceGraph(title, irObject); | 565 compiler.tracer.traceGraph(title, irObject); |
| 564 } | 566 } |
| 565 | 567 |
| 566 DartTypes get dartTypes => compiler.types; | 568 DartTypes get dartTypes => compiler.types; |
| 567 | 569 |
| 568 InternalErrorFunction get internalError => compiler.internalError; | 570 InternalErrorFunction get internalError => compiler.internalError; |
| 569 } | 571 } |
| OLD | NEW |