| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // types are correctly marked as instantiated (Issue 21880). | 161 // types are correctly marked as instantiated (Issue 21880). |
| 162 TypePropagator typePropagator = new TypePropagator( | 162 TypePropagator typePropagator = new TypePropagator( |
| 163 context.dartTypes, | 163 context.dartTypes, |
| 164 context.constantSystem, | 164 context.constantSystem, |
| 165 new UnitTypeSystem(), | 165 new UnitTypeSystem(), |
| 166 context.internalError); | 166 context.internalError); |
| 167 applyCpsPass(typePropagator); | 167 applyCpsPass(typePropagator); |
| 168 applyCpsPass(new RedundantPhiEliminator()); | 168 applyCpsPass(new RedundantPhiEliminator()); |
| 169 applyCpsPass(new ShrinkingReducer()); | 169 applyCpsPass(new ShrinkingReducer()); |
| 170 | 170 |
| 171 // Do not rewrite the IR after variable allocation. Allocation | |
| 172 // makes decisions based on an approximation of IR variable live | |
| 173 // ranges that can be invalidated by transforming the IR. | |
| 174 new cps_ir.RegisterAllocator(context.internalError).visit(cpsDefinition); | |
| 175 | |
| 176 tree_builder.Builder builder = | 171 tree_builder.Builder builder = |
| 177 new tree_builder.Builder(context.internalError); | 172 new tree_builder.Builder(context.internalError); |
| 178 tree_ir.ExecutableDefinition treeDefinition = builder.build(cpsDefinition); | 173 tree_ir.ExecutableDefinition treeDefinition = builder.build(cpsDefinition); |
| 179 assert(treeDefinition != null); | 174 assert(treeDefinition != null); |
| 180 context.traceGraph('Tree builder', treeDefinition); | 175 context.traceGraph('Tree builder', treeDefinition); |
| 181 assert(checkTreeIntegrity(treeDefinition)); | 176 assert(checkTreeIntegrity(treeDefinition)); |
| 182 | 177 |
| 183 // Transformations on the Tree IR. | 178 // Transformations on the Tree IR. |
| 184 void applyTreePass(tree_opt.Pass pass) { | 179 void applyTreePass(tree_opt.Pass pass) { |
| 185 pass.rewrite(treeDefinition); | 180 pass.rewrite(treeDefinition); |
| 186 context.traceGraph(pass.passName, treeDefinition); | 181 context.traceGraph(pass.passName, treeDefinition); |
| 187 assert(checkTreeIntegrity(treeDefinition)); | 182 assert(checkTreeIntegrity(treeDefinition)); |
| 188 } | 183 } |
| 189 | 184 |
| 190 applyTreePass(new StatementRewriter()); | 185 applyTreePass(new StatementRewriter()); |
| 191 applyTreePass(new CopyPropagator()); | 186 applyTreePass(new VariableMerger()); |
| 192 applyTreePass(new LoopRewriter()); | 187 applyTreePass(new LoopRewriter()); |
| 193 applyTreePass(new LogicalRewriter()); | 188 applyTreePass(new LogicalRewriter()); |
| 194 | 189 |
| 195 // Backend-specific transformations. | 190 // Backend-specific transformations. |
| 196 new backend_ast_emitter.UnshadowParameters().unshadow(treeDefinition); | 191 new backend_ast_emitter.UnshadowParameters().unshadow(treeDefinition); |
| 197 context.traceGraph('Unshadow parameters', treeDefinition); | 192 context.traceGraph('Unshadow parameters', treeDefinition); |
| 198 | 193 |
| 199 TreeElementMapping treeElements = new TreeElementMapping(element); | 194 TreeElementMapping treeElements = new TreeElementMapping(element); |
| 200 backend_ast.ExecutableDefinition backendAst = | 195 backend_ast.ExecutableDefinition backendAst = |
| 201 backend_ast_emitter.emit(treeDefinition); | 196 backend_ast_emitter.emit(treeDefinition); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 } | 557 } |
| 563 | 558 |
| 564 void traceGraph(String title, var irObject) { | 559 void traceGraph(String title, var irObject) { |
| 565 compiler.tracer.traceGraph(title, irObject); | 560 compiler.tracer.traceGraph(title, irObject); |
| 566 } | 561 } |
| 567 | 562 |
| 568 DartTypes get dartTypes => compiler.types; | 563 DartTypes get dartTypes => compiler.types; |
| 569 | 564 |
| 570 InternalErrorFunction get internalError => compiler.internalError; | 565 InternalErrorFunction get internalError => compiler.internalError; |
| 571 } | 566 } |
| OLD | NEW |