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

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

Issue 9370020: Fully support try/catch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/nodes.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 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 visitTry(HTry node) { 353 visitTry(HTry node) {
354 addIndentation(); 354 addIndentation();
355 buffer.add('try {\n'); 355 buffer.add('try {\n');
356 indent++; 356 indent++;
357 List<HBasicBlock> successors = node.block.successors; 357 List<HBasicBlock> successors = node.block.successors;
358 visitBasicBlock(successors[0]); 358 visitBasicBlock(successors[0]);
359 indent--; 359 indent--;
360 360
361 if (node.finallyBlock != successors[1]) { 361 if (node.finallyBlock != successors[1]) {
362 // Printing the catch part.
362 addIndentation(); 363 addIndentation();
363 buffer.add('} catch (e) {\n'); 364 String name = temporary(node.exception);
365 parameterNames[node.exception.element] = name;
366 buffer.add('} catch ($name) {\n');
364 indent++; 367 indent++;
368 visitBasicBlock(successors[1]);
369 parameterNames.remove(node.exception.element);
370 indent--;
365 } 371 }
366 372
367 for (int i = 1; i < successors.length - 1; i++) { 373 if (node.finallyBlock != null) {
368 // TODO(ngeoffray): add the type check.
369 visitBasicBlock(successors[i]);
370 }
371
372 if (node.finallyBlock == null) {
373 // TODO(ngeoffray): add the type check.
374 visitBasicBlock(successors[successors.length - 1]);
375 } else {
376 addIndentation(); 374 addIndentation();
377 buffer.add('} finally {\n'); 375 buffer.add('} finally {\n');
378 indent++; 376 indent++;
379 visitBasicBlock(node.finallyBlock); 377 visitBasicBlock(node.finallyBlock);
380 } 378 }
381 indent--; 379 indent--;
382 addIndentation(); 380 addIndentation();
383 buffer.add('}\n'); 381 buffer.add('}\n');
384 } 382 }
385 383
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 if (node.typeExpression.name == const SourceString('Object')) { 790 if (node.typeExpression.name == const SourceString('Object')) {
793 // TODO(ahe): This probably belongs in the constant folder. 791 // TODO(ahe): This probably belongs in the constant folder.
794 if (node.expression.generateAtUseSite()) { 792 if (node.expression.generateAtUseSite()) {
795 buffer.add('(('); 793 buffer.add('((');
796 visit(node.expression); 794 visit(node.expression);
797 buffer.add('), true)'); 795 buffer.add('), true)');
798 } else { 796 } else {
799 buffer.add('true'); 797 buffer.add('true');
800 } 798 }
801 } else { 799 } else {
802 buffer.add('(('); 800 buffer.add('(!!(');
803 use(node.expression); 801 use(node.expression);
804 buffer.add(').'); 802 buffer.add(').');
805 buffer.add(compiler.namer.operatorIs(node.typeExpression)); 803 buffer.add(compiler.namer.operatorIs(node.typeExpression));
806 buffer.add(' === true)'); 804 buffer.add(')');
807 } 805 }
808 } 806 }
809 } 807 }
810 808
811 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { 809 class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
812 final List<HTypeGuard> guards; 810 final List<HTypeGuard> guards;
813 int state = 0; 811 int state = 0;
814 812
815 SsaOptimizedCodeGenerator(compiler, work, buffer, parameters, parameterNames) 813 SsaOptimizedCodeGenerator(compiler, work, buffer, parameters, parameterNames)
816 : super(compiler, work, buffer, parameters, parameterNames), 814 : super(compiler, work, buffer, parameters, parameterNames),
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 startBailoutSwitch(); 1146 startBailoutSwitch();
1149 } 1147 }
1150 } 1148 }
1151 1149
1152 void endElse(HIf node) { 1150 void endElse(HIf node) {
1153 if (node.elseBlock.hasBailouts()) { 1151 if (node.elseBlock.hasBailouts()) {
1154 endBailoutSwitch(); 1152 endBailoutSwitch();
1155 } 1153 }
1156 } 1154 }
1157 } 1155 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698