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

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

Issue 1375213003: dart2js cps: Maintain parent pointers instead of recomputing them. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 tracer.traceGraph(title, irObject); 114 tracer.traceGraph(title, irObject);
115 } 115 }
116 } 116 }
117 117
118 void applyCpsPass(cps_opt.Pass pass, cps.FunctionDefinition cpsFunction) { 118 void applyCpsPass(cps_opt.Pass pass, cps.FunctionDefinition cpsFunction) {
119 cpsOptimizationTask.measureSubtask(pass.passName, () { 119 cpsOptimizationTask.measureSubtask(pass.passName, () {
120 pass.rewrite(cpsFunction); 120 pass.rewrite(cpsFunction);
121 }); 121 });
122 traceGraph(pass.passName, cpsFunction); 122 traceGraph(pass.passName, cpsFunction);
123 dumpTypedIr(pass.passName, cpsFunction); 123 dumpTypedIr(pass.passName, cpsFunction);
124 assert(checkCpsIntegrity(cpsFunction)); 124 assert(checkCpsIntegrity(cpsFunction, pass.passName));
125 } 125 }
126 126
127 cps.FunctionDefinition compileToCpsIr(AstElement element) { 127 cps.FunctionDefinition compileToCpsIr(AstElement element) {
128 cps.FunctionDefinition cpsFunction = cpsBuilderTask.buildNode(element); 128 cps.FunctionDefinition cpsFunction = cpsBuilderTask.buildNode(element);
129 if (cpsFunction == null) { 129 if (cpsFunction == null) {
130 if (cpsBuilderTask.bailoutMessage == null) { 130 if (cpsBuilderTask.bailoutMessage == null) {
131 giveUp('unable to build cps definition of $element'); 131 giveUp('unable to build cps definition of $element');
132 } else { 132 } else {
133 giveUp(cpsBuilderTask.bailoutMessage); 133 giveUp(cpsBuilderTask.bailoutMessage);
134 } 134 }
135 } 135 }
136 ParentVisitor.setParents(cpsFunction);
136 traceGraph('IR Builder', cpsFunction); 137 traceGraph('IR Builder', cpsFunction);
137 dumpTypedIr('IR Builder', cpsFunction); 138 dumpTypedIr('IR Builder', cpsFunction);
138 // Eliminating redundant phis before the unsugaring pass will make it 139 // Eliminating redundant phis before the unsugaring pass will make it
139 // insert fewer getInterceptor calls. 140 // insert fewer getInterceptor calls.
140 applyCpsPass(new RedundantPhiEliminator(), cpsFunction); 141 applyCpsPass(new RedundantPhiEliminator(), cpsFunction);
141 applyCpsPass(new UnsugarVisitor(glue), cpsFunction); 142 applyCpsPass(new UnsugarVisitor(glue), cpsFunction);
142 return cpsFunction; 143 return cpsFunction;
143 } 144 }
144 145
145 static const Pattern PRINT_TYPED_IR_FILTER = null; 146 static const Pattern PRINT_TYPED_IR_FILTER = null;
(...skipping 23 matching lines...) Expand all
169 return node is cps.Variable && node.type != null 170 return node is cps.Variable && node.type != null
170 ? '$s:${formatTypeMask(node.type)}' 171 ? '$s:${formatTypeMask(node.type)}'
171 : s; 172 : s;
172 } 173 }
173 DEBUG_MODE = true; 174 DEBUG_MODE = true;
174 print(';;; ==== After $passName ===='); 175 print(';;; ==== After $passName ====');
175 print(new SExpressionStringifier(printType).visit(cpsFunction)); 176 print(new SExpressionStringifier(printType).visit(cpsFunction));
176 } 177 }
177 } 178 }
178 179
179 static bool checkCpsIntegrity(cps.FunctionDefinition node) { 180 static bool checkCpsIntegrity(cps.FunctionDefinition node, String pass) {
180 new CheckCpsIntegrity().check(node); 181 new CheckCpsIntegrity().check(node, pass);
181 return true; // So this can be used from assert(). 182 return true; // So this can be used from assert().
182 } 183 }
183 184
184 cps.FunctionDefinition optimizeCpsIr(cps.FunctionDefinition cpsFunction) { 185 cps.FunctionDefinition optimizeCpsIr(cps.FunctionDefinition cpsFunction) {
185 TypeMaskSystem typeSystem = new TypeMaskSystem(compiler); 186 TypeMaskSystem typeSystem = new TypeMaskSystem(compiler);
186 187
187 applyCpsPass(new RedundantJoinEliminator(), cpsFunction); 188 applyCpsPass(new RedundantJoinEliminator(), cpsFunction);
188 applyCpsPass(new RedundantPhiEliminator(), cpsFunction); 189 applyCpsPass(new RedundantPhiEliminator(), cpsFunction);
189 applyCpsPass(new InsertRefinements(typeSystem), cpsFunction); 190 applyCpsPass(new InsertRefinements(typeSystem), cpsFunction);
190 applyCpsPass(new TypePropagator(compiler, typeSystem, this), cpsFunction); 191 applyCpsPass(new TypePropagator(compiler, typeSystem, this), cpsFunction);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 treeOptimizationTask] 256 treeOptimizationTask]
256 ..addAll(fallbackCompiler.tasks); 257 ..addAll(fallbackCompiler.tasks);
257 } 258 }
258 259
259 js.Node attachPosition(js.Node node, AstElement element) { 260 js.Node attachPosition(js.Node node, AstElement element) {
260 return node.withSourceInformation( 261 return node.withSourceInformation(
261 sourceInformationFactory.createBuilderForContext(element) 262 sourceInformationFactory.createBuilderForContext(element)
262 .buildDeclaration(element)); 263 .buildDeclaration(element));
263 } 264 }
264 } 265 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698