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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 } | 927 } |
928 | 928 |
929 void checkArray(HInstruction input, String cmp) { | 929 void checkArray(HInstruction input, String cmp) { |
930 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 930 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
931 use(input, JSPrecedence.MEMBER_PRECEDENCE); | 931 use(input, JSPrecedence.MEMBER_PRECEDENCE); |
932 buffer.add('.constructor $cmp Array'); | 932 buffer.add('.constructor $cmp Array'); |
933 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); | 933 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); |
934 } | 934 } |
935 | 935 |
936 void visitIs(HIs node) { | 936 void visitIs(HIs node) { |
937 ClassElement element = node.typeExpression; | 937 Element element = node.typeExpression; |
938 LibraryElement coreLibrary = compiler.coreLibrary; | 938 LibraryElement coreLibrary = compiler.coreLibrary; |
939 ClassElement objectClass = coreLibrary.find(const SourceString('Object')); | 939 ClassElement objectClass = coreLibrary.find(const SourceString('Object')); |
940 HInstruction input = node.expression; | 940 HInstruction input = node.expression; |
941 if (node.nullOk) { | 941 if (node.nullOk) { |
942 use(input, JSPrecedence.EQUALITY_PRECEDENCE); | 942 use(input, JSPrecedence.EQUALITY_PRECEDENCE); |
943 buffer.add(' === (void 0) || ('); | 943 buffer.add(' === (void 0) || ('); |
944 } | 944 } |
945 if (element == objectClass) { | 945 if (element == objectClass) { |
946 // TODO(ahe): This probably belongs in the constant folder. | 946 // TODO(ahe): This probably belongs in the constant folder. |
947 buffer.add('true'); | 947 buffer.add('true'); |
(...skipping 21 matching lines...) Expand all Loading... |
969 buffer.add(' && '); | 969 buffer.add(' && '); |
970 int precedence = JSPrecedence.PREFIX_PRECEDENCE; | 970 int precedence = JSPrecedence.PREFIX_PRECEDENCE; |
971 bool endParen = false; | 971 bool endParen = false; |
972 if (isListOrSupertype(element)) { | 972 if (isListOrSupertype(element)) { |
973 buffer.add("("); | 973 buffer.add("("); |
974 endParen = true; | 974 endParen = true; |
975 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); | 975 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); |
976 checkArray(input, '==='); | 976 checkArray(input, '==='); |
977 buffer.add(' || '); | 977 buffer.add(' || '); |
978 precedence = JSPrecedence.LOGICAL_OR_PRECEDENCE; | 978 precedence = JSPrecedence.LOGICAL_OR_PRECEDENCE; |
979 } else if (element.isNative() || isSupertypeOfNativeClass(element)) { | 979 } else if (element.isClass() && (element.dynamic.isNative() |
| 980 || isSupertypeOfNativeClass(element))) { |
980 buffer.add("("); | 981 buffer.add("("); |
981 endParen = true; | 982 endParen = true; |
982 } else { | 983 } else { |
983 beginExpression(precedence); | 984 beginExpression(precedence); |
984 } | 985 } |
985 buffer.add('!!'); | 986 buffer.add('!!'); |
986 use(input, JSPrecedence.MEMBER_PRECEDENCE); | 987 use(input, JSPrecedence.MEMBER_PRECEDENCE); |
987 buffer.add('.'); | 988 buffer.add('.'); |
988 buffer.add(compiler.namer.operatorIs(node.typeExpression)); | 989 buffer.add(compiler.namer.operatorIs(node.typeExpression)); |
989 if (element.isNative() || isSupertypeOfNativeClass(element)) { | 990 if (element.isNative() || isSupertypeOfNativeClass(element)) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 startBailoutSwitch(); | 1392 startBailoutSwitch(); |
1392 } | 1393 } |
1393 } | 1394 } |
1394 | 1395 |
1395 void endElse(HIf node) { | 1396 void endElse(HIf node) { |
1396 if (node.elseBlock.hasBailouts()) { | 1397 if (node.elseBlock.hasBailouts()) { |
1397 endBailoutSwitch(); | 1398 endBailoutSwitch(); |
1398 } | 1399 } |
1399 } | 1400 } |
1400 } | 1401 } |
OLD | NEW |