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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); | 675 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); |
| 676 buffer.add(';\n'); | 676 buffer.add(';\n'); |
| 677 } | 677 } |
| 678 } | 678 } |
| 679 | 679 |
| 680 visitThis(HThis node) { | 680 visitThis(HThis node) { |
| 681 buffer.add('this'); | 681 buffer.add('this'); |
| 682 } | 682 } |
| 683 | 683 |
| 684 visitThrow(HThrow node) { | 684 visitThrow(HThrow node) { |
| 685 buffer.add('throw '); | 685 Element toStringHelper = |
| 686 use(node.inputs[0], JSPrecedence.EXPRESSION_PRECEDENCE); | 686 compiler.findHelper(new SourceString(@'builtin$toString$0')); |
| 687 compiler.registerStaticUse(toStringHelper); | |
|
ngeoffray
2012/02/22 11:12:36
Please add a comment that you're adding toString b
ahe
2012/02/22 21:51:24
Done.
| |
| 688 generateThrowWithHelper('captureStackTrace', node.inputs[0]); | |
| 687 buffer.add(';\n'); | 689 buffer.add(';\n'); |
| 688 } | 690 } |
| 689 | 691 |
| 690 visitBoundsCheck(HBoundsCheck node) { | 692 visitBoundsCheck(HBoundsCheck node) { |
| 691 buffer.add('if ('); | 693 buffer.add('if ('); |
| 692 use(node.index, JSPrecedence.RELATIONAL_PRECEDENCE); | 694 use(node.index, JSPrecedence.RELATIONAL_PRECEDENCE); |
| 693 buffer.add(' < 0 || '); | 695 buffer.add(' < 0 || '); |
| 694 use(node.index, JSPrecedence.RELATIONAL_PRECEDENCE); | 696 use(node.index, JSPrecedence.RELATIONAL_PRECEDENCE); |
| 695 buffer.add(' >= '); | 697 buffer.add(' >= '); |
| 696 use(node.length, JSPrecedence.SHIFT_PRECEDENCE); | 698 use(node.length, JSPrecedence.SHIFT_PRECEDENCE); |
| 697 buffer.add(") "); | 699 buffer.add(") "); |
| 698 generateFail('ioore', node.index); | 700 generateThrowWithHelper('ioore', node.index); |
| 699 } | 701 } |
| 700 | 702 |
| 701 visitIntegerCheck(HIntegerCheck node) { | 703 visitIntegerCheck(HIntegerCheck node) { |
| 702 buffer.add('if ('); | 704 buffer.add('if ('); |
| 703 use(node.value, JSPrecedence.EQUALITY_PRECEDENCE); | 705 use(node.value, JSPrecedence.EQUALITY_PRECEDENCE); |
| 704 buffer.add(' !== ('); | 706 buffer.add(' !== ('); |
| 705 use(node.value, JSPrecedence.BITWISE_OR_PRECEDENCE); | 707 use(node.value, JSPrecedence.BITWISE_OR_PRECEDENCE); |
| 706 buffer.add(" | 0)) "); | 708 buffer.add(" | 0)) "); |
| 707 generateFail('iae', node.value); | 709 generateThrowWithHelper('iae', node.value); |
| 708 } | 710 } |
| 709 | 711 |
| 710 void generateFail(String helperName, HInstruction argument) { | 712 void generateThrowWithHelper(String helperName, HInstruction argument) { |
| 711 Element helper = compiler.findHelper(new SourceString(helperName)); | 713 Element helper = compiler.findHelper(new SourceString(helperName)); |
| 712 compiler.registerStaticUse(helper); | 714 compiler.registerStaticUse(helper); |
| 713 buffer.add('throw '); | 715 buffer.add('throw '); |
| 714 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE); | 716 beginExpression(JSPrecedence.EXPRESSION_PRECEDENCE); |
| 715 beginExpression(JSPrecedence.CALL_PRECEDENCE); | 717 beginExpression(JSPrecedence.CALL_PRECEDENCE); |
| 716 buffer.add(compiler.namer.isolateAccess(helper)); | 718 buffer.add(compiler.namer.isolateAccess(helper)); |
| 717 visitArguments([null, argument]); | 719 visitArguments([null, argument]); |
| 718 endExpression(JSPrecedence.CALL_PRECEDENCE); | 720 endExpression(JSPrecedence.CALL_PRECEDENCE); |
| 719 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE); | 721 endExpression(JSPrecedence.EXPRESSION_PRECEDENCE); |
| 720 } | 722 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 } else if (element == coreLibrary.find(const SourceString('bool'))) { | 886 } else if (element == coreLibrary.find(const SourceString('bool'))) { |
| 885 checkBool(input, '==='); | 887 checkBool(input, '==='); |
| 886 } else if (element == coreLibrary.find(const SourceString('int'))) { | 888 } else if (element == coreLibrary.find(const SourceString('int'))) { |
| 887 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); | 889 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); |
| 888 checkNum(input, '==='); | 890 checkNum(input, '==='); |
| 889 buffer.add(' && '); | 891 buffer.add(' && '); |
| 890 checkInt(input, '==='); | 892 checkInt(input, '==='); |
| 891 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); | 893 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); |
| 892 } else { | 894 } else { |
| 893 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); | 895 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); |
| 896 if (element == coreLibrary.find(const SourceString('Comparable'))) { | |
| 897 checkString(input, '==='); | |
| 898 buffer.add(' || '); | |
| 899 } | |
| 900 if (element == coreLibrary.find(const SourceString('Hashable'))) { | |
| 901 checkString(input, '==='); | |
| 902 buffer.add(' || '); | |
| 903 } | |
| 904 if (element == coreLibrary.find(const SourceString('Pattern'))) { | |
|
ngeoffray
2012/02/22 11:12:36
Please merge the conditions into one if. Also add
ahe
2012/02/22 21:51:24
Done.
| |
| 905 checkString(input, '==='); | |
| 906 buffer.add(' || '); | |
| 907 } | |
| 894 checkObject(input, '==='); | 908 checkObject(input, '==='); |
| 895 buffer.add(' && '); | 909 buffer.add(' && '); |
| 896 int precedence = JSPrecedence.PREFIX_PRECEDENCE; | 910 int precedence = JSPrecedence.PREFIX_PRECEDENCE; |
| 897 bool endParen = false; | 911 bool endParen = false; |
| 898 if (element == coreLibrary.find(const SourceString('List'))) { | 912 if (element == coreLibrary.find(const SourceString('List'))) { |
| 899 buffer.add("("); | 913 buffer.add("("); |
| 900 endParen = true; | 914 endParen = true; |
| 901 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); | 915 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); |
| 902 checkObject(input, '==='); | 916 checkObject(input, '==='); |
| 903 buffer.add(' && '); | 917 buffer.add(' && '); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1262 startBailoutSwitch(); | 1276 startBailoutSwitch(); |
| 1263 } | 1277 } |
| 1264 } | 1278 } |
| 1265 | 1279 |
| 1266 void endElse(HIf node) { | 1280 void endElse(HIf node) { |
| 1267 if (node.elseBlock.hasBailouts()) { | 1281 if (node.elseBlock.hasBailouts()) { |
| 1268 endBailoutSwitch(); | 1282 endBailoutSwitch(); |
| 1269 } | 1283 } |
| 1270 } | 1284 } |
| 1271 } | 1285 } |
| OLD | NEW |