Chromium Code Reviews| Index: pkg/compiler/lib/src/dart_backend/backend.dart |
| diff --git a/pkg/compiler/lib/src/dart_backend/backend.dart b/pkg/compiler/lib/src/dart_backend/backend.dart |
| index 90baf1b2d30221dea10da42994cd2f62098c638f..6fd3c1cfced4c1dc746628e6183ae73583c7b1b4 100644 |
| --- a/pkg/compiler/lib/src/dart_backend/backend.dart |
| +++ b/pkg/compiler/lib/src/dart_backend/backend.dart |
| @@ -131,26 +131,41 @@ class DartBackend extends Backend { |
| void codegen(CodegenWorkItem work) { } |
| + static bool checkTreeIntegrity(tree_ir.ExecutableDefinition node) { |
| + new CheckTreeIntegrity().check(node); |
| + return true; // So this can be used from assert(). |
| + } |
| + |
| + static bool checkCpsIntegrity(cps_ir.ExecutableDefinition node) { |
| + new CheckCpsIntegrity().check(node); |
| + return true; // So this can be used from assert(). |
| + } |
| + |
| /// Create an [ElementAst] from the CPS IR. |
| static ElementAst createElementAst( |
| ElementAstCreationContext context, |
| Element element, |
| cps_ir.ExecutableDefinition cpsDefinition) { |
| - // Transformations on the CPS IR. |
| context.traceCompilation(element.name); |
| + context.traceGraph('CPS builder', cpsDefinition); |
| + assert(checkCpsIntegrity(cpsDefinition)); |
| + |
| + // Transformations on the CPS IR. |
| + void applyCpsPass(String name, cps_opt.Pass pass) { |
|
Kevin Millikin (Google)
2015/03/04 13:07:41
This might be part of the rewrite method in the Pa
asgerf
2015/03/04 13:29:11
I don't like calling traceGraph from inside the Pa
|
| + pass.rewrite(cpsDefinition); |
| + context.traceGraph(name, cpsDefinition); |
| + assert(checkCpsIntegrity(cpsDefinition)); |
| + } |
| // TODO(karlklose): enable type propagation for dart2dart when constant |
| // types are correctly marked as instantiated (Issue 21880). |
| - new TypePropagator(context.dartTypes, |
| - context.constantSystem, |
| - new UnitTypeSystem(), |
| - context.internalError) |
| - .rewrite(cpsDefinition); |
| - context.traceGraph("Sparse constant propagation", cpsDefinition); |
| - new RedundantPhiEliminator().rewrite(cpsDefinition); |
| - context.traceGraph("Redundant phi elimination", cpsDefinition); |
| - new ShrinkingReducer().rewrite(cpsDefinition); |
| - context.traceGraph("Shrinking reductions", cpsDefinition); |
| + applyCpsPass('Sparse constant propagation', |
| + new TypePropagator(context.dartTypes, |
| + context.constantSystem, |
| + new UnitTypeSystem(), |
| + context.internalError)); |
| + applyCpsPass('Redundant phi elimination', new RedundantPhiEliminator()); |
| + applyCpsPass('Shrinking reductions', new ShrinkingReducer()); |
| // Do not rewrite the IR after variable allocation. Allocation |
| // makes decisions based on an approximation of IR variable live |
| @@ -162,16 +177,21 @@ class DartBackend extends Backend { |
| tree_ir.ExecutableDefinition treeDefinition = builder.build(cpsDefinition); |
| assert(treeDefinition != null); |
| context.traceGraph('Tree builder', treeDefinition); |
| + assert(checkTreeIntegrity(treeDefinition)); |
| // Transformations on the Tree IR. |
| - new StatementRewriter().rewrite(treeDefinition); |
| - context.traceGraph('Statement rewriter', treeDefinition); |
| - new CopyPropagator().rewrite(treeDefinition); |
| - context.traceGraph('Copy propagation', treeDefinition); |
| - new LoopRewriter().rewrite(treeDefinition); |
| - context.traceGraph('Loop rewriter', treeDefinition); |
| - new LogicalRewriter().rewrite(treeDefinition); |
| - context.traceGraph('Logical rewriter', treeDefinition); |
| + void applyTreePass(String name, tree_opt.Pass pass) { |
| + pass.rewrite(treeDefinition); |
| + context.traceGraph(name, treeDefinition); |
| + assert(checkTreeIntegrity(treeDefinition)); |
| + } |
| + |
| + applyTreePass('Statement rewriter', new StatementRewriter()); |
| + applyTreePass('Copy propagation', new CopyPropagator()); |
| + applyTreePass('Loop rewriter', new LoopRewriter()); |
| + applyTreePass('Logical rewriter', new LogicalRewriter()); |
| + |
| + // Backend-specific transformations. |
| new backend_ast_emitter.UnshadowParameters().unshadow(treeDefinition); |
| context.traceGraph('Unshadow parameters', treeDefinition); |