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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10001008: Many type fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 8 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 9
10 String generateMethod(WorkItem work, HGraph graph) { 10 String generateMethod(WorkItem work, HGraph graph) {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return false; 229 return false;
230 } 230 }
231 } while (limits.contains(basicBlock)); 231 } while (limits.contains(basicBlock));
232 return true; 232 return true;
233 } 233 }
234 234
235 bool isCondition(SubGraph limits) { 235 bool isCondition(SubGraph limits) {
236 return isExpression(limits) && (limits.end.last is HConditionalBranch); 236 return isExpression(limits) && (limits.end.last is HConditionalBranch);
237 } 237 }
238 238
239 void visitExpressionGraph(SubGraph subGraph) { 239 void visitExpressionGraph(SubGraph expressionSubGraph) {
240 int oldState = generationState; 240 int oldState = generationState;
241 generationState = STATE_FIRST_EXPRESSION; 241 generationState = STATE_FIRST_EXPRESSION;
242 visitSubGraph(subGraph); 242 visitSubGraph(expressionSubGraph);
243 generationState = oldState; 243 generationState = oldState;
244 } 244 }
245 245
246 void visitConditionGraph(SubGraph subGraph) { 246 void visitConditionGraph(SubGraph conditionSubGraph) {
247 visitExpressionGraph(subGraph); 247 visitExpressionGraph(conditionSubGraph);
248 } 248 }
249 249
250 String temporary(HInstruction instruction) { 250 String temporary(HInstruction instruction) {
251 int id = instruction.id; 251 int id = instruction.id;
252 String name = names[id]; 252 String name = names[id];
253 if (name !== null) return name; 253 if (name !== null) return name;
254 254
255 if (instruction is HPhi) { 255 if (instruction is HPhi) {
256 HPhi phi = instruction; 256 HPhi phi = instruction;
257 Element element = phi.element; 257 Element element = phi.element;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 } 342 }
343 343
344 void define(HInstruction instruction) { 344 void define(HInstruction instruction) {
345 String name = temporary(instruction); 345 String name = temporary(instruction);
346 declareVariable(name); 346 declareVariable(name);
347 buffer.add(" = "); 347 buffer.add(" = ");
348 visit(instruction, JSPrecedence.ASSIGNMENT_PRECEDENCE); 348 visit(instruction, JSPrecedence.ASSIGNMENT_PRECEDENCE);
349 } 349 }
350 350
351 void use(HInstruction argument, int expectedPrecedence) { 351 void use(HInstruction argument, int expectedPrecedenceForArgument) {
352 if (isGenerateAtUseSite(argument)) { 352 if (isGenerateAtUseSite(argument)) {
353 visit(argument, expectedPrecedence); 353 visit(argument, expectedPrecedenceForArgument);
354 } else if (argument is HIntegerCheck) { 354 } else if (argument is HIntegerCheck) {
355 HIntegerCheck instruction = argument; 355 HIntegerCheck instruction = argument;
356 use(instruction.value, expectedPrecedence); 356 use(instruction.value, expectedPrecedenceForArgument);
357 } else if (argument is HBoundsCheck) { 357 } else if (argument is HBoundsCheck) {
358 HBoundsCheck instruction = argument; 358 HBoundsCheck instruction = argument;
359 use(instruction.index, expectedPrecedence); 359 use(instruction.index, expectedPrecedenceForArgument);
360 } else if (argument is HTypeGuard) { 360 } else if (argument is HTypeGuard) {
361 HTypeGuard instruction = argument; 361 HTypeGuard instruction = argument;
362 use(instruction.guarded, expectedPrecedence); 362 use(instruction.guarded, expectedPrecedenceForArgument);
363 } else { 363 } else {
364 buffer.add(temporary(argument)); 364 buffer.add(temporary(argument));
365 } 365 }
366 } 366 }
367 367
368 visit(HInstruction node, int expectedPrecedence) { 368 visit(HInstruction node, int expectedPrecedenceForNode) {
369 int oldPrecedence = this.expectedPrecedence; 369 int oldPrecedence = this.expectedPrecedence;
370 this.expectedPrecedence = expectedPrecedence; 370 this.expectedPrecedence = expectedPrecedenceForNode;
371 node.accept(this); 371 node.accept(this);
372 this.expectedPrecedence = oldPrecedence; 372 this.expectedPrecedence = oldPrecedence;
373 } 373 }
374 374
375 void continueAsBreak(LabelElement target) { 375 void continueAsBreak(LabelElement target) {
376 addIndentation(); 376 addIndentation();
377 buffer.add("break "); 377 buffer.add("break ");
378 writeContinueLabel(target); 378 writeContinueLabel(target);
379 buffer.add(";\n"); 379 buffer.add(";\n");
380 } 380 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 TargetElement target = info.target; 472 TargetElement target = info.target;
473 if (target !== null && target.isContinueTarget) { 473 if (target !== null && target.isContinueTarget) {
474 addIndentation(); 474 addIndentation();
475 for (LabelElement label in info.labels) { 475 for (LabelElement label in info.labels) {
476 if (label.isContinueTarget) { 476 if (label.isContinueTarget) {
477 writeContinueLabel(label); 477 writeContinueLabel(label);
478 buffer.add(":"); 478 buffer.add(":");
479 continueAction[label] = continueAsBreak; 479 continueAction[label] = continueAsBreak;
480 } 480 }
481 } 481 }
482 addImplicitContinueLabel(); 482 writeImplicitContinueLabel(target);
483 buffer.add(":{\n"); 483 buffer.add(":{\n");
484 continueAction[info.target] = implicitContinueAsBreak; 484 continueAction[info.target] = implicitContinueAsBreak;
485 indent++; 485 indent++;
486 visitSubGraph(info.body); 486 visitSubGraph(info.body);
487 indent--; 487 indent--;
488 addIndentation(); 488 addIndentation();
489 buffer.add("}\n"); 489 buffer.add("}\n");
490 continueAction.remove(info.target); 490 continueAction.remove(info.target);
491 for (LabelElement label in info.labels) { 491 for (LabelElement label in info.labels) {
492 if (label.isContinueTarget) { 492 if (label.isContinueTarget) {
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 1789
1790 1790
1791 void beginLoop(HBasicBlock block) { 1791 void beginLoop(HBasicBlock block) {
1792 // TODO(ngeoffray): Don't put labels on loops that don't bailout. 1792 // TODO(ngeoffray): Don't put labels on loops that don't bailout.
1793 String newLabel = pushLabel(); 1793 String newLabel = pushLabel();
1794 if (block.hasGuards()) { 1794 if (block.hasGuards()) {
1795 startBailoutCase(block.guards, const <HTypeGuard>[]); 1795 startBailoutCase(block.guards, const <HTypeGuard>[]);
1796 } 1796 }
1797 1797
1798 addIndentation(); 1798 addIndentation();
1799 for (SourceString label in block.loopInformation.labels) { 1799 for (LabelElement label in block.loopInformation.labels) {
1800 writeLabel(label); 1800 writeLabel(label);
1801 buffer.add(":"); 1801 buffer.add(":");
1802 } 1802 }
1803 buffer.add('$newLabel: while (true) {\n'); 1803 buffer.add('$newLabel: while (true) {\n');
1804 indent++; 1804 indent++;
1805 1805
1806 if (block.hasGuards()) { 1806 if (block.hasGuards()) {
1807 startBailoutSwitch(); 1807 startBailoutSwitch();
1808 } 1808 }
1809 } 1809 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 startBailoutSwitch(); 1882 startBailoutSwitch();
1883 } 1883 }
1884 } 1884 }
1885 1885
1886 void endElse(HIf node) { 1886 void endElse(HIf node) {
1887 if (node.elseBlock.hasGuards()) { 1887 if (node.elseBlock.hasGuards()) {
1888 endBailoutSwitch(); 1888 endBailoutSwitch();
1889 } 1889 }
1890 } 1890 }
1891 } 1891 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698