| 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 '../../tree_ir/tree_ir_builder.dart' as tree_builder; | 24 import '../../tree_ir/tree_ir_builder.dart' as tree_builder; |
| 25 import '../../cps_ir/optimizers.dart'; | 25 import '../../cps_ir/optimizers.dart'; |
| 26 import '../../cps_ir/optimizers.dart' as cps_opt; | 26 import '../../cps_ir/optimizers.dart' as cps_opt; |
| 27 import '../../tracer.dart'; | 27 import '../../tracer.dart'; |
| 28 import '../../js_backend/codegen/codegen.dart'; | 28 import '../../js_backend/codegen/codegen.dart'; |
| 29 import '../../ssa/ssa.dart' as ssa; | 29 import '../../ssa/ssa.dart' as ssa; |
| 30 import '../../tree_ir/optimization/optimization.dart'; | 30 import '../../tree_ir/optimization/optimization.dart'; |
| 31 import '../../tree_ir/optimization/optimization.dart' as tree_opt; | 31 import '../../tree_ir/optimization/optimization.dart' as tree_opt; |
| 32 import '../../tree_ir/tree_ir_integrity.dart'; | 32 import '../../tree_ir/tree_ir_integrity.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'; | |
| 35 | 34 |
| 36 class CpsFunctionCompiler implements FunctionCompiler { | 35 class CpsFunctionCompiler implements FunctionCompiler { |
| 37 final ConstantSystem constantSystem; | 36 final ConstantSystem constantSystem; |
| 38 final Compiler compiler; | 37 final Compiler compiler; |
| 39 final Glue glue; | 38 final Glue glue; |
| 40 final SourceInformationFactory sourceInformationFactory; | 39 final SourceInformationFactory sourceInformationFactory; |
| 41 | 40 |
| 42 // TODO(karlklose,sigurm): remove and update dart-doc of [compile]. | 41 // TODO(karlklose,sigurm): remove and update dart-doc of [compile]. |
| 43 final FunctionCompiler fallbackCompiler; | 42 final FunctionCompiler fallbackCompiler; |
| 44 | 43 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 TypePropagator typePropagator = new TypePropagator(compiler); | 184 TypePropagator typePropagator = new TypePropagator(compiler); |
| 186 applyCpsPass(typePropagator); | 185 applyCpsPass(typePropagator); |
| 187 dumpTypedIR(cpsNode, typePropagator); | 186 dumpTypedIR(cpsNode, typePropagator); |
| 188 applyCpsPass(new RedundantPhiEliminator()); | 187 applyCpsPass(new RedundantPhiEliminator()); |
| 189 applyCpsPass(new ShrinkingReducer()); | 188 applyCpsPass(new ShrinkingReducer()); |
| 190 | 189 |
| 191 return cpsNode; | 190 return cpsNode; |
| 192 } | 191 } |
| 193 | 192 |
| 194 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { | 193 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { |
| 195 tree_builder.Builder builder = new JsTreeBuilder( | 194 tree_builder.Builder builder = new tree_builder.Builder( |
| 196 compiler.internalError, compiler.identicalFunction, glue); | 195 compiler.internalError); |
| 197 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); | 196 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); |
| 198 assert(treeNode != null); | 197 assert(treeNode != null); |
| 199 traceGraph('Tree builder', treeNode); | 198 traceGraph('Tree builder', treeNode); |
| 200 assert(checkTreeIntegrity(treeNode)); | 199 assert(checkTreeIntegrity(treeNode)); |
| 201 return treeNode; | 200 return treeNode; |
| 202 } | 201 } |
| 203 | 202 |
| 204 static bool checkTreeIntegrity(tree_ir.FunctionDefinition node) { | 203 static bool checkTreeIntegrity(tree_ir.FunctionDefinition node) { |
| 205 new CheckTreeIntegrity().check(node); | 204 new CheckTreeIntegrity().check(node); |
| 206 return true; // So this can be used from assert(). | 205 return true; // So this can be used from assert(). |
| (...skipping 25 matching lines...) Expand all Loading... |
| 232 // TODO(sigurdm): Make a better list of tasks. | 231 // TODO(sigurdm): Make a better list of tasks. |
| 233 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); | 232 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); |
| 234 } | 233 } |
| 235 | 234 |
| 236 js.Node attachPosition(js.Node node, AstElement element) { | 235 js.Node attachPosition(js.Node node, AstElement element) { |
| 237 return node.withSourceInformation( | 236 return node.withSourceInformation( |
| 238 sourceInformationFactory.forContext(element) | 237 sourceInformationFactory.forContext(element) |
| 239 .buildDeclaration(element)); | 238 .buildDeclaration(element)); |
| 240 } | 239 } |
| 241 } | 240 } |
| OLD | NEW |