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

Side by Side Diff: frog/leg/ssa/codegen.dart

Issue 9601009: Change labeled statement to use visitSubGraph for its body instead of marking its "exit block" spec… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 String generate(WorkItem work, HGraph graph) { 9 String generate(WorkItem work, HGraph graph) {
10 return measure(() { 10 return measure(() {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 indent++; // We are already inside a function. 154 indent++; // We are already inside a function.
155 subGraph = new SubGraph(graph.entry, graph.exit); 155 subGraph = new SubGraph(graph.entry, graph.exit);
156 beginGraph(graph); 156 beginGraph(graph);
157 visitBasicBlock(graph.entry); 157 visitBasicBlock(graph.entry);
158 endGraph(graph); 158 endGraph(graph);
159 } 159 }
160 160
161 void visitSubGraph(SubGraph newSubGraph) { 161 void visitSubGraph(SubGraph newSubGraph) {
162 SubGraph oldSubGraph = subGraph; 162 SubGraph oldSubGraph = subGraph;
163 subGraph = newSubGraph; 163 subGraph = newSubGraph;
164 visitBasicBlock(subGraph.start); 164 iterateBasicBlock(subGraph.start);
165 subGraph = oldSubGraph; 165 subGraph = oldSubGraph;
166 } 166 }
167 167
168 String temporary(HInstruction instruction) { 168 String temporary(HInstruction instruction) {
169 int id = instruction.id; 169 int id = instruction.id;
170 String name = names[id]; 170 String name = names[id];
171 if (name !== null) return name; 171 if (name !== null) return name;
172 172
173 String prefix = 't'; 173 String prefix = 't';
174 if (!prefixes.containsKey(prefix)) prefixes[prefix] = 0; 174 if (!prefixes.containsKey(prefix)) prefixes[prefix] = 0;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 visit(HInstruction node, int expectedPrecedence) { 233 visit(HInstruction node, int expectedPrecedence) {
234 int oldPrecedence = this.expectedPrecedence; 234 int oldPrecedence = this.expectedPrecedence;
235 this.expectedPrecedence = expectedPrecedence; 235 this.expectedPrecedence = expectedPrecedence;
236 node.accept(this); 236 node.accept(this);
237 this.expectedPrecedence = oldPrecedence; 237 this.expectedPrecedence = oldPrecedence;
238 } 238 }
239 239
240 void handleLabeledBlock(HBasicBlock node) { 240 void handleLabeledBlock(HBasicBlock node) {
241 HLabeledBlockInformation labeledBlockInfo = node.labeledBlockInformation; 241 HLabeledBlockInformation labeledBlockInfo = node.labeledBlockInformation;
242 if (labeledBlockInfo.start === node) { 242
243 addIndentation(); 243 addIndentation();
244 for (SourceString label in labeledBlockInfo.labels) { 244 for (SourceString label in labeledBlockInfo.labels) {
245 addLabel(label); 245 addLabel(label);
246 buffer.add(":"); 246 buffer.add(":");
247 }
248 buffer.add("{\n");
249 indent++;
250 } else {
251 assert(labeledBlockInfo.end === node);
252 assert((){
253 // Check that this block is (transitively) dominated by the start block.
254 HBasicBlock block = node;
255 while (block.dominator !== null) {
256 block = block.dominator;
257 if (block === labeledBlockInfo.start) return true;
258 }
259 return false;
260 });
261 indent--;
262 addIndentation();
263 buffer.add("}\n");
264 } 247 }
248 buffer.add("{\n");
249 indent++;
250
251 visitSubGraph(labeledBlockInfo.body);
252
253 indent--;
254 addIndentation();
255 buffer.add("}\n");
256
257 visitBasicBlock(labeledBlockInfo.joinBlock);
265 } 258 }
266 259
267 260
268 visitBasicBlock(HBasicBlock node) { 261 visitBasicBlock(HBasicBlock node) {
269 if (!subGraph.contains(node)) return; 262 if (!subGraph.contains(node)) return;
270 263
271 currentBlock = node;
272
273 if (node.hasLabeledBlockInformation()) { 264 if (node.hasLabeledBlockInformation()) {
274 handleLabeledBlock(node); 265 handleLabeledBlock(node);
275 } else if (currentBlock.isLoopHeader()) { 266 return;
267 }
268 iterateBasicBlock(node);
269 }
270
271 iterateBasicBlock(HBasicBlock node) {
ngeoffray 2012/03/05 14:12:48 Was this change (adding iterateBasicBlock) necessa
Lasse Reichstein Nielsen 2012/03/05 14:16:49 Sadly, yes, something is necessary, but I'm not en
272 currentBlock = node;
273 if (node.isLoopHeader()) {
276 // While loop will be closed by the conditional loop-branch. 274 // While loop will be closed by the conditional loop-branch.
277 // TODO(floitsch): HACK HACK HACK. 275 // TODO(floitsch): HACK HACK HACK.
278 beginLoop(node); 276 beginLoop(node);
279 } 277 }
280
281 HInstruction instruction = node.first; 278 HInstruction instruction = node.first;
282 while (instruction != null) { 279 while (instruction != null) {
283 if (instruction is HGoto || instruction is HExit || instruction is HTry) { 280 if (instruction is HGoto || instruction is HExit || instruction is HTry) {
284 visit(instruction, JSPrecedence.STATEMENT_PRECEDENCE); 281 visit(instruction, JSPrecedence.STATEMENT_PRECEDENCE);
285 return; 282 return;
286 } else if (!instruction.generateAtUseSite()) { 283 } else if (!instruction.generateAtUseSite()) {
287 if (instruction is !HIf && instruction is !HBailoutTarget) { 284 if (instruction is !HIf && instruction is !HBailoutTarget) {
288 addIndentation(); 285 addIndentation();
289 } 286 }
290 if (instruction.usedBy.isEmpty() || instruction is HLocal) { 287 if (instruction.usedBy.isEmpty() || instruction is HLocal) {
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 startBailoutSwitch(); 1396 startBailoutSwitch();
1400 } 1397 }
1401 } 1398 }
1402 1399
1403 void endElse(HIf node) { 1400 void endElse(HIf node) {
1404 if (node.elseBlock.hasBailouts()) { 1401 if (node.elseBlock.hasBailouts()) {
1405 endBailoutSwitch(); 1402 endBailoutSwitch();
1406 } 1403 }
1407 } 1404 }
1408 } 1405 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698