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

Side by Side Diff: pkg/compiler/lib/src/dart_backend/backend.dart

Issue 792643003: Add DartTypes to abstract Types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/dart_types.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart_backend; 5 part of dart_backend;
6 6
7 // TODO(ahe): This class is simply wrong. This backend should use 7 // TODO(ahe): This class is simply wrong. This backend should use
8 // elements when it can, not AST nodes. Perhaps a [Map<Element, 8 // elements when it can, not AST nodes. Perhaps a [Map<Element,
9 // TreeElements>] is what is needed. 9 // TreeElements>] is what is needed.
10 class ElementAst { 10 class ElementAst {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // we don't trust the resolution to always get these included. 123 // we don't trust the resolution to always get these included.
124 world.registerInvocation(new Selector.call("toString", null, 0)); 124 world.registerInvocation(new Selector.call("toString", null, 0));
125 world.registerInvokedGetter(new Selector.getter("hashCode", null)); 125 world.registerInvokedGetter(new Selector.getter("hashCode", null));
126 world.registerInvocation(new Selector.binaryOperator("==")); 126 world.registerInvocation(new Selector.binaryOperator("=="));
127 world.registerInvocation(new Selector.call("compareTo", null, 1)); 127 world.registerInvocation(new Selector.call("compareTo", null, 1));
128 } 128 }
129 129
130 void codegen(CodegenWorkItem work) { } 130 void codegen(CodegenWorkItem work) { }
131 131
132 /// Create an [ElementAst] from the CPS IR. 132 /// Create an [ElementAst] from the CPS IR.
133 static ElementAst createElementAst(Compiler compiler, 133 static ElementAst createElementAst(
134 Compiler compiler,
134 Tracer tracer, 135 Tracer tracer,
135 ConstantSystem constantSystem, 136 ConstantSystem constantSystem,
136 Element element, 137 Element element,
137 cps_ir.ExecutableDefinition cpsDefinition) { 138 cps_ir.ExecutableDefinition cpsDefinition) {
138 // Transformations on the CPS IR. 139 // Transformations on the CPS IR.
139 if (tracer != null) { 140 if (tracer != null) {
140 tracer.traceCompilation(element.name, null); 141 tracer.traceCompilation(element.name, null);
141 } 142 }
142 143
143 void traceGraph(String title, var irObject) { 144 void traceGraph(String title, var irObject) {
144 if (tracer != null) { 145 if (tracer != null) {
145 tracer.traceGraph(title, irObject); 146 tracer.traceGraph(title, irObject);
146 } 147 }
147 } 148 }
148 149
149 // TODO(karlklose): enable type propagation for dart2dart when constant 150 // TODO(karlklose): enable type propagation for dart2dart when constant
150 // types are correctly marked as instantiated (Issue 21880). 151 // types are correctly marked as instantiated (Issue 21880).
151 new TypePropagator(compiler, constantSystem, new UnitTypeSystem(), 152 new TypePropagator(compiler.types, constantSystem, new UnitTypeSystem(),
152 compiler.internalError).rewrite(cpsDefinition); 153 compiler.internalError).rewrite(cpsDefinition);
153 traceGraph("Sparse constant propagation", cpsDefinition); 154 traceGraph("Sparse constant propagation", cpsDefinition);
154 new RedundantPhiEliminator().rewrite(cpsDefinition); 155 new RedundantPhiEliminator().rewrite(cpsDefinition);
155 traceGraph("Redundant phi elimination", cpsDefinition); 156 traceGraph("Redundant phi elimination", cpsDefinition);
156 new ShrinkingReducer().rewrite(cpsDefinition); 157 new ShrinkingReducer().rewrite(cpsDefinition);
157 traceGraph("Shrinking reductions", cpsDefinition); 158 traceGraph("Shrinking reductions", cpsDefinition);
158 159
159 // Do not rewrite the IR after variable allocation. Allocation 160 // Do not rewrite the IR after variable allocation. Allocation
160 // makes decisions based on an approximation of IR variable live 161 // makes decisions based on an approximation of IR variable live
161 // ranges that can be invalidated by transforming the IR. 162 // ranges that can be invalidated by transforming the IR.
162 new cps_ir.RegisterAllocator().visit(cpsDefinition); 163 new cps_ir.RegisterAllocator().visit(cpsDefinition);
163 164
164 tree_builder.Builder builder = 165 tree_builder.Builder builder = new tree_builder.Builder(
165 new tree_builder.Builder(new Glue(compiler), compiler); 166 new Glue(compiler), compiler.internalError, compiler.identicalFunction);
166 tree_ir.ExecutableDefinition treeDefinition = builder.build(cpsDefinition); 167 tree_ir.ExecutableDefinition treeDefinition = builder.build(cpsDefinition);
167 assert(treeDefinition != null); 168 assert(treeDefinition != null);
168 traceGraph('Tree builder', treeDefinition); 169 traceGraph('Tree builder', treeDefinition);
169 170
170 // Transformations on the Tree IR. 171 // Transformations on the Tree IR.
171 new StatementRewriter().rewrite(treeDefinition); 172 new StatementRewriter().rewrite(treeDefinition);
172 traceGraph('Statement rewriter', treeDefinition); 173 traceGraph('Statement rewriter', treeDefinition);
173 new CopyPropagator().rewrite(treeDefinition); 174 new CopyPropagator().rewrite(treeDefinition);
174 traceGraph('Copy propagation', treeDefinition); 175 traceGraph('Copy propagation', treeDefinition);
175 new LoopRewriter().rewrite(treeDefinition); 176 new LoopRewriter().rewrite(treeDefinition);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 521 }
521 522
522 ConstantExpression compileMetadata(MetadataAnnotation metadata, 523 ConstantExpression compileMetadata(MetadataAnnotation metadata,
523 Node node, 524 Node node,
524 TreeElements elements) { 525 TreeElements elements) {
525 return measure(() { 526 return measure(() {
526 return constantCompiler.compileMetadata(metadata, node, elements); 527 return constantCompiler.compileMetadata(metadata, node, elements);
527 }); 528 });
528 } 529 }
529 } 530 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/dart_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698