| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Generate code using the cps-based IR pipeline. | 5 /// Generate code using the cps-based IR pipeline. |
| 6 library code_generator_task; | 6 library code_generator_task; |
| 7 | 7 |
| 8 import 'glue.dart'; | 8 import 'glue.dart'; |
| 9 import 'codegen.dart'; | 9 import 'codegen.dart'; |
| 10 import 'unsugar.dart'; | 10 import 'unsugar.dart'; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 import '../../js/js.dart' as js; | 24 import '../../js/js.dart' as js; |
| 25 import '../../source_map_builder.dart'; | 25 import '../../source_map_builder.dart'; |
| 26 import '../../tree_ir/tree_ir_builder.dart' as tree_builder; | 26 import '../../tree_ir/tree_ir_builder.dart' as tree_builder; |
| 27 import '../../dart_backend/backend_ast_emitter.dart' as backend_ast_emitter; | 27 import '../../dart_backend/backend_ast_emitter.dart' as backend_ast_emitter; |
| 28 import '../../cps_ir/optimizers.dart'; | 28 import '../../cps_ir/optimizers.dart'; |
| 29 import '../../tracer.dart'; | 29 import '../../tracer.dart'; |
| 30 import '../../js_backend/codegen/codegen.dart'; | 30 import '../../js_backend/codegen/codegen.dart'; |
| 31 import '../../ssa/ssa.dart' as ssa; | 31 import '../../ssa/ssa.dart' as ssa; |
| 32 import '../../tree_ir/optimization/optimization.dart'; | 32 import '../../tree_ir/optimization/optimization.dart'; |
| 33 import '../../cps_ir/cps_ir_nodes_sexpr.dart'; | 33 import '../../cps_ir/cps_ir_nodes_sexpr.dart'; |
| 34 import 'js_tree_builder.dart'; |
| 34 | 35 |
| 35 class CspFunctionCompiler implements FunctionCompiler { | 36 class CspFunctionCompiler implements FunctionCompiler { |
| 36 final IrBuilderTask irBuilderTask; | 37 final IrBuilderTask irBuilderTask; |
| 37 final ConstantSystem constantSystem; | 38 final ConstantSystem constantSystem; |
| 38 final Compiler compiler; | 39 final Compiler compiler; |
| 39 final Glue glue; | 40 final Glue glue; |
| 40 | 41 |
| 41 TypeSystem types; | 42 TypeSystem types; |
| 42 | 43 |
| 43 // TODO(karlklose,sigurm): remove and update dart-doc of [compile]. | 44 // TODO(karlklose,sigurm): remove and update dart-doc of [compile]. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 traceGraph("Shrinking reductions", cpsNode); | 159 traceGraph("Shrinking reductions", cpsNode); |
| 159 | 160 |
| 160 // Do not rewrite the IR after variable allocation. Allocation | 161 // Do not rewrite the IR after variable allocation. Allocation |
| 161 // makes decisions based on an approximation of IR variable live | 162 // makes decisions based on an approximation of IR variable live |
| 162 // ranges that can be invalidated by transforming the IR. | 163 // ranges that can be invalidated by transforming the IR. |
| 163 new cps.RegisterAllocator().visit(cpsNode); | 164 new cps.RegisterAllocator().visit(cpsNode); |
| 164 return cpsNode; | 165 return cpsNode; |
| 165 } | 166 } |
| 166 | 167 |
| 167 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { | 168 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { |
| 168 tree_builder.Builder builder = new tree_builder.Builder( | 169 tree_builder.Builder builder = new JsTreeBuilder( |
| 169 glue, compiler.internalError, compiler.identicalFunction); | 170 compiler.internalError, compiler.identicalFunction, glue); |
| 170 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); | 171 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); |
| 171 assert(treeNode != null); | 172 assert(treeNode != null); |
| 172 traceGraph('Tree builder', treeNode); | 173 traceGraph('Tree builder', treeNode); |
| 173 return treeNode; | 174 return treeNode; |
| 174 } | 175 } |
| 175 | 176 |
| 176 tree_ir.FunctionDefinition optimizeTreeIR( | 177 tree_ir.FunctionDefinition optimizeTreeIR( |
| 177 tree_ir.FunctionDefinition treeNode) { | 178 tree_ir.FunctionDefinition treeNode) { |
| 178 // Transformations on the Tree IR. | 179 // Transformations on the Tree IR. |
| 179 new StatementRewriter().rewrite(treeNode); | 180 new StatementRewriter().rewrite(treeNode); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 if (endToken.charOffset < sourceFile.length) { | 228 if (endToken.charOffset < sourceFile.length) { |
| 228 endSourcePosition = | 229 endSourcePosition = |
| 229 new TokenSourceFileLocation(sourceFile, endToken, name); | 230 new TokenSourceFileLocation(sourceFile, endToken, name); |
| 230 } | 231 } |
| 231 return node.withPosition(sourcePosition, endSourcePosition); | 232 return node.withPosition(sourcePosition, endSourcePosition); |
| 232 } | 233 } |
| 233 | 234 |
| 234 SourceFile sourceFileOfElement(Element element) { | 235 SourceFile sourceFileOfElement(Element element) { |
| 235 return element.implementation.compilationUnit.script.file; | 236 return element.implementation.compilationUnit.script.file; |
| 236 } | 237 } |
| 237 | |
| 238 } | 238 } |
| OLD | NEW |