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 part of js_backend; | 5 part of js_backend; |
6 | 6 |
7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
8 | 8 |
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 ClassElement jsBoolClass; | 187 ClassElement jsBoolClass; |
188 ClassElement jsPlainJavaScriptObjectClass; | 188 ClassElement jsPlainJavaScriptObjectClass; |
189 ClassElement jsUnknownJavaScriptObjectClass; | 189 ClassElement jsUnknownJavaScriptObjectClass; |
190 | 190 |
191 ClassElement jsIndexableClass; | 191 ClassElement jsIndexableClass; |
192 ClassElement jsMutableIndexableClass; | 192 ClassElement jsMutableIndexableClass; |
193 | 193 |
194 ClassElement jsMutableArrayClass; | 194 ClassElement jsMutableArrayClass; |
195 ClassElement jsFixedArrayClass; | 195 ClassElement jsFixedArrayClass; |
196 ClassElement jsExtendableArrayClass; | 196 ClassElement jsExtendableArrayClass; |
| 197 ClassElement jsPositiveIntClass; |
197 ClassElement jsUInt32Class; | 198 ClassElement jsUInt32Class; |
198 ClassElement jsUInt31Class; | 199 ClassElement jsUInt31Class; |
199 | 200 |
200 Element jsIndexableLength; | 201 Element jsIndexableLength; |
201 Element jsArrayTypedConstructor; | 202 Element jsArrayTypedConstructor; |
202 Element jsArrayRemoveLast; | 203 Element jsArrayRemoveLast; |
203 Element jsArrayAdd; | 204 Element jsArrayAdd; |
204 Element jsStringSplit; | 205 Element jsStringSplit; |
205 Element jsStringToString; | 206 Element jsStringToString; |
206 Element jsStringOperatorAdd; | 207 Element jsStringOperatorAdd; |
(...skipping 17 matching lines...) Expand all Loading... |
224 * interceptor. See declaration of `mapTypeToInterceptor` in | 225 * interceptor. See declaration of `mapTypeToInterceptor` in |
225 * `interceptors.dart`. | 226 * `interceptors.dart`. |
226 */ | 227 */ |
227 Element mapTypeToInterceptor; | 228 Element mapTypeToInterceptor; |
228 | 229 |
229 TypeMask get stringType => compiler.typesTask.stringType; | 230 TypeMask get stringType => compiler.typesTask.stringType; |
230 TypeMask get doubleType => compiler.typesTask.doubleType; | 231 TypeMask get doubleType => compiler.typesTask.doubleType; |
231 TypeMask get intType => compiler.typesTask.intType; | 232 TypeMask get intType => compiler.typesTask.intType; |
232 TypeMask get uint32Type => compiler.typesTask.uint32Type; | 233 TypeMask get uint32Type => compiler.typesTask.uint32Type; |
233 TypeMask get uint31Type => compiler.typesTask.uint31Type; | 234 TypeMask get uint31Type => compiler.typesTask.uint31Type; |
| 235 TypeMask get positiveIntType => compiler.typesTask.positiveIntType; |
234 TypeMask get numType => compiler.typesTask.numType; | 236 TypeMask get numType => compiler.typesTask.numType; |
235 TypeMask get boolType => compiler.typesTask.boolType; | 237 TypeMask get boolType => compiler.typesTask.boolType; |
236 TypeMask get dynamicType => compiler.typesTask.dynamicType; | 238 TypeMask get dynamicType => compiler.typesTask.dynamicType; |
237 TypeMask get nullType => compiler.typesTask.nullType; | 239 TypeMask get nullType => compiler.typesTask.nullType; |
238 TypeMask get emptyType => const TypeMask.nonNullEmpty(); | 240 TypeMask get emptyType => const TypeMask.nonNullEmpty(); |
239 TypeMask indexablePrimitiveType; | 241 TypeMask indexablePrimitiveType; |
240 TypeMask readableArrayType; | 242 TypeMask readableArrayType; |
241 TypeMask mutableArrayType; | 243 TypeMask mutableArrayType; |
242 TypeMask fixedArrayType; | 244 TypeMask fixedArrayType; |
243 TypeMask extendableArrayType; | 245 TypeMask extendableArrayType; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 inlineCache.markAsNonInlinable(getInterceptorMethod, insideLoop: true); | 575 inlineCache.markAsNonInlinable(getInterceptorMethod, insideLoop: true); |
574 | 576 |
575 List<ClassElement> classes = [ | 577 List<ClassElement> classes = [ |
576 jsInterceptorClass = | 578 jsInterceptorClass = |
577 compiler.findInterceptor('Interceptor'), | 579 compiler.findInterceptor('Interceptor'), |
578 jsStringClass = compiler.findInterceptor('JSString'), | 580 jsStringClass = compiler.findInterceptor('JSString'), |
579 jsArrayClass = compiler.findInterceptor('JSArray'), | 581 jsArrayClass = compiler.findInterceptor('JSArray'), |
580 // The int class must be before the double class, because the | 582 // The int class must be before the double class, because the |
581 // emitter relies on this list for the order of type checks. | 583 // emitter relies on this list for the order of type checks. |
582 jsIntClass = compiler.findInterceptor('JSInt'), | 584 jsIntClass = compiler.findInterceptor('JSInt'), |
| 585 jsPositiveIntClass = compiler.findInterceptor('JSPositiveInt'), |
583 jsUInt32Class = compiler.findInterceptor('JSUInt32'), | 586 jsUInt32Class = compiler.findInterceptor('JSUInt32'), |
584 jsUInt31Class = compiler.findInterceptor('JSUInt31'), | 587 jsUInt31Class = compiler.findInterceptor('JSUInt31'), |
585 jsDoubleClass = compiler.findInterceptor('JSDouble'), | 588 jsDoubleClass = compiler.findInterceptor('JSDouble'), |
586 jsNumberClass = compiler.findInterceptor('JSNumber'), | 589 jsNumberClass = compiler.findInterceptor('JSNumber'), |
587 jsNullClass = compiler.findInterceptor('JSNull'), | 590 jsNullClass = compiler.findInterceptor('JSNull'), |
588 jsBoolClass = compiler.findInterceptor('JSBool'), | 591 jsBoolClass = compiler.findInterceptor('JSBool'), |
589 jsMutableArrayClass = compiler.findInterceptor('JSMutableArray'), | 592 jsMutableArrayClass = compiler.findInterceptor('JSMutableArray'), |
590 jsFixedArrayClass = compiler.findInterceptor('JSFixedArray'), | 593 jsFixedArrayClass = compiler.findInterceptor('JSFixedArray'), |
591 jsExtendableArrayClass = compiler.findInterceptor('JSExtendableArray'), | 594 jsExtendableArrayClass = compiler.findInterceptor('JSExtendableArray'), |
592 jsPlainJavaScriptObjectClass = | 595 jsPlainJavaScriptObjectClass = |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 } else if (cls == compiler.listClass | 849 } else if (cls == compiler.listClass |
847 || cls == jsArrayClass | 850 || cls == jsArrayClass |
848 || cls == jsFixedArrayClass | 851 || cls == jsFixedArrayClass |
849 || cls == jsExtendableArrayClass) { | 852 || cls == jsExtendableArrayClass) { |
850 addInterceptors(jsArrayClass, enqueuer, elements); | 853 addInterceptors(jsArrayClass, enqueuer, elements); |
851 addInterceptors(jsMutableArrayClass, enqueuer, elements); | 854 addInterceptors(jsMutableArrayClass, enqueuer, elements); |
852 addInterceptors(jsFixedArrayClass, enqueuer, elements); | 855 addInterceptors(jsFixedArrayClass, enqueuer, elements); |
853 addInterceptors(jsExtendableArrayClass, enqueuer, elements); | 856 addInterceptors(jsExtendableArrayClass, enqueuer, elements); |
854 } else if (cls == compiler.intClass || cls == jsIntClass) { | 857 } else if (cls == compiler.intClass || cls == jsIntClass) { |
855 addInterceptors(jsIntClass, enqueuer, elements); | 858 addInterceptors(jsIntClass, enqueuer, elements); |
| 859 addInterceptors(jsPositiveIntClass, enqueuer, elements); |
856 addInterceptors(jsUInt32Class, enqueuer, elements); | 860 addInterceptors(jsUInt32Class, enqueuer, elements); |
857 addInterceptors(jsUInt31Class, enqueuer, elements); | 861 addInterceptors(jsUInt31Class, enqueuer, elements); |
858 addInterceptors(jsNumberClass, enqueuer, elements); | 862 addInterceptors(jsNumberClass, enqueuer, elements); |
859 } else if (cls == compiler.doubleClass || cls == jsDoubleClass) { | 863 } else if (cls == compiler.doubleClass || cls == jsDoubleClass) { |
860 addInterceptors(jsDoubleClass, enqueuer, elements); | 864 addInterceptors(jsDoubleClass, enqueuer, elements); |
861 addInterceptors(jsNumberClass, enqueuer, elements); | 865 addInterceptors(jsNumberClass, enqueuer, elements); |
862 } else if (cls == compiler.boolClass || cls == jsBoolClass) { | 866 } else if (cls == compiler.boolClass || cls == jsBoolClass) { |
863 addInterceptors(jsBoolClass, enqueuer, elements); | 867 addInterceptors(jsBoolClass, enqueuer, elements); |
864 } else if (cls == compiler.nullClass || cls == jsNullClass) { | 868 } else if (cls == compiler.nullClass || cls == jsNullClass) { |
865 addInterceptors(jsNullClass, enqueuer, elements); | 869 addInterceptors(jsNullClass, enqueuer, elements); |
866 } else if (cls == compiler.numClass || cls == jsNumberClass) { | 870 } else if (cls == compiler.numClass || cls == jsNumberClass) { |
867 addInterceptors(jsIntClass, enqueuer, elements); | 871 addInterceptors(jsIntClass, enqueuer, elements); |
| 872 addInterceptors(jsPositiveIntClass, enqueuer, elements); |
868 addInterceptors(jsUInt32Class, enqueuer, elements); | 873 addInterceptors(jsUInt32Class, enqueuer, elements); |
869 addInterceptors(jsUInt31Class, enqueuer, elements); | 874 addInterceptors(jsUInt31Class, enqueuer, elements); |
870 addInterceptors(jsDoubleClass, enqueuer, elements); | 875 addInterceptors(jsDoubleClass, enqueuer, elements); |
871 addInterceptors(jsNumberClass, enqueuer, elements); | 876 addInterceptors(jsNumberClass, enqueuer, elements); |
872 } else if (cls == jsPlainJavaScriptObjectClass) { | 877 } else if (cls == jsPlainJavaScriptObjectClass) { |
873 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, elements); | 878 addInterceptors(jsPlainJavaScriptObjectClass, enqueuer, elements); |
874 } else if (cls == jsUnknownJavaScriptObjectClass) { | 879 } else if (cls == jsUnknownJavaScriptObjectClass) { |
875 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, elements); | 880 addInterceptors(jsUnknownJavaScriptObjectClass, enqueuer, elements); |
876 } else if (Elements.isNativeOrExtendsNative(cls)) { | 881 } else if (Elements.isNativeOrExtendsNative(cls)) { |
877 addInterceptorsForNativeClassMembers(cls, enqueuer); | 882 addInterceptorsForNativeClassMembers(cls, enqueuer); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1419 if (nativeCheckOnly) return null; | 1424 if (nativeCheckOnly) return null; |
1420 return typeCast | 1425 return typeCast |
1421 ? 'numTypeCast' | 1426 ? 'numTypeCast' |
1422 : 'numTypeCheck'; | 1427 : 'numTypeCheck'; |
1423 } else if (element == jsBoolClass || element == compiler.boolClass) { | 1428 } else if (element == jsBoolClass || element == compiler.boolClass) { |
1424 if (nativeCheckOnly) return null; | 1429 if (nativeCheckOnly) return null; |
1425 return typeCast | 1430 return typeCast |
1426 ? 'boolTypeCast' | 1431 ? 'boolTypeCast' |
1427 : 'boolTypeCheck'; | 1432 : 'boolTypeCheck'; |
1428 } else if (element == jsIntClass || element == compiler.intClass | 1433 } else if (element == jsIntClass || element == compiler.intClass |
1429 || element == jsUInt32Class || element == jsUInt31Class) { | 1434 || element == jsUInt32Class || element == jsUInt31Class |
| 1435 || element == jsPositiveIntClass) { |
1430 if (nativeCheckOnly) return null; | 1436 if (nativeCheckOnly) return null; |
1431 return typeCast | 1437 return typeCast |
1432 ? 'intTypeCast' | 1438 ? 'intTypeCast' |
1433 : 'intTypeCheck'; | 1439 : 'intTypeCheck'; |
1434 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { | 1440 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { |
1435 if (nativeCheck) { | 1441 if (nativeCheck) { |
1436 return typeCast | 1442 return typeCast |
1437 ? 'numberOrStringSuperNativeTypeCast' | 1443 ? 'numberOrStringSuperNativeTypeCast' |
1438 : 'numberOrStringSuperNativeTypeCheck'; | 1444 : 'numberOrStringSuperNativeTypeCheck'; |
1439 } else { | 1445 } else { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 return compiler.findHelper("throwCyclicInit"); | 1645 return compiler.findHelper("throwCyclicInit"); |
1640 } | 1646 } |
1641 | 1647 |
1642 bool isNullImplementation(ClassElement cls) { | 1648 bool isNullImplementation(ClassElement cls) { |
1643 return cls == jsNullClass; | 1649 return cls == jsNullClass; |
1644 } | 1650 } |
1645 | 1651 |
1646 ClassElement get intImplementation => jsIntClass; | 1652 ClassElement get intImplementation => jsIntClass; |
1647 ClassElement get uint32Implementation => jsUInt32Class; | 1653 ClassElement get uint32Implementation => jsUInt32Class; |
1648 ClassElement get uint31Implementation => jsUInt31Class; | 1654 ClassElement get uint31Implementation => jsUInt31Class; |
| 1655 ClassElement get positiveIntImplementation => jsPositiveIntClass; |
1649 ClassElement get doubleImplementation => jsDoubleClass; | 1656 ClassElement get doubleImplementation => jsDoubleClass; |
1650 ClassElement get numImplementation => jsNumberClass; | 1657 ClassElement get numImplementation => jsNumberClass; |
1651 ClassElement get stringImplementation => jsStringClass; | 1658 ClassElement get stringImplementation => jsStringClass; |
1652 ClassElement get listImplementation => jsArrayClass; | 1659 ClassElement get listImplementation => jsArrayClass; |
1653 ClassElement get constListImplementation => jsArrayClass; | 1660 ClassElement get constListImplementation => jsArrayClass; |
1654 ClassElement get fixedListImplementation => jsFixedArrayClass; | 1661 ClassElement get fixedListImplementation => jsFixedArrayClass; |
1655 ClassElement get growableListImplementation => jsExtendableArrayClass; | 1662 ClassElement get growableListImplementation => jsExtendableArrayClass; |
1656 ClassElement get mapImplementation => mapLiteralClass; | 1663 ClassElement get mapImplementation => mapLiteralClass; |
1657 ClassElement get constMapImplementation => constMapLiteralClass; | 1664 ClassElement get constMapImplementation => constMapLiteralClass; |
1658 ClassElement get typeImplementation => typeLiteralClass; | 1665 ClassElement get typeImplementation => typeLiteralClass; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1989 copy(constant.values); | 1996 copy(constant.values); |
1990 copy(constant.protoValue); | 1997 copy(constant.protoValue); |
1991 copy(constant); | 1998 copy(constant); |
1992 } | 1999 } |
1993 | 2000 |
1994 void visitConstructed(ConstructedConstant constant) { | 2001 void visitConstructed(ConstructedConstant constant) { |
1995 copy(constant.fields); | 2002 copy(constant.fields); |
1996 copy(constant); | 2003 copy(constant); |
1997 } | 2004 } |
1998 } | 2005 } |
OLD | NEW |