| Index: pkg/compiler/lib/src/js_backend/codegen/task.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/codegen/task.dart b/pkg/compiler/lib/src/js_backend/codegen/task.dart
|
| index 68e1d5bfbc8476dbfefdb4e75e779a0bb09826b0..8fc5804447fff39ea8186b5f55bbc199c549af3b 100644
|
| --- a/pkg/compiler/lib/src/js_backend/codegen/task.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/codegen/task.dart
|
| @@ -16,6 +16,7 @@ import '../../cps_ir/cps_ir_nodes.dart' as cps;
|
| import '../../cps_ir/cps_ir_builder.dart';
|
| import '../../tree_ir/tree_ir_nodes.dart' as tree_ir;
|
| import '../../tree/tree.dart' as ast;
|
| +import '../../types/types.dart' show TypeMask;
|
| import '../../scanner/scannerlib.dart' as scanner;
|
| import '../../elements/elements.dart';
|
| import '../../closure.dart';
|
| @@ -28,6 +29,7 @@ import '../../tracer.dart';
|
| import '../../js_backend/codegen/codegen.dart';
|
| import '../../ssa/ssa.dart' as ssa;
|
| import '../../tree_ir/optimization/optimization.dart';
|
| +import '../../cps_ir/cps_ir_nodes_sexpr.dart';
|
|
|
| class CspFunctionCompiler implements FunctionCompiler {
|
| final IrBuilderTask irBuilderTask;
|
| @@ -35,6 +37,8 @@ class CspFunctionCompiler implements FunctionCompiler {
|
| final Compiler compiler;
|
| final Glue glue;
|
|
|
| + TypeSystem types;
|
| +
|
| // TODO(karlklose,sigurm): remove and update dart-doc of [compile].
|
| final FunctionCompiler fallbackCompiler;
|
|
|
| @@ -55,6 +59,7 @@ class CspFunctionCompiler implements FunctionCompiler {
|
| /// features not implemented it will fall back to the ssa pipeline (for
|
| /// platform code) or will cancel compilation (for user code).
|
| js.Fun compile(CodegenWorkItem work) {
|
| + types = new TypeMaskSystem(compiler);
|
| AstElement element = work.element;
|
| return compiler.withCurrentElement(element, () {
|
| try {
|
| @@ -107,12 +112,27 @@ class CspFunctionCompiler implements FunctionCompiler {
|
| return cpsNode;
|
| }
|
|
|
| + static const Pattern PRINT_TYPED_IR_FILTER = null;
|
| +
|
| cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) {
|
| // Transformations on the CPS IR.
|
| traceGraph("IR Builder", cpsNode);
|
| - new ConstantPropagator(compiler, constantSystem)
|
| - .rewrite(cpsNode);
|
| +
|
| + TypePropagator typePropagator = new TypePropagator<TypeMask>(compiler,
|
| + constantSystem, new TypeMaskSystem(compiler), compiler.internalError);
|
| + typePropagator.rewrite(cpsNode);
|
| traceGraph("Sparse constant propagation", cpsNode);
|
| +
|
| + if (PRINT_TYPED_IR_FILTER != null &&
|
| + PRINT_TYPED_IR_FILTER.matchAsPrefix(cpsNode.element.name) != null) {
|
| + String printType(cps.Node node, String s) {
|
| + var type = typePropagator.getType(node);
|
| + return type == null ? s : "<$type: $s>";
|
| + }
|
| + DEBUG_MODE = true;
|
| + print(new SExpressionStringifier(printType).visit(cpsNode));
|
| + }
|
| +
|
| new RedundantPhiEliminator().rewrite(cpsNode);
|
| traceGraph("Redundant phi elimination", cpsNode);
|
| new ShrinkingReducer().rewrite(cpsNode);
|
|
|