| 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 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 emitter.assembleProgram(); | 1186 emitter.assembleProgram(); |
| 1187 int totalMethodCount = generatedCode.length; | 1187 int totalMethodCount = generatedCode.length; |
| 1188 if (totalMethodCount != preMirrorsMethodCount) { | 1188 if (totalMethodCount != preMirrorsMethodCount) { |
| 1189 int mirrorCount = totalMethodCount - preMirrorsMethodCount; | 1189 int mirrorCount = totalMethodCount - preMirrorsMethodCount; |
| 1190 double percentage = (mirrorCount / totalMethodCount) * 100; | 1190 double percentage = (mirrorCount / totalMethodCount) * 100; |
| 1191 compiler.reportHint( | 1191 compiler.reportHint( |
| 1192 compiler.mainApp, MessageKind.MIRROR_BLOAT, | 1192 compiler.mainApp, MessageKind.MIRROR_BLOAT, |
| 1193 {'count': mirrorCount, | 1193 {'count': mirrorCount, |
| 1194 'total': totalMethodCount, | 1194 'total': totalMethodCount, |
| 1195 'percentage': percentage.round()}); | 1195 'percentage': percentage.round()}); |
| 1196 for (LibraryElement library in compiler.libraries.values) { | 1196 for (LibraryElement library in compiler.libraryLoader.libraries) { |
| 1197 if (library.isInternalLibrary) continue; | 1197 if (library.isInternalLibrary) continue; |
| 1198 for (LibraryTag tag in library.tags) { | 1198 for (LibraryTag tag in library.tags) { |
| 1199 Import importTag = tag.asImport(); | 1199 Import importTag = tag.asImport(); |
| 1200 if (importTag == null) continue; | 1200 if (importTag == null) continue; |
| 1201 LibraryElement importedLibrary = library.getLibraryFromTag(tag); | 1201 LibraryElement importedLibrary = library.getLibraryFromTag(tag); |
| 1202 if (importedLibrary != compiler.mirrorsLibrary) continue; | 1202 if (importedLibrary != compiler.mirrorsLibrary) continue; |
| 1203 MessageKind kind = | 1203 MessageKind kind = |
| 1204 compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library) | 1204 compiler.mirrorUsageAnalyzerTask.hasMirrorUsage(library) |
| 1205 ? MessageKind.MIRROR_IMPORT | 1205 ? MessageKind.MIRROR_IMPORT |
| 1206 : MessageKind.MIRROR_IMPORT_NO_USAGE; | 1206 : MessageKind.MIRROR_IMPORT_NO_USAGE; |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1917 // reflection. If there is no mirror-usage these are probably not | 1917 // reflection. If there is no mirror-usage these are probably not |
| 1918 // necessary, but the backend relies on them being resolved. | 1918 // necessary, but the backend relies on them being resolved. |
| 1919 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); | 1919 enqueuer.enqueueReflectiveStaticFields(_findStaticFieldTargets()); |
| 1920 } | 1920 } |
| 1921 | 1921 |
| 1922 if (mustPreserveNames) compiler.log('Preserving names.'); | 1922 if (mustPreserveNames) compiler.log('Preserving names.'); |
| 1923 | 1923 |
| 1924 if (mustRetainMetadata) { | 1924 if (mustRetainMetadata) { |
| 1925 compiler.log('Retaining metadata.'); | 1925 compiler.log('Retaining metadata.'); |
| 1926 | 1926 |
| 1927 compiler.libraries.values.forEach(retainMetadataOf); | 1927 compiler.libraryLoader.libraries.forEach(retainMetadataOf); |
| 1928 for (Dependency dependency in metadataConstants) { | 1928 for (Dependency dependency in metadataConstants) { |
| 1929 registerCompileTimeConstant( | 1929 registerCompileTimeConstant( |
| 1930 dependency.constant, dependency.registry); | 1930 dependency.constant, dependency.registry); |
| 1931 } | 1931 } |
| 1932 metadataConstants.clear(); | 1932 metadataConstants.clear(); |
| 1933 } | 1933 } |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 void onElementResolved(Element element, TreeElements elements) { | 1936 void onElementResolved(Element element, TreeElements elements) { |
| 1937 LibraryElement library = element.library; | 1937 LibraryElement library = element.library; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 } | 1993 } |
| 1994 | 1994 |
| 1995 /// Records that [constant] is used by the element behind [registry]. | 1995 /// Records that [constant] is used by the element behind [registry]. |
| 1996 class Dependency { | 1996 class Dependency { |
| 1997 final Constant constant; | 1997 final Constant constant; |
| 1998 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. | 1998 // TODO(johnniwinther): Change to [Element] when dependency nodes are added. |
| 1999 final Registry registry; | 1999 final Registry registry; |
| 2000 | 2000 |
| 2001 const Dependency(this.constant, this.registry); | 2001 const Dependency(this.constant, this.registry); |
| 2002 } | 2002 } |
| OLD | NEW |