| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 new Map<Element, jsAst.Expression>(); | 635 new Map<Element, jsAst.Expression>(); |
| 636 | 636 |
| 637 ClassElement jsStringClass; | 637 ClassElement jsStringClass; |
| 638 ClassElement jsArrayClass; | 638 ClassElement jsArrayClass; |
| 639 ClassElement jsNumberClass; | 639 ClassElement jsNumberClass; |
| 640 ClassElement jsIntClass; | 640 ClassElement jsIntClass; |
| 641 ClassElement jsDoubleClass; | 641 ClassElement jsDoubleClass; |
| 642 ClassElement jsFunctionClass; | 642 ClassElement jsFunctionClass; |
| 643 ClassElement jsNullClass; | 643 ClassElement jsNullClass; |
| 644 ClassElement jsBoolClass; | 644 ClassElement jsBoolClass; |
| 645 ClassElement typeLiteralClass; |
| 646 ClassElement mapLiteralClass; |
| 645 Element jsArrayLength; | 647 Element jsArrayLength; |
| 646 Element jsStringLength; | 648 Element jsStringLength; |
| 647 Element jsArrayRemoveLast; | 649 Element jsArrayRemoveLast; |
| 648 Element jsArrayAdd; | 650 Element jsArrayAdd; |
| 649 Element jsStringSplit; | 651 Element jsStringSplit; |
| 650 Element jsStringConcat; | 652 Element jsStringConcat; |
| 651 Element jsStringToString; | 653 Element jsStringToString; |
| 652 Element getInterceptorMethod; | 654 Element getInterceptorMethod; |
| 653 Element interceptedNames; | 655 Element interceptedNames; |
| 654 Element fixedLengthListConstructor; | 656 Element fixedLengthListConstructor; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 jsStringSplit = compiler.lookupElementIn( | 835 jsStringSplit = compiler.lookupElementIn( |
| 834 jsStringClass, const SourceString('split')); | 836 jsStringClass, const SourceString('split')); |
| 835 jsStringConcat = compiler.lookupElementIn( | 837 jsStringConcat = compiler.lookupElementIn( |
| 836 jsStringClass, const SourceString('concat')); | 838 jsStringClass, const SourceString('concat')); |
| 837 jsStringToString = compiler.lookupElementIn( | 839 jsStringToString = compiler.lookupElementIn( |
| 838 jsStringClass, const SourceString('toString')); | 840 jsStringClass, const SourceString('toString')); |
| 839 | 841 |
| 840 for (ClassElement cls in classes) { | 842 for (ClassElement cls in classes) { |
| 841 if (cls != null) interceptedClasses.add(cls); | 843 if (cls != null) interceptedClasses.add(cls); |
| 842 } | 844 } |
| 845 |
| 846 typeLiteralClass = compiler.findHelper(const SourceString('TypeImpl')); |
| 847 // TODO(ngeoffray): We have ConstantMap and |
| 848 // LinkedHashMapImplementation for literal maps. We should somehow |
| 849 // have the users of [mapLiteralClass] know. |
| 850 mapLiteralClass = |
| 851 compiler.coreLibrary.find(const SourceString('LinkedHashMap')); |
| 843 } | 852 } |
| 844 | 853 |
| 845 void addInterceptors(ClassElement cls, Enqueuer enqueuer) { | 854 void addInterceptors(ClassElement cls, Enqueuer enqueuer) { |
| 846 if (enqueuer.isResolutionQueue) { | 855 if (enqueuer.isResolutionQueue) { |
| 847 cls.ensureResolved(compiler); | 856 cls.ensureResolved(compiler); |
| 848 cls.forEachMember((ClassElement classElement, Element member) { | 857 cls.forEachMember((ClassElement classElement, Element member) { |
| 849 Set<Element> set = interceptedElements.putIfAbsent( | 858 Set<Element> set = interceptedElements.putIfAbsent( |
| 850 member.name, () => new Set<Element>()); | 859 member.name, () => new Set<Element>()); |
| 851 set.add(member); | 860 set.add(member); |
| 852 }, | 861 }, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 enqueuer.registerStaticUse( | 908 enqueuer.registerStaticUse( |
| 900 compiler.findHelper(const SourceString('ioore'))); | 909 compiler.findHelper(const SourceString('ioore'))); |
| 901 enqueuer.registerStaticUse( | 910 enqueuer.registerStaticUse( |
| 902 compiler.findHelper(const SourceString('iae'))); | 911 compiler.findHelper(const SourceString('iae'))); |
| 903 } else if (cls == compiler.functionClass) { | 912 } else if (cls == compiler.functionClass) { |
| 904 enqueuer.registerInstantiatedClass(compiler.closureClass); | 913 enqueuer.registerInstantiatedClass(compiler.closureClass); |
| 905 } else if (cls == compiler.mapClass) { | 914 } else if (cls == compiler.mapClass) { |
| 906 // The backend will use a literal list to initialize the entries | 915 // The backend will use a literal list to initialize the entries |
| 907 // of the map. | 916 // of the map. |
| 908 enqueuer.registerInstantiatedClass(compiler.listClass); | 917 enqueuer.registerInstantiatedClass(compiler.listClass); |
| 909 enqueuer.registerInstantiatedClass(compiler.mapLiteralClass); | 918 enqueuer.registerInstantiatedClass(mapLiteralClass); |
| 910 enqueueInResolution(getMapMaker()); | 919 enqueueInResolution(getMapMaker()); |
| 911 } | 920 } |
| 912 } | 921 } |
| 913 ClassElement result = null; | 922 ClassElement result = null; |
| 914 if (cls == compiler.stringClass) { | 923 if (cls == compiler.stringClass) { |
| 915 addInterceptors(jsStringClass, enqueuer); | 924 addInterceptors(jsStringClass, enqueuer); |
| 916 } else if (cls == compiler.listClass) { | 925 } else if (cls == compiler.listClass) { |
| 917 addInterceptors(jsArrayClass, enqueuer); | 926 addInterceptors(jsArrayClass, enqueuer); |
| 918 } else if (cls == compiler.intClass) { | 927 } else if (cls == compiler.intClass) { |
| 919 addInterceptors(jsIntClass, enqueuer); | 928 addInterceptors(jsIntClass, enqueuer); |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 void eagerRecompile(Element element) { | 1515 void eagerRecompile(Element element) { |
| 1507 assert(invariant(element, element.isDeclaration)); | 1516 assert(invariant(element, element.isDeclaration)); |
| 1508 generatedCode.remove(element); | 1517 generatedCode.remove(element); |
| 1509 generatedBailoutCode.remove(element); | 1518 generatedBailoutCode.remove(element); |
| 1510 compiler.enqueuer.codegen.addToWorkList(element); | 1519 compiler.enqueuer.codegen.addToWorkList(element); |
| 1511 } | 1520 } |
| 1512 | 1521 |
| 1513 bool isNullImplementation(ClassElement cls) { | 1522 bool isNullImplementation(ClassElement cls) { |
| 1514 return cls == jsNullClass; | 1523 return cls == jsNullClass; |
| 1515 } | 1524 } |
| 1525 |
| 1526 ClassElement get intImplementation => jsIntClass; |
| 1527 ClassElement get doubleImplementation => jsDoubleClass; |
| 1528 ClassElement get numImplementation => jsNumberClass; |
| 1529 ClassElement get stringImplementation => jsStringClass; |
| 1530 ClassElement get listImplementation => jsArrayClass; |
| 1531 ClassElement get mapImplementation => mapLiteralClass; |
| 1532 ClassElement get functionImplementation => jsFunctionClass; |
| 1533 ClassElement get typeImplementation => typeLiteralClass; |
| 1534 ClassElement get boolImplementation => jsBoolClass; |
| 1535 ClassElement get nullImplementation => jsNullClass; |
| 1516 } | 1536 } |
| OLD | NEW |