Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 assert(dominated[0] == currentBlock.successors[0]); | 349 assert(dominated[0] == currentBlock.successors[0]); |
| 350 visitBasicBlock(dominated[0]); | 350 visitBasicBlock(dominated[0]); |
| 351 } | 351 } |
| 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--; | |
| 360 | 359 |
| 361 if (node.finallyBlock != successors[1]) { | 360 if (node.finallyBlock != successors[1]) { |
| 361 indent--; | |
|
floitsch
2012/02/09 15:06:57
add comment that this is the catch part.
floitsch
2012/02/09 15:06:57
I would move the indent-- out of the if.
ngeoffray
2012/02/09 15:13:48
Done.
ngeoffray
2012/02/09 15:13:48
Done.
| |
| 362 addIndentation(); | 362 addIndentation(); |
| 363 buffer.add('} catch (e) {\n'); | 363 String name = temporary(node.exception); |
| 364 parameterNames[node.exception.element] = name; | |
| 365 buffer.add('} catch ($name) {\n'); | |
| 364 indent++; | 366 indent++; |
| 367 visitBasicBlock(successors[1]); | |
| 368 parameterNames.remove(node.exception.element); | |
| 365 } | 369 } |
| 366 | 370 |
| 367 for (int i = 1; i < successors.length - 1; i++) { | 371 if (node.finallyBlock != null) { |
| 368 // TODO(ngeoffray): add the type check. | 372 indent--; |
| 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(); | 373 addIndentation(); |
| 377 buffer.add('} finally {\n'); | 374 buffer.add('} finally {\n'); |
| 378 indent++; | 375 indent++; |
| 379 visitBasicBlock(node.finallyBlock); | 376 visitBasicBlock(node.finallyBlock); |
| 380 } | 377 } |
| 381 indent--; | 378 indent--; |
| 382 addIndentation(); | 379 addIndentation(); |
| 383 buffer.add('}\n'); | 380 buffer.add('}\n'); |
| 384 } | 381 } |
| 385 | 382 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 if (node.typeExpression.name == const SourceString('Object')) { | 789 if (node.typeExpression.name == const SourceString('Object')) { |
| 793 // TODO(ahe): This probably belongs in the constant folder. | 790 // TODO(ahe): This probably belongs in the constant folder. |
| 794 if (node.expression.generateAtUseSite()) { | 791 if (node.expression.generateAtUseSite()) { |
| 795 buffer.add('(('); | 792 buffer.add('(('); |
| 796 visit(node.expression); | 793 visit(node.expression); |
| 797 buffer.add('), true)'); | 794 buffer.add('), true)'); |
| 798 } else { | 795 } else { |
| 799 buffer.add('true'); | 796 buffer.add('true'); |
| 800 } | 797 } |
| 801 } else { | 798 } else { |
| 802 buffer.add('(('); | 799 buffer.add('(!!('); |
| 803 use(node.expression); | 800 use(node.expression); |
| 804 buffer.add(').'); | 801 buffer.add(').'); |
| 805 buffer.add(compiler.namer.operatorIs(node.typeExpression)); | 802 buffer.add(compiler.namer.operatorIs(node.typeExpression)); |
| 806 buffer.add(' === true)'); | 803 buffer.add(')'); |
| 807 } | 804 } |
| 808 } | 805 } |
| 809 } | 806 } |
| 810 | 807 |
| 811 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { | 808 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { |
| 812 final List<HTypeGuard> guards; | 809 final List<HTypeGuard> guards; |
| 813 int state = 0; | 810 int state = 0; |
| 814 | 811 |
| 815 SsaOptimizedCodeGenerator(compiler, work, buffer, parameters, parameterNames) | 812 SsaOptimizedCodeGenerator(compiler, work, buffer, parameters, parameterNames) |
| 816 : super(compiler, work, buffer, parameters, parameterNames), | 813 : super(compiler, work, buffer, parameters, parameterNames), |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 startBailoutSwitch(); | 1145 startBailoutSwitch(); |
| 1149 } | 1146 } |
| 1150 } | 1147 } |
| 1151 | 1148 |
| 1152 void endElse(HIf node) { | 1149 void endElse(HIf node) { |
| 1153 if (node.elseBlock.hasBailouts()) { | 1150 if (node.elseBlock.hasBailouts()) { |
| 1154 endBailoutSwitch(); | 1151 endBailoutSwitch(); |
| 1155 } | 1152 } |
| 1156 } | 1153 } |
| 1157 } | 1154 } |
| OLD | NEW |