Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 340253003: Avoid counting custom elements as added due to mirrors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 staticFields.add(target); 1892 staticFields.add(target);
1893 } else if (target.isLibrary || target.isClass) { 1893 } else if (target.isLibrary || target.isClass) {
1894 addFieldsInContainer(target); 1894 addFieldsInContainer(target);
1895 } 1895 }
1896 } 1896 }
1897 return staticFields; 1897 return staticFields;
1898 } 1898 }
1899 1899
1900 /// Called when [enqueuer] is empty, but before it is closed. 1900 /// Called when [enqueuer] is empty, but before it is closed.
1901 void onQueueEmpty(Enqueuer enqueuer) { 1901 void onQueueEmpty(Enqueuer enqueuer) {
1902 // Add elements referenced only via custom elements. Return early if any
1903 // elements are added to avoid counting the elements as due to mirrors.
1904 customElementsAnalysis.onQueueEmpty(enqueuer);
1905 if (!enqueuer.queueIsEmpty) return;
1906
1902 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) { 1907 if (!enqueuer.isResolutionQueue && preMirrorsMethodCount == 0) {
1903 preMirrorsMethodCount = generatedCode.length; 1908 preMirrorsMethodCount = generatedCode.length;
1904 } 1909 }
1905 1910
1906 if (isTreeShakingDisabled) { 1911 if (isTreeShakingDisabled) {
1907 enqueuer.enqueueEverything(); 1912 enqueuer.enqueueEverything();
1908 } else if (!targetsUsed.isEmpty && enqueuer.isResolutionQueue) { 1913 } else if (!targetsUsed.isEmpty && enqueuer.isResolutionQueue) {
1909 // Add all static elements (not classes) that have been requested for 1914 // Add all static elements (not classes) that have been requested for
1910 // reflection. If there is no mirror-usage these are probably not 1915 // reflection. If there is no mirror-usage these are probably not
1911 // necessary, but the backend relies on them being resolved. 1916 // necessary, but the backend relies on them being resolved.
1912 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); 1917 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets());
1913 } 1918 }
1914 1919
1915 if (mustPreserveNames) compiler.log('Preserving names.'); 1920 if (mustPreserveNames) compiler.log('Preserving names.');
1916 1921
1917 if (mustRetainMetadata) { 1922 if (mustRetainMetadata) {
1918 compiler.log('Retaining metadata.'); 1923 compiler.log('Retaining metadata.');
1919 1924
1920 compiler.libraries.values.forEach(retainMetadataOf); 1925 compiler.libraries.values.forEach(retainMetadataOf);
1921 for (Dependency dependency in metadataConstants) { 1926 for (Dependency dependency in metadataConstants) {
1922 registerCompileTimeConstant( 1927 registerCompileTimeConstant(
1923 dependency.constant, dependency.registry); 1928 dependency.constant, dependency.registry);
1924 } 1929 }
1925 metadataConstants.clear(); 1930 metadataConstants.clear();
1926 } 1931 }
1927
1928 customElementsAnalysis.onQueueEmpty(enqueuer);
1929 } 1932 }
1930 1933
1931 void onElementResolved(Element element, TreeElements elements) { 1934 void onElementResolved(Element element, TreeElements elements) {
1932 LibraryElement library = element.library; 1935 LibraryElement library = element.library;
1933 if (!library.isPlatformLibrary && !library.canUseNative) return; 1936 if (!library.isPlatformLibrary && !library.canUseNative) return;
1934 bool hasNoInline = false; 1937 bool hasNoInline = false;
1935 bool hasNoThrows = false; 1938 bool hasNoThrows = false;
1936 bool hasNoSideEffects = false; 1939 bool hasNoSideEffects = false;
1937 for (MetadataAnnotation metadata in element.metadata) { 1940 for (MetadataAnnotation metadata in element.metadata) {
1938 metadata.ensureResolved(compiler); 1941 metadata.ensureResolved(compiler);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 } 1991 }
1989 1992
1990 /// Records that [constant] is used by the element behind [registry]. 1993 /// Records that [constant] is used by the element behind [registry].
1991 class Dependency { 1994 class Dependency {
1992 final Constant constant; 1995 final Constant constant;
1993 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. 1996 // TODO(johnniwinther): Change to [Element] when dependency nodes are added.
1994 final Registry registry; 1997 final Registry registry;
1995 1998
1996 const Dependency(this.constant, this.registry); 1999 const Dependency(this.constant, this.registry);
1997 } 2000 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/enqueue.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698