Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: pkg/compiler/lib/src/dart_backend/backend.dart

Issue 812333002: Fix analyzer2dart end2end. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix latent crash in modely. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer2dart/lib/src/tree_shaker.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d5a2b70e7d90724ebd51a2595dc50350dec81568..3aebb9e6ce845d348474c16237b4dd6832b6a547 100644
--- a/pkg/compiler/lib/src/dart_backend/backend.dart
+++ b/pkg/compiler/lib/src/dart_backend/backend.dart
@@ -131,31 +131,24 @@ class DartBackend extends Backend {
/// Create an [ElementAst] from the CPS IR.
static ElementAst createElementAst(
- Compiler compiler,
- Tracer tracer,
- ConstantSystem constantSystem,
+ ElementAstCreationContext context,
Element element,
cps_ir.ExecutableDefinition cpsDefinition) {
// Transformations on the CPS IR.
- if (tracer != null) {
- tracer.traceCompilation(element.name, null);
- }
-
- void traceGraph(String title, var irObject) {
- if (tracer != null) {
- tracer.traceGraph(title, irObject);
- }
- }
+ context.traceCompilation(element.name);
// TODO(karlklose): enable type propagation for dart2dart when constant
// types are correctly marked as instantiated (Issue 21880).
- new TypePropagator(compiler.types, constantSystem, new UnitTypeSystem(),
- compiler.internalError).rewrite(cpsDefinition);
- traceGraph("Sparse constant propagation", cpsDefinition);
+ new TypePropagator(context.dartTypes,
+ context.constantSystem,
+ new UnitTypeSystem(),
+ context.internalError)
+ .rewrite(cpsDefinition);
+ context.traceGraph("Sparse constant propagation", cpsDefinition);
new RedundantPhiEliminator().rewrite(cpsDefinition);
- traceGraph("Redundant phi elimination", cpsDefinition);
+ context.traceGraph("Redundant phi elimination", cpsDefinition);
new ShrinkingReducer().rewrite(cpsDefinition);
- traceGraph("Shrinking reductions", cpsDefinition);
+ context.traceGraph("Shrinking reductions", cpsDefinition);
// Do not rewrite the IR after variable allocation. Allocation
// makes decisions based on an approximation of IR variable live
@@ -163,22 +156,22 @@ class DartBackend extends Backend {
new cps_ir.RegisterAllocator().visit(cpsDefinition);
tree_builder.Builder builder =
- new tree_builder.Builder(compiler.internalError);
+ new tree_builder.Builder(context.internalError);
tree_ir.ExecutableDefinition treeDefinition = builder.build(cpsDefinition);
assert(treeDefinition != null);
- traceGraph('Tree builder', treeDefinition);
+ context.traceGraph('Tree builder', treeDefinition);
// Transformations on the Tree IR.
new StatementRewriter().rewrite(treeDefinition);
- traceGraph('Statement rewriter', treeDefinition);
+ context.traceGraph('Statement rewriter', treeDefinition);
new CopyPropagator().rewrite(treeDefinition);
- traceGraph('Copy propagation', treeDefinition);
+ context.traceGraph('Copy propagation', treeDefinition);
new LoopRewriter().rewrite(treeDefinition);
- traceGraph('Loop rewriter', treeDefinition);
+ context.traceGraph('Loop rewriter', treeDefinition);
new LogicalRewriter().rewrite(treeDefinition);
- traceGraph('Logical rewriter', treeDefinition);
+ context.traceGraph('Logical rewriter', treeDefinition);
new backend_ast_emitter.UnshadowParameters().unshadow(treeDefinition);
- traceGraph('Unshadow parameters', treeDefinition);
+ context.traceGraph('Unshadow parameters', treeDefinition);
TreeElementMapping treeElements = new TreeElementMapping(element);
backend_ast.ExecutableDefinition backendAst =
@@ -201,6 +194,8 @@ class DartBackend extends Backend {
}
void assembleProgram() {
+ ElementAstCreationContext context =
+ new _ElementAstCreationContext(compiler, constantSystem);
ElementAst computeElementAst(AstElement element) {
if (!compiler.irBuilder.hasIr(element)) {
@@ -209,8 +204,7 @@ class DartBackend extends Backend {
} else {
cps_ir.ExecutableDefinition definition =
compiler.irBuilder.getIr(element);
- return createElementAst(compiler,
- compiler.tracer, constantSystem, element, definition);
+ return createElementAst(context, element, definition);
}
}
@@ -528,3 +522,31 @@ class DartConstantTask extends ConstantCompilerTask
});
}
}
+
+abstract class ElementAstCreationContext {
+ DartTypes get dartTypes;
+ ConstantSystem get constantSystem;
+ InternalErrorFunction get internalError;
+
+ void traceCompilation(String name);
+ void traceGraph(String title, var irObject);
+}
+
+class _ElementAstCreationContext implements ElementAstCreationContext {
+ final Compiler compiler;
+ final ConstantSystem constantSystem;
+
+ _ElementAstCreationContext(this.compiler, this.constantSystem);
+
+ void traceCompilation(String name) {
+ compiler.tracer.traceCompilation(name, null);
+ }
+
+ void traceGraph(String title, var irObject) {
+ compiler.tracer.traceGraph(title, irObject);
+ }
+
+ DartTypes get dartTypes => compiler.types;
+
+ InternalErrorFunction get internalError => compiler.internalError;
+}
« no previous file with comments | « pkg/analyzer2dart/lib/src/tree_shaker.dart ('k') | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698