| 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 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 | 816 |
| 817 void checkArray(HInstruction input, String cmp) { | 817 void checkArray(HInstruction input, String cmp) { |
| 818 use(input); | 818 use(input); |
| 819 buffer.add('.constructor $cmp Array'); | 819 buffer.add('.constructor $cmp Array'); |
| 820 } | 820 } |
| 821 | 821 |
| 822 void visitIs(HIs node) { | 822 void visitIs(HIs node) { |
| 823 ClassElement element = node.typeExpression; | 823 ClassElement element = node.typeExpression; |
| 824 LibraryElement coreLibrary = compiler.coreLibrary; | 824 LibraryElement coreLibrary = compiler.coreLibrary; |
| 825 HInstruction input = node.expression; | 825 HInstruction input = node.expression; |
| 826 buffer.add('('); |
| 826 if (element == coreLibrary.find(const SourceString('Object'))) { | 827 if (element == coreLibrary.find(const SourceString('Object'))) { |
| 827 // TODO(ahe): This probably belongs in the constant folder. | 828 // TODO(ahe): This probably belongs in the constant folder. |
| 828 buffer.add('true'); | 829 buffer.add('true'); |
| 829 } else if (element == coreLibrary.find(const SourceString('String'))) { | 830 } else if (element == coreLibrary.find(const SourceString('String'))) { |
| 830 checkString(input, '==='); | 831 checkString(input, '==='); |
| 831 } else if (element == coreLibrary.find(const SourceString('double'))) { | 832 } else if (element == coreLibrary.find(const SourceString('double'))) { |
| 832 checkDouble(input, '==='); | 833 checkDouble(input, '==='); |
| 833 } else if (element == coreLibrary.find(const SourceString('num'))) { | 834 } else if (element == coreLibrary.find(const SourceString('num'))) { |
| 834 checkNum(input, '==='); | 835 checkNum(input, '==='); |
| 835 } else if (element == coreLibrary.find(const SourceString('bool'))) { | 836 } else if (element == coreLibrary.find(const SourceString('bool'))) { |
| 836 checkBool(input, '==='); | 837 checkBool(input, '==='); |
| 837 } else if (element == coreLibrary.find(const SourceString('int'))) { | 838 } else if (element == coreLibrary.find(const SourceString('int'))) { |
| 839 checkNum(input, '==='); |
| 840 buffer.add(' && '); |
| 838 checkInt(input, '==='); | 841 checkInt(input, '==='); |
| 839 } else { | 842 } else { |
| 840 if (element == coreLibrary.find(const SourceString('List'))) { | 843 if (element == coreLibrary.find(const SourceString('List'))) { |
| 841 checkArray(input, '==='); | 844 checkArray(input, '==='); |
| 842 buffer.add(' || '); | 845 buffer.add(' || '); |
| 843 } | 846 } |
| 844 buffer.add('!!('); | 847 buffer.add('!!('); |
| 845 use(input); | 848 use(input); |
| 846 buffer.add('.'); | 849 buffer.add('.'); |
| 847 buffer.add(compiler.namer.operatorIs(node.typeExpression)); | 850 buffer.add(compiler.namer.operatorIs(node.typeExpression)); |
| 848 buffer.add(')'); | 851 buffer.add(')'); |
| 849 } | 852 } |
| 853 buffer.add(')'); |
| 850 } | 854 } |
| 851 } | 855 } |
| 852 | 856 |
| 853 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { | 857 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { |
| 854 final List<HTypeGuard> guards; | 858 final List<HTypeGuard> guards; |
| 855 int state = 0; | 859 int state = 0; |
| 856 | 860 |
| 857 SsaOptimizedCodeGenerator(compiler, work, buffer, parameters, parameterNames) | 861 SsaOptimizedCodeGenerator(compiler, work, buffer, parameters, parameterNames) |
| 858 : super(compiler, work, buffer, parameters, parameterNames), | 862 : super(compiler, work, buffer, parameters, parameterNames), |
| 859 guards = <HTypeGuard>[]; | 863 guards = <HTypeGuard>[]; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 startBailoutSwitch(); | 1192 startBailoutSwitch(); |
| 1189 } | 1193 } |
| 1190 } | 1194 } |
| 1191 | 1195 |
| 1192 void endElse(HIf node) { | 1196 void endElse(HIf node) { |
| 1193 if (node.elseBlock.hasBailouts()) { | 1197 if (node.elseBlock.hasBailouts()) { |
| 1194 endBailoutSwitch(); | 1198 endBailoutSwitch(); |
| 1195 } | 1199 } |
| 1196 } | 1200 } |
| 1197 } | 1201 } |
| OLD | NEW |