| 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 boundsChecked = new Set<HInstruction>(); | 640 boundsChecked = new Set<HInstruction>(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 class JavaScriptBackend extends Backend { | 643 class JavaScriptBackend extends Backend { |
| 644 SsaBuilderTask builder; | 644 SsaBuilderTask builder; |
| 645 SsaOptimizerTask optimizer; | 645 SsaOptimizerTask optimizer; |
| 646 SsaCodeGeneratorTask generator; | 646 SsaCodeGeneratorTask generator; |
| 647 CodeEmitterTask emitter; | 647 CodeEmitterTask emitter; |
| 648 | 648 |
| 649 ClassElement jsStringClass; | 649 ClassElement jsStringClass; |
| 650 ClassElement jsArrayClass; |
| 650 ClassElement objectInterceptorClass; | 651 ClassElement objectInterceptorClass; |
| 651 Element getInterceptorMethod; | 652 Element getInterceptorMethod; |
| 652 | 653 |
| 653 final Namer namer; | 654 final Namer namer; |
| 654 | 655 |
| 655 /** | 656 /** |
| 656 * Interface used to determine if an object has the JavaScript | 657 * Interface used to determine if an object has the JavaScript |
| 657 * indexing behavior. The interface is only visible to specific | 658 * indexing behavior. The interface is only visible to specific |
| 658 * libraries. | 659 * libraries. |
| 659 */ | 660 */ |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 710 } |
| 710 | 711 |
| 711 static Namer determineNamer(Compiler compiler) { | 712 static Namer determineNamer(Compiler compiler) { |
| 712 return compiler.enableMinification ? | 713 return compiler.enableMinification ? |
| 713 new MinifyNamer(compiler) : | 714 new MinifyNamer(compiler) : |
| 714 new Namer(compiler); | 715 new Namer(compiler); |
| 715 } | 716 } |
| 716 | 717 |
| 717 bool isInterceptorClass(Element element) { | 718 bool isInterceptorClass(Element element) { |
| 718 if (element == null) return false; | 719 if (element == null) return false; |
| 719 return element == jsStringClass; | 720 return element == jsStringClass || element == jsArrayClass; |
| 720 } | 721 } |
| 721 | 722 |
| 722 void addInterceptedSelector(Selector selector) { | 723 void addInterceptedSelector(Selector selector) { |
| 723 usedInterceptors.add(selector); | 724 usedInterceptors.add(selector); |
| 724 } | 725 } |
| 725 | 726 |
| 726 bool shouldInterceptSelector(Selector selector) { | 727 bool shouldInterceptSelector(Selector selector) { |
| 727 List<Element> intercepted = interceptedElements[selector.name]; | 728 List<Element> intercepted = interceptedElements[selector.name]; |
| 728 if (intercepted == null) return false; | 729 if (intercepted == null) return false; |
| 729 for (Element element in intercepted) { | 730 for (Element element in intercepted) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 742 | 743 |
| 743 void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) { | 744 void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) { |
| 744 ClassElement result = null; | 745 ClassElement result = null; |
| 745 if (cls == compiler.stringClass) { | 746 if (cls == compiler.stringClass) { |
| 746 if (jsStringClass == null) { | 747 if (jsStringClass == null) { |
| 747 jsStringClass = | 748 jsStringClass = |
| 748 compiler.findInterceptor(const SourceString('JSString')); | 749 compiler.findInterceptor(const SourceString('JSString')); |
| 749 initializeInterceptorElements(); | 750 initializeInterceptorElements(); |
| 750 } | 751 } |
| 751 result = jsStringClass; | 752 result = jsStringClass; |
| 753 } else if (cls == compiler.listClass) { |
| 754 if (jsArrayClass == null) { |
| 755 jsArrayClass = |
| 756 compiler.findInterceptor(const SourceString('JSArray')); |
| 757 initializeInterceptorElements(); |
| 758 } |
| 759 result = jsArrayClass; |
| 752 } | 760 } |
| 753 | 761 |
| 754 if (result == null) return; | 762 if (result == null) return; |
| 755 | 763 |
| 756 result.forEachMember((_, Element member) { | 764 result.forEachMember((_, Element member) { |
| 757 List<Element> list = interceptedElements.putIfAbsent( | 765 List<Element> list = interceptedElements.putIfAbsent( |
| 758 member.name, () => new List<Element>()); | 766 member.name, () => new List<Element>()); |
| 759 list.add(member); | 767 list.add(member); |
| 760 }); | 768 }); |
| 761 | 769 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 print("Inferred return types:"); | 1036 print("Inferred return types:"); |
| 1029 print("----------------------"); | 1037 print("----------------------"); |
| 1030 dumpReturnTypes(); | 1038 dumpReturnTypes(); |
| 1031 print(""); | 1039 print(""); |
| 1032 print("Inferred field types:"); | 1040 print("Inferred field types:"); |
| 1033 print("------------------------"); | 1041 print("------------------------"); |
| 1034 fieldTypes.dump(); | 1042 fieldTypes.dump(); |
| 1035 print(""); | 1043 print(""); |
| 1036 } | 1044 } |
| 1037 } | 1045 } |
| OLD | NEW |