| 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 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 && mask.satisfies(jsIndexingBehaviorInterface, compiler); | 1737 && mask.satisfies(jsIndexingBehaviorInterface, compiler); |
| 1738 } | 1738 } |
| 1739 | 1739 |
| 1740 bool couldBeTypedArray(TypeMask mask) { | 1740 bool couldBeTypedArray(TypeMask mask) { |
| 1741 TypeMask indexing = new TypeMask.subtype(jsIndexingBehaviorInterface); | 1741 TypeMask indexing = new TypeMask.subtype(jsIndexingBehaviorInterface); |
| 1742 // Checking if [mask] contains [indexing] means that we want to | 1742 // Checking if [mask] contains [indexing] means that we want to |
| 1743 // know if [mask] is not a more specific type than [indexing]. | 1743 // know if [mask] is not a more specific type than [indexing]. |
| 1744 return isTypedArray(mask) || mask.containsMask(indexing, compiler); | 1744 return isTypedArray(mask) || mask.containsMask(indexing, compiler); |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 /// Returns all static fields that are referenced through [targetsUsed]. |
| 1748 /// If the target is a library or class all nested static fields are |
| 1749 /// included too. |
| 1750 Iterable<Element> _findStaticFieldTargets() { |
| 1751 List staticFields = []; |
| 1752 |
| 1753 void addFieldsInContainer(ScopeContainerElement container) { |
| 1754 container.forEachLocalMember((Element member) { |
| 1755 if (!member.isInstanceMember() && member.isField()) { |
| 1756 staticFields.add(member); |
| 1757 } else if (member.isClass()) { |
| 1758 addFieldsInContainer(member); |
| 1759 } |
| 1760 }); |
| 1761 } |
| 1762 |
| 1763 for (Element target in targetsUsed) { |
| 1764 if (target == null) continue; |
| 1765 if (target.isField()) { |
| 1766 staticFields.add(target); |
| 1767 } else if (target.isLibrary() || target.isClass()) { |
| 1768 addFieldsInContainer(target); |
| 1769 } |
| 1770 } |
| 1771 return staticFields; |
| 1772 } |
| 1773 |
| 1747 /// Called when [enqueuer] is empty, but before it is closed. | 1774 /// Called when [enqueuer] is empty, but before it is closed. |
| 1748 void onQueueEmpty(Enqueuer enqueuer) { | 1775 void onQueueEmpty(Enqueuer enqueuer) { |
| 1749 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { | 1776 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { |
| 1750 preMirrorsMethodCount = generatedCode.length; | 1777 preMirrorsMethodCount = generatedCode.length; |
| 1751 } | 1778 } |
| 1752 | 1779 |
| 1753 if (isTreeShakingDisabled) enqueuer.enqueueEverything(); | 1780 if (isTreeShakingDisabled) { |
| 1781 enqueuer.enqueueEverything(); |
| 1782 } else if (!targetsUsed.isEmpty && enqueuer.isResolutionQueue) { |
| 1783 // Add all static elements (not classes) that have been requested for |
| 1784 // reflection. If there is no mirror-usage these are probably not |
| 1785 // necessary, but the backend relies on them being resolved. |
| 1786 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); |
| 1787 } |
| 1754 | 1788 |
| 1755 if (mustPreserveNames) compiler.log('Preserving names.'); | 1789 if (mustPreserveNames) compiler.log('Preserving names.'); |
| 1756 | 1790 |
| 1757 if (mustRetainMetadata) { | 1791 if (mustRetainMetadata) { |
| 1758 compiler.log('Retaining metadata.'); | 1792 compiler.log('Retaining metadata.'); |
| 1759 | 1793 |
| 1760 compiler.libraries.values.forEach(retainMetadataOf); | 1794 compiler.libraries.values.forEach(retainMetadataOf); |
| 1761 for (Dependency dependency in metadataConstants) { | 1795 for (Dependency dependency in metadataConstants) { |
| 1762 registerCompileTimeConstant( | 1796 registerCompileTimeConstant( |
| 1763 dependency.constant, dependency.user); | 1797 dependency.constant, dependency.user); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1873 copy(constant.values); | 1907 copy(constant.values); |
| 1874 copy(constant.protoValue); | 1908 copy(constant.protoValue); |
| 1875 copy(constant); | 1909 copy(constant); |
| 1876 } | 1910 } |
| 1877 | 1911 |
| 1878 void visitConstructed(ConstructedConstant constant) { | 1912 void visitConstructed(ConstructedConstant constant) { |
| 1879 copy(constant.fields); | 1913 copy(constant.fields); |
| 1880 copy(constant); | 1914 copy(constant); |
| 1881 } | 1915 } |
| 1882 } | 1916 } |
| OLD | NEW |