| 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 dart_backend; | 5 part of dart_backend; |
| 6 | 6 |
| 7 // TODO(ahe): This class is simply wrong. This backend should use | 7 // TODO(ahe): This class is simply wrong. This backend should use |
| 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, | 8 // elements when it can, not AST nodes. Perhaps a [Map<Element, |
| 9 // TreeElements>] is what is needed. | 9 // TreeElements>] is what is needed. |
| 10 class ElementAst { | 10 class ElementAst { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 && element is !AbstractFieldElement) | 155 && element is !AbstractFieldElement) |
| 156 || element.library == mirrorHelperLibrary; | 156 || element.library == mirrorHelperLibrary; |
| 157 } | 157 } |
| 158 | 158 |
| 159 void assembleProgram() { | 159 void assembleProgram() { |
| 160 // Conservatively traverse all platform libraries and collect member names. | 160 // Conservatively traverse all platform libraries and collect member names. |
| 161 // TODO(antonm): ideally we should only collect names of used members, | 161 // TODO(antonm): ideally we should only collect names of used members, |
| 162 // however as of today there are problems with names of some core library | 162 // however as of today there are problems with names of some core library |
| 163 // interfaces, most probably for interfaces of literals. | 163 // interfaces, most probably for interfaces of literals. |
| 164 final fixedMemberNames = new Set<String>(); | 164 final fixedMemberNames = new Set<String>(); |
| 165 for (final library in compiler.libraries.values) { | 165 for (final library in compiler.libraryLoader.libraries) { |
| 166 if (!library.isPlatformLibrary) continue; | 166 if (!library.isPlatformLibrary) continue; |
| 167 library.implementation.forEachLocalMember((Element element) { | 167 library.implementation.forEachLocalMember((Element element) { |
| 168 if (element.isClass) { | 168 if (element.isClass) { |
| 169 ClassElement classElement = element; | 169 ClassElement classElement = element; |
| 170 classElement.forEachLocalMember((member) { | 170 classElement.forEachLocalMember((member) { |
| 171 final name = member.name; | 171 final name = member.name; |
| 172 // Skip operator names. | 172 // Skip operator names. |
| 173 if (!name.startsWith(r'operator$')) { | 173 if (!name.startsWith(r'operator$')) { |
| 174 // Fetch name of named constructors and factories if any, | 174 // Fetch name of named constructors and factories if any, |
| 175 // otherwise store regular name. | 175 // otherwise store regular name. |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 ..close(); | 439 ..close(); |
| 440 compiler.assembledCode = assembledCode; | 440 compiler.assembledCode = assembledCode; |
| 441 | 441 |
| 442 // Output verbose info about size ratio of resulting bundle to all | 442 // Output verbose info about size ratio of resulting bundle to all |
| 443 // referenced non-platform sources. | 443 // referenced non-platform sources. |
| 444 logResultBundleSizeInfo(topLevelElements); | 444 logResultBundleSizeInfo(topLevelElements); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void logResultBundleSizeInfo(Set<Element> topLevelElements) { | 447 void logResultBundleSizeInfo(Set<Element> topLevelElements) { |
| 448 Iterable<LibraryElement> referencedLibraries = | 448 Iterable<LibraryElement> referencedLibraries = |
| 449 compiler.libraries.values.where(isUserLibrary); | 449 compiler.libraryLoader.libraries.where(isUserLibrary); |
| 450 // Sum total size of scripts in each referenced library. | 450 // Sum total size of scripts in each referenced library. |
| 451 int nonPlatformSize = 0; | 451 int nonPlatformSize = 0; |
| 452 for (LibraryElement lib in referencedLibraries) { | 452 for (LibraryElement lib in referencedLibraries) { |
| 453 for (CompilationUnitElement compilationUnit in lib.compilationUnits) { | 453 for (CompilationUnitElement compilationUnit in lib.compilationUnits) { |
| 454 nonPlatformSize += compilationUnit.script.file.length; | 454 nonPlatformSize += compilationUnit.script.file.length; |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 int percentage = compiler.assembledCode.length * 100 ~/ nonPlatformSize; | 457 int percentage = compiler.assembledCode.length * 100 ~/ nonPlatformSize; |
| 458 log('Total used non-platform files size: ${nonPlatformSize} bytes, ' | 458 log('Total used non-platform files size: ${nonPlatformSize} bytes, ' |
| 459 'bundle size: ${compiler.assembledCode.length} bytes (${percentage}%)'); | 459 'bundle size: ${compiler.assembledCode.length} bytes (${percentage}%)'); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 } | 637 } |
| 638 | 638 |
| 639 Constant compileMetadata(MetadataAnnotation metadata, | 639 Constant compileMetadata(MetadataAnnotation metadata, |
| 640 Node node, | 640 Node node, |
| 641 TreeElements elements) { | 641 TreeElements elements) { |
| 642 return measure(() { | 642 return measure(() { |
| 643 return constantCompiler.compileMetadata(metadata, node, elements); | 643 return constantCompiler.compileMetadata(metadata, node, elements); |
| 644 }); | 644 }); |
| 645 } | 645 } |
| 646 } | 646 } |
| OLD | NEW |