| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 buffer.add(';\n'); | 626 buffer.add(';\n'); |
| 627 } | 627 } |
| 628 | 628 |
| 629 visitBoundsCheck(HBoundsCheck node) { | 629 visitBoundsCheck(HBoundsCheck node) { |
| 630 buffer.add('if ('); | 630 buffer.add('if ('); |
| 631 use(node.index); | 631 use(node.index); |
| 632 buffer.add(' < 0 || '); | 632 buffer.add(' < 0 || '); |
| 633 use(node.index); | 633 use(node.index); |
| 634 buffer.add(' >= '); | 634 buffer.add(' >= '); |
| 635 use(node.length); | 635 use(node.length); |
| 636 buffer.add(") throw 'Out of bounds'"); | 636 buffer.add(") "); |
| 637 generateFail('ioore', node.index); |
| 637 } | 638 } |
| 638 | 639 |
| 639 visitIntegerCheck(HIntegerCheck node) { | 640 visitIntegerCheck(HIntegerCheck node) { |
| 640 buffer.add('if ('); | 641 buffer.add('if ('); |
| 641 use(node.value); | 642 use(node.value); |
| 642 buffer.add(' !== ('); | 643 buffer.add(' !== ('); |
| 643 use(node.value); | 644 use(node.value); |
| 644 buffer.add(" | 0)) throw 'Illegal argument'"); | 645 buffer.add(" | 0)) "); |
| 646 generateFail('iae', node.value); |
| 647 } |
| 648 |
| 649 void generateFail(String helperName, HInstruction argument) { |
| 650 Element helper = compiler.findHelper(new SourceString(helperName)); |
| 651 compiler.registerStaticUse(helper); |
| 652 buffer.add(compiler.namer.isolateAccess(helper)); |
| 653 buffer.add("("); |
| 654 use(argument); |
| 655 buffer.add(")"); |
| 645 } | 656 } |
| 646 | 657 |
| 647 void addIndentation() { | 658 void addIndentation() { |
| 648 for (int i = 0; i < indent; i++) { | 659 for (int i = 0; i < indent; i++) { |
| 649 buffer.add(' '); | 660 buffer.add(' '); |
| 650 } | 661 } |
| 651 } | 662 } |
| 652 | 663 |
| 653 void visitStatic(HStatic node) { | 664 void visitStatic(HStatic node) { |
| 654 compiler.registerStaticUse(node.element); | 665 compiler.registerStaticUse(node.element); |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 startBailoutSwitch(); | 1156 startBailoutSwitch(); |
| 1146 } | 1157 } |
| 1147 } | 1158 } |
| 1148 | 1159 |
| 1149 void endElse(HIf node) { | 1160 void endElse(HIf node) { |
| 1150 if (node.elseBlock.hasBailouts()) { | 1161 if (node.elseBlock.hasBailouts()) { |
| 1151 endBailoutSwitch(); | 1162 endBailoutSwitch(); |
| 1152 } | 1163 } |
| 1153 } | 1164 } |
| 1154 } | 1165 } |
| OLD | NEW |