Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/compiler.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/compiler.dart b/sdk/lib/_internal/compiler/implementation/compiler.dart |
| index 3c6de9c065fae4bd9ce9af38dda3ef3f3d7f96aa..09f680e8c8b7adc55f330630623913417528985a 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/compiler.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/compiler.dart |
| @@ -11,11 +11,6 @@ part of dart2js; |
| const bool REPORT_EXCESS_RESOLUTION = false; |
| /** |
| - * If true, dump the inferred types after compilation. |
| - */ |
| -const bool DUMP_INFERRED_TYPES = false; |
| - |
| -/** |
| * Contains backend-specific data that is used throughout the compilation of |
| * one work item. |
| */ |
| @@ -85,6 +80,13 @@ abstract class Backend { |
| [ConstantSystem constantSystem = DART_CONSTANT_SYSTEM]) |
| : this.constantSystem = constantSystem; |
| + /** |
| + * Map each library to the size of the generated code for that library. |
| + */ |
| + final CodeSizeCounter codeSizeCounter = new CodeSizeCounter(); |
|
ahe
2013/11/27 19:28:53
It doesn't seem appropriate for the backend to exp
sigurdm
2013/11/29 10:39:37
Done.
|
| + |
| + CodeBuffer emitCodeFor(Element element); |
|
ahe
2013/11/27 19:28:53
Please document this method.
sigurdm
2013/11/29 10:39:37
Done.
|
| + |
| void initializeHelperClasses() {} |
| void enqueueAllTopLevelFunctions(LibraryElement lib, Enqueuer world) { |
| @@ -110,8 +112,46 @@ abstract class Backend { |
| void onResolutionComplete() {} |
| - // TODO(ahe,karlklose): rename this? |
| - void dumpInferredTypes() {} |
| + Map collectDumpInfo() { |
|
ahe
2013/11/27 19:28:53
This seems like an odd fit for this functionality.
sigurdm
2013/11/29 10:39:37
Done.
|
| + List<LibraryElement> sortedLibraries = compiler.libraries.values.toList(); |
| + sortedLibraries.sort( |
|
karlklose
2013/11/27 14:19:23
You could also write it as follows: (we usually fo
sigurdm
2013/11/29 10:39:37
Much better
|
| + (LibraryElement l1, LibraryElement l2) { |
| + if (l1.isPlatformLibrary && !l2.isPlatformLibrary) { |
| + return 1; |
| + } else if (!l1.isPlatformLibrary && l2.isPlatformLibrary) { |
| + return -1; |
| + } |
| + return l1.getLibraryName(). |
| + compareTo(l2.getLibraryName()); |
| + }); |
| + List libraryInfos = []; |
|
karlklose
2013/11/27 14:19:23
'List' -> 'List<Map>', maybe even add the key and
sigurdm
2013/11/29 10:39:37
Problem is, that the value type is not fixed.
But
|
| + for (LibraryElement library in sortedLibraries) { |
|
karlklose
2013/11/27 14:19:23
How about:
libraryInfos.addAll(sortedLibraries
sigurdm
2013/11/29 10:39:37
Nice
|
| + Map libraryInfo = library.collectInferredTypes(compiler); |
| + if (libraryInfo != null) { |
| + libraryInfos.add(libraryInfo); |
| + } |
| + } |
| + Map info = { |
| + "compilation duration" : compiler.totalCompileTime.elapsedTicks, |
|
karlklose
2013/11/27 14:19:23
Remove the space between the map key and ':'.
sigurdm
2013/11/29 10:39:37
Done.
|
| + // TODO (sigurdm) Also count the size of deferred code |
| + "generated size" : compiler.assembledCode.length, |
| + "libraries" : libraryInfos, |
| + "compilation time" : new DateTime.now().toString() |
| + }; |
| + if (commandline.BUILD_ID != null) { |
| + info["dart2js version"] = commandline.BUILD_ID.toString(); |
| + } |
| + return info; |
| + } |
| + |
| + void dumpInfo() { |
| + Map info = collectDumpInfo(); |
| + StringBuffer buffer = new StringBuffer(); |
| + dumpInfoHtml(info, buffer); |
| + compiler.outputProvider('', 'info.html') |
| + ..add(buffer.toString()) |
| + ..close(); |
| + } |
| ItemCompilationContext createItemCompilationContext() { |
| return new ItemCompilationContext(); |
| @@ -367,6 +407,7 @@ abstract class Compiler implements DiagnosticListener { |
| final bool trustTypeAnnotations; |
| final bool enableConcreteTypeInference; |
| final bool disableTypeInferenceFlag; |
| + final bool dumpInfo; |
| /** |
| * The maximum size of a concrete type before it widens to dynamic during |
| @@ -628,6 +669,7 @@ abstract class Compiler implements DiagnosticListener { |
| this.buildId: UNDETERMINED_BUILD_ID, |
| this.globalJsName: r'$', |
| this.terseDiagnostics: false, |
| + this.dumpInfo: false, |
| outputProvider, |
| List<String> strips: const []}) |
| : this.analyzeOnly = analyzeOnly || analyzeSignaturesOnly, |
| @@ -1135,6 +1177,10 @@ abstract class Compiler implements DiagnosticListener { |
| backend.assembleProgram(); |
| + if (dumpInfo) { |
| + backend.dumpInfo(); |
|
ahe
2013/11/27 19:28:53
This should be its own task. Then we can see how l
sigurdm
2013/11/29 10:39:37
Done.
|
| + } |
| + |
| checkQueues(); |
| if (compilationFailed) { |
| @@ -1194,9 +1240,6 @@ abstract class Compiler implements DiagnosticListener { |
| world.queueIsClosed = true; |
| if (compilationFailed) return; |
| assert(world.checkNoEnqueuedInvokedInstanceMethods()); |
| - if (DUMP_INFERRED_TYPES && phase == PHASE_COMPILING) { |
| - backend.dumpInferredTypes(); |
| - } |
| } |
| /** |