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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/task.dart

Issue 1238163003: dart2js cps: Share interceptors by default and propagate to use later. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Renamed to let_sinking.dart Created 5 years, 5 months 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
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 cps.FunctionDefinition cpsNode = irBuilderTask.buildNode(element); 112 cps.FunctionDefinition cpsNode = irBuilderTask.buildNode(element);
113 if (cpsNode == null) { 113 if (cpsNode == null) {
114 if (irBuilderTask.bailoutMessage == null) { 114 if (irBuilderTask.bailoutMessage == null) {
115 giveUp('unable to build cps definition of $element'); 115 giveUp('unable to build cps definition of $element');
116 } else { 116 } else {
117 giveUp(irBuilderTask.bailoutMessage); 117 giveUp(irBuilderTask.bailoutMessage);
118 } 118 }
119 } 119 }
120 traceGraph("IR Builder", cpsNode); 120 traceGraph("IR Builder", cpsNode);
121 // Eliminating redundant phis before the unsugaring pass will make it
122 // insert fewer getInterceptor calls.
123 new RedundantPhiEliminator().rewrite(cpsNode);
124 traceGraph("Redundant phi elimination", cpsNode);
121 new UnsugarVisitor(glue).rewrite(cpsNode); 125 new UnsugarVisitor(glue).rewrite(cpsNode);
122 traceGraph("Unsugaring", cpsNode); 126 traceGraph("Unsugaring", cpsNode);
123 return cpsNode; 127 return cpsNode;
124 } 128 }
125 129
126 static const Pattern PRINT_TYPED_IR_FILTER = null; 130 static const Pattern PRINT_TYPED_IR_FILTER = null;
127 131
128 String formatTypeMask(TypeMask type) { 132 String formatTypeMask(TypeMask type) {
129 if (type is UnionTypeMask) { 133 if (type is UnionTypeMask) {
130 return '[${type.disjointMasks.map(formatTypeMask).join(', ')}]'; 134 return '[${type.disjointMasks.map(formatTypeMask).join(', ')}]';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 166 }
163 167
164 cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) { 168 cps.FunctionDefinition optimizeCpsIR(cps.FunctionDefinition cpsNode) {
165 // Transformations on the CPS IR. 169 // Transformations on the CPS IR.
166 void applyCpsPass(cps_opt.Pass pass) { 170 void applyCpsPass(cps_opt.Pass pass) {
167 pass.rewrite(cpsNode); 171 pass.rewrite(cpsNode);
168 traceGraph(pass.passName, cpsNode); 172 traceGraph(pass.passName, cpsNode);
169 assert(checkCpsIntegrity(cpsNode)); 173 assert(checkCpsIntegrity(cpsNode));
170 } 174 }
171 175
172 applyCpsPass(new RedundantPhiEliminator());
173 TypePropagator typePropagator = new TypePropagator(compiler); 176 TypePropagator typePropagator = new TypePropagator(compiler);
174 applyCpsPass(typePropagator); 177 applyCpsPass(typePropagator);
175 dumpTypedIR(cpsNode, typePropagator); 178 dumpTypedIR(cpsNode, typePropagator);
176 applyCpsPass(new ShrinkingReducer()); 179 applyCpsPass(new ShrinkingReducer());
177 applyCpsPass(new MutableVariableEliminator()); 180 applyCpsPass(new MutableVariableEliminator());
178 applyCpsPass(new RedundantJoinEliminator()); 181 applyCpsPass(new RedundantJoinEliminator());
179 applyCpsPass(new RedundantPhiEliminator()); 182 applyCpsPass(new RedundantPhiEliminator());
180 applyCpsPass(new ShrinkingReducer()); 183 applyCpsPass(new ShrinkingReducer());
184 applyCpsPass(new LetSinker());
181 185
182 return cpsNode; 186 return cpsNode;
183 } 187 }
184 188
185 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) { 189 tree_ir.FunctionDefinition compileToTreeIR(cps.FunctionDefinition cpsNode) {
186 tree_builder.Builder builder = new tree_builder.Builder( 190 tree_builder.Builder builder = new tree_builder.Builder(
187 compiler.internalError); 191 compiler.internalError);
188 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode); 192 tree_ir.FunctionDefinition treeNode = builder.buildFunction(cpsNode);
189 assert(treeNode != null); 193 assert(treeNode != null);
190 traceGraph('Tree builder', treeNode); 194 traceGraph('Tree builder', treeNode);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // TODO(sigurdm): Make a better list of tasks. 227 // TODO(sigurdm): Make a better list of tasks.
224 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks); 228 return <CompilerTask>[irBuilderTask]..addAll(fallbackCompiler.tasks);
225 } 229 }
226 230
227 js.Node attachPosition(js.Node node, AstElement element) { 231 js.Node attachPosition(js.Node node, AstElement element) {
228 return node.withSourceInformation( 232 return node.withSourceInformation(
229 sourceInformationFactory.createBuilderForContext(element) 233 sourceInformationFactory.createBuilderForContext(element)
230 .buildDeclaration(element)); 234 .buildDeclaration(element));
231 } 235 }
232 } 236 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/unsugar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698