| 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 typedef void Recompile(Element element); | 7 typedef void Recompile(Element element); |
| 8 | 8 |
| 9 class ReturnInfo { | 9 class ReturnInfo { |
| 10 HType returnType; | 10 HType returnType; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 : types = new List<HType>(length), | 72 : types = new List<HType>(length), |
| 73 namedArguments = null; | 73 namedArguments = null; |
| 74 HTypeList.withNamedArguments(int length, this.namedArguments) | 74 HTypeList.withNamedArguments(int length, this.namedArguments) |
| 75 : types = new List<HType>(length); | 75 : types = new List<HType>(length); |
| 76 const HTypeList.withAllUnknown() | 76 const HTypeList.withAllUnknown() |
| 77 : types = null, | 77 : types = null, |
| 78 namedArguments = null; | 78 namedArguments = null; |
| 79 | 79 |
| 80 factory HTypeList.fromStaticInvocation(HInvokeStatic node) { | 80 factory HTypeList.fromStaticInvocation(HInvokeStatic node) { |
| 81 bool allUnknown = true; | 81 bool allUnknown = true; |
| 82 for (int i = 1; i < node.inputs.length; i++) { | 82 for (int i = 0; i < node.inputs.length; i++) { |
| 83 if (node.inputs[i].instructionType != HType.UNKNOWN) { | 83 if (node.inputs[i].instructionType != HType.UNKNOWN) { |
| 84 allUnknown = false; | 84 allUnknown = false; |
| 85 break; | 85 break; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 if (allUnknown) return HTypeList.ALL_UNKNOWN; | 88 if (allUnknown) return HTypeList.ALL_UNKNOWN; |
| 89 | 89 |
| 90 HTypeList result = new HTypeList(node.inputs.length - 1); | 90 HTypeList result = new HTypeList(node.inputs.length); |
| 91 for (int i = 0; i < result.types.length; i++) { | 91 for (int i = 0; i < result.types.length; i++) { |
| 92 result.types[i] = node.inputs[i + 1].instructionType; | 92 result.types[i] = node.inputs[i].instructionType; |
| 93 assert(!result.types[i].isConflicting()); | 93 assert(!result.types[i].isConflicting()); |
| 94 } | 94 } |
| 95 return result; | 95 return result; |
| 96 } | 96 } |
| 97 | 97 |
| 98 factory HTypeList.fromDynamicInvocation(HInvokeDynamic node, | 98 factory HTypeList.fromDynamicInvocation(HInvokeDynamic node, |
| 99 Selector selector) { | 99 Selector selector) { |
| 100 HTypeList result; | 100 HTypeList result; |
| 101 int argumentsCount = node.inputs.length - 1; | 101 int argumentsCount = node.inputs.length - 1; |
| 102 int startInvokeIndex = HInvoke.ARGUMENTS_OFFSET; | 102 int startInvokeIndex = HInvoke.ARGUMENTS_OFFSET; |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 */ | 640 */ |
| 641 final Map<FunctionElement, bool> canBeInlined = | 641 final Map<FunctionElement, bool> canBeInlined = |
| 642 new Map<FunctionElement, bool>(); | 642 new Map<FunctionElement, bool>(); |
| 643 | 643 |
| 644 ClassElement jsInterceptorClass; | 644 ClassElement jsInterceptorClass; |
| 645 ClassElement jsStringClass; | 645 ClassElement jsStringClass; |
| 646 ClassElement jsArrayClass; | 646 ClassElement jsArrayClass; |
| 647 ClassElement jsNumberClass; | 647 ClassElement jsNumberClass; |
| 648 ClassElement jsIntClass; | 648 ClassElement jsIntClass; |
| 649 ClassElement jsDoubleClass; | 649 ClassElement jsDoubleClass; |
| 650 ClassElement jsFunctionClass; | |
| 651 ClassElement jsNullClass; | 650 ClassElement jsNullClass; |
| 652 ClassElement jsBoolClass; | 651 ClassElement jsBoolClass; |
| 653 | 652 |
| 654 ClassElement jsIndexableClass; | 653 ClassElement jsIndexableClass; |
| 655 ClassElement jsMutableIndexableClass; | 654 ClassElement jsMutableIndexableClass; |
| 656 | 655 |
| 657 ClassElement jsMutableArrayClass; | 656 ClassElement jsMutableArrayClass; |
| 658 ClassElement jsFixedArrayClass; | 657 ClassElement jsFixedArrayClass; |
| 659 ClassElement jsExtendableArrayClass; | 658 ClassElement jsExtendableArrayClass; |
| 660 | 659 |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 jsInterceptorClass = | 911 jsInterceptorClass = |
| 913 compiler.findInterceptor(const SourceString('Interceptor')), | 912 compiler.findInterceptor(const SourceString('Interceptor')), |
| 914 jsStringClass = compiler.findInterceptor(const SourceString('JSString')), | 913 jsStringClass = compiler.findInterceptor(const SourceString('JSString')), |
| 915 jsArrayClass = compiler.findInterceptor(const SourceString('JSArray')), | 914 jsArrayClass = compiler.findInterceptor(const SourceString('JSArray')), |
| 916 // The int class must be before the double class, because the | 915 // The int class must be before the double class, because the |
| 917 // emitter relies on this list for the order of type checks. | 916 // emitter relies on this list for the order of type checks. |
| 918 jsIntClass = compiler.findInterceptor(const SourceString('JSInt')), | 917 jsIntClass = compiler.findInterceptor(const SourceString('JSInt')), |
| 919 jsDoubleClass = compiler.findInterceptor(const SourceString('JSDouble')), | 918 jsDoubleClass = compiler.findInterceptor(const SourceString('JSDouble')), |
| 920 jsNumberClass = compiler.findInterceptor(const SourceString('JSNumber')), | 919 jsNumberClass = compiler.findInterceptor(const SourceString('JSNumber')), |
| 921 jsNullClass = compiler.findInterceptor(const SourceString('JSNull')), | 920 jsNullClass = compiler.findInterceptor(const SourceString('JSNull')), |
| 922 jsFunctionClass = | |
| 923 compiler.findInterceptor(const SourceString('JSFunction')), | |
| 924 jsBoolClass = compiler.findInterceptor(const SourceString('JSBool')), | 921 jsBoolClass = compiler.findInterceptor(const SourceString('JSBool')), |
| 925 jsMutableArrayClass = | 922 jsMutableArrayClass = |
| 926 compiler.findInterceptor(const SourceString('JSMutableArray')), | 923 compiler.findInterceptor(const SourceString('JSMutableArray')), |
| 927 jsFixedArrayClass = | 924 jsFixedArrayClass = |
| 928 compiler.findInterceptor(const SourceString('JSFixedArray')), | 925 compiler.findInterceptor(const SourceString('JSFixedArray')), |
| 929 jsExtendableArrayClass = | 926 jsExtendableArrayClass = |
| 930 compiler.findInterceptor(const SourceString('JSExtendableArray'))]; | 927 compiler.findInterceptor(const SourceString('JSExtendableArray'))]; |
| 931 | 928 |
| 932 jsIndexableClass = | 929 jsIndexableClass = |
| 933 compiler.findInterceptor(const SourceString('JSIndexable')); | 930 compiler.findInterceptor(const SourceString('JSIndexable')); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 || cls == jsExtendableArrayClass) { | 1112 || cls == jsExtendableArrayClass) { |
| 1116 addInterceptors(jsArrayClass, enqueuer, elements); | 1113 addInterceptors(jsArrayClass, enqueuer, elements); |
| 1117 enqueuer.registerInstantiatedClass(jsFixedArrayClass, elements); | 1114 enqueuer.registerInstantiatedClass(jsFixedArrayClass, elements); |
| 1118 enqueuer.registerInstantiatedClass(jsExtendableArrayClass, elements); | 1115 enqueuer.registerInstantiatedClass(jsExtendableArrayClass, elements); |
| 1119 } else if (cls == compiler.intClass || cls == jsIntClass) { | 1116 } else if (cls == compiler.intClass || cls == jsIntClass) { |
| 1120 addInterceptors(jsIntClass, enqueuer, elements); | 1117 addInterceptors(jsIntClass, enqueuer, elements); |
| 1121 addInterceptors(jsNumberClass, enqueuer, elements); | 1118 addInterceptors(jsNumberClass, enqueuer, elements); |
| 1122 } else if (cls == compiler.doubleClass || cls == jsDoubleClass) { | 1119 } else if (cls == compiler.doubleClass || cls == jsDoubleClass) { |
| 1123 addInterceptors(jsDoubleClass, enqueuer, elements); | 1120 addInterceptors(jsDoubleClass, enqueuer, elements); |
| 1124 addInterceptors(jsNumberClass, enqueuer, elements); | 1121 addInterceptors(jsNumberClass, enqueuer, elements); |
| 1125 } else if (cls == compiler.functionClass || cls == jsFunctionClass) { | |
| 1126 addInterceptors(jsFunctionClass, enqueuer, elements); | |
| 1127 } else if (cls == compiler.boolClass || cls == jsBoolClass) { | 1122 } else if (cls == compiler.boolClass || cls == jsBoolClass) { |
| 1128 addInterceptors(jsBoolClass, enqueuer, elements); | 1123 addInterceptors(jsBoolClass, enqueuer, elements); |
| 1129 } else if (cls == compiler.nullClass || cls == jsNullClass) { | 1124 } else if (cls == compiler.nullClass || cls == jsNullClass) { |
| 1130 addInterceptors(jsNullClass, enqueuer, elements); | 1125 addInterceptors(jsNullClass, enqueuer, elements); |
| 1131 } else if (cls == compiler.numClass || cls == jsNumberClass) { | 1126 } else if (cls == compiler.numClass || cls == jsNumberClass) { |
| 1132 addInterceptors(jsIntClass, enqueuer, elements); | 1127 addInterceptors(jsIntClass, enqueuer, elements); |
| 1133 addInterceptors(jsDoubleClass, enqueuer, elements); | 1128 addInterceptors(jsDoubleClass, enqueuer, elements); |
| 1134 addInterceptors(jsNumberClass, enqueuer, elements); | 1129 addInterceptors(jsNumberClass, enqueuer, elements); |
| 1135 } else if (cls.isNative()) { | 1130 } else if (cls.isNative()) { |
| 1136 addInterceptorsForNativeClassMembers(cls, enqueuer); | 1131 addInterceptorsForNativeClassMembers(cls, enqueuer); |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 } else if (element == jsNumberClass || element == compiler.numClass) { | 1644 } else if (element == jsNumberClass || element == compiler.numClass) { |
| 1650 if (nativeCheckOnly) return null; | 1645 if (nativeCheckOnly) return null; |
| 1651 return typeCast | 1646 return typeCast |
| 1652 ? const SourceString("numTypeCast") | 1647 ? const SourceString("numTypeCast") |
| 1653 : const SourceString('numTypeCheck'); | 1648 : const SourceString('numTypeCheck'); |
| 1654 } else if (element == jsBoolClass || element == compiler.boolClass) { | 1649 } else if (element == jsBoolClass || element == compiler.boolClass) { |
| 1655 if (nativeCheckOnly) return null; | 1650 if (nativeCheckOnly) return null; |
| 1656 return typeCast | 1651 return typeCast |
| 1657 ? const SourceString("boolTypeCast") | 1652 ? const SourceString("boolTypeCast") |
| 1658 : const SourceString('boolTypeCheck'); | 1653 : const SourceString('boolTypeCheck'); |
| 1659 } else if (element == jsFunctionClass || | |
| 1660 element == compiler.functionClass) { | |
| 1661 if (nativeCheckOnly) return null; | |
| 1662 return typeCast | |
| 1663 ? const SourceString("functionTypeCast") | |
| 1664 : const SourceString('functionTypeCheck'); | |
| 1665 } else if (element == jsIntClass || element == compiler.intClass) { | 1654 } else if (element == jsIntClass || element == compiler.intClass) { |
| 1666 if (nativeCheckOnly) return null; | 1655 if (nativeCheckOnly) return null; |
| 1667 return typeCast ? | 1656 return typeCast ? |
| 1668 const SourceString("intTypeCast") : | 1657 const SourceString("intTypeCast") : |
| 1669 const SourceString('intTypeCheck'); | 1658 const SourceString('intTypeCheck'); |
| 1670 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { | 1659 } else if (Elements.isNumberOrStringSupertype(element, compiler)) { |
| 1671 if (nativeCheck) { | 1660 if (nativeCheck) { |
| 1672 return typeCast | 1661 return typeCast |
| 1673 ? const SourceString("numberOrStringSuperNativeTypeCast") | 1662 ? const SourceString("numberOrStringSuperNativeTypeCast") |
| 1674 : const SourceString('numberOrStringSuperNativeTypeCheck'); | 1663 : const SourceString('numberOrStringSuperNativeTypeCheck'); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 ClassElement get intImplementation => jsIntClass; | 1827 ClassElement get intImplementation => jsIntClass; |
| 1839 ClassElement get doubleImplementation => jsDoubleClass; | 1828 ClassElement get doubleImplementation => jsDoubleClass; |
| 1840 ClassElement get numImplementation => jsNumberClass; | 1829 ClassElement get numImplementation => jsNumberClass; |
| 1841 ClassElement get stringImplementation => jsStringClass; | 1830 ClassElement get stringImplementation => jsStringClass; |
| 1842 ClassElement get listImplementation => jsArrayClass; | 1831 ClassElement get listImplementation => jsArrayClass; |
| 1843 ClassElement get constListImplementation => jsArrayClass; | 1832 ClassElement get constListImplementation => jsArrayClass; |
| 1844 ClassElement get fixedListImplementation => jsFixedArrayClass; | 1833 ClassElement get fixedListImplementation => jsFixedArrayClass; |
| 1845 ClassElement get growableListImplementation => jsExtendableArrayClass; | 1834 ClassElement get growableListImplementation => jsExtendableArrayClass; |
| 1846 ClassElement get mapImplementation => mapLiteralClass; | 1835 ClassElement get mapImplementation => mapLiteralClass; |
| 1847 ClassElement get constMapImplementation => constMapLiteralClass; | 1836 ClassElement get constMapImplementation => constMapLiteralClass; |
| 1848 ClassElement get functionImplementation => jsFunctionClass; | |
| 1849 ClassElement get typeImplementation => typeLiteralClass; | 1837 ClassElement get typeImplementation => typeLiteralClass; |
| 1850 ClassElement get boolImplementation => jsBoolClass; | 1838 ClassElement get boolImplementation => jsBoolClass; |
| 1851 ClassElement get nullImplementation => jsNullClass; | 1839 ClassElement get nullImplementation => jsNullClass; |
| 1852 } | 1840 } |
| OLD | NEW |