| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// An entrypoint used to run portions of dart2js and measure its performance. | 5 /// An entrypoint used to run portions of dart2js and measure its performance. |
| 6 library compiler.tool.perf; | 6 library compiler.tool.perf; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| 11 import 'package:compiler/compiler_new.dart'; | 11 import 'package:compiler/compiler_new.dart'; |
| 12 import 'package:compiler/src/apiimpl.dart'; | 12 import 'package:compiler/src/apiimpl.dart'; |
| 13 import 'package:compiler/src/compiler.dart'; | 13 import 'package:compiler/src/compiler.dart'; |
| 14 import 'package:compiler/src/elements/elements.dart'; | 14 import 'package:compiler/src/elements/elements.dart'; |
| 15 import 'package:compiler/src/common.dart'; | 15 import 'package:compiler/src/common.dart'; |
| 16 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; | 16 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; |
| 17 import 'package:compiler/src/diagnostics/messages.dart' | 17 import 'package:compiler/src/diagnostics/messages.dart' |
| 18 show Message, MessageTemplate; | 18 show Message, MessageTemplate; |
| 19 import 'package:compiler/src/enqueue.dart' show ResolutionEnqueuer; |
| 19 import 'package:compiler/src/io/source_file.dart'; | 20 import 'package:compiler/src/io/source_file.dart'; |
| 20 import 'package:compiler/src/options.dart'; | 21 import 'package:compiler/src/options.dart'; |
| 21 import 'package:compiler/src/parser/element_listener.dart' show ScannerOptions; | 22 import 'package:compiler/src/parser/element_listener.dart' show ScannerOptions; |
| 22 import 'package:compiler/src/parser/node_listener.dart' show NodeListener; | 23 import 'package:compiler/src/parser/node_listener.dart' show NodeListener; |
| 23 import 'package:compiler/src/parser/diet_parser_task.dart' show PartialParser; | 24 import 'package:compiler/src/parser/diet_parser_task.dart' show PartialParser; |
| 24 import 'package:compiler/src/platform_configuration.dart' as platform; | 25 import 'package:compiler/src/platform_configuration.dart' as platform; |
| 25 import 'package:compiler/src/source_file_provider.dart'; | 26 import 'package:compiler/src/source_file_provider.dart'; |
| 26 import 'package:compiler/src/universe/world_impact.dart' show WorldImpact; | 27 import 'package:compiler/src/universe/world_impact.dart' show WorldImpact; |
| 27 import 'package:front_end/src/fasta/parser.dart' show Listener, Parser; | 28 import 'package:front_end/src/fasta/parser.dart' show Listener, Parser; |
| 28 import 'package:front_end/src/fasta/scanner.dart' show Token, scan; | 29 import 'package:front_end/src/fasta/scanner.dart' show Token, scan; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 340 |
| 340 // We subclass compiler to skip phases and stop after creating kernel. | 341 // We subclass compiler to skip phases and stop after creating kernel. |
| 341 class MyCompiler extends CompilerImpl { | 342 class MyCompiler extends CompilerImpl { |
| 342 MyCompiler(CompilerInput provider, CompilerDiagnostics handler, | 343 MyCompiler(CompilerInput provider, CompilerDiagnostics handler, |
| 343 CompilerOptions options) | 344 CompilerOptions options) |
| 344 : super(provider, null, handler, options) {} | 345 : super(provider, null, handler, options) {} |
| 345 | 346 |
| 346 /// Performs the compilation when all libraries have been loaded. | 347 /// Performs the compilation when all libraries have been loaded. |
| 347 void compileLoadedLibraries() => | 348 void compileLoadedLibraries() => |
| 348 selfTask.measureSubtask('KernelCompiler.compileLoadedLibraries', () { | 349 selfTask.measureSubtask('KernelCompiler.compileLoadedLibraries', () { |
| 350 ResolutionEnqueuer resolutionEnqueuer = startResolution(); |
| 349 WorldImpact mainImpact = computeMain(); | 351 WorldImpact mainImpact = computeMain(); |
| 350 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 352 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
| 351 | 353 |
| 352 deferredLoadTask.beforeResolution(this); | 354 deferredLoadTask.beforeResolution(this); |
| 353 impactStrategy = backend.createImpactStrategy( | 355 impactStrategy = backend.createImpactStrategy( |
| 354 supportDeferredLoad: deferredLoadTask.isProgramSplit, | 356 supportDeferredLoad: deferredLoadTask.isProgramSplit, |
| 355 supportDumpInfo: options.dumpInfo, | 357 supportDumpInfo: options.dumpInfo, |
| 356 supportSerialization: serialization.supportSerialization); | 358 supportSerialization: serialization.supportSerialization); |
| 357 | 359 |
| 358 phase = Compiler.PHASE_RESOLVING; | 360 phase = Compiler.PHASE_RESOLVING; |
| 359 enqueuer.resolution.applyImpact(mainImpact); | 361 resolutionEnqueuer.applyImpact(mainImpact); |
| 360 // Note: we enqueue everything in the program so we measure generating | 362 // Note: we enqueue everything in the program so we measure generating |
| 361 // kernel for the entire code, not just what's reachable from main. | 363 // kernel for the entire code, not just what's reachable from main. |
| 362 libraryLoader.libraries.forEach((LibraryElement library) { | 364 libraryLoader.libraries.forEach((LibraryElement library) { |
| 363 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); | 365 resolutionEnqueuer.applyImpact(computeImpactForLibrary(library)); |
| 364 }); | 366 }); |
| 365 | 367 |
| 366 if (deferredLoadTask.isProgramSplit) { | 368 if (deferredLoadTask.isProgramSplit) { |
| 367 enqueuer.resolution | 369 resolutionEnqueuer |
| 368 .applyImpact(backend.computeDeferredLoadingImpact()); | 370 .applyImpact(backend.computeDeferredLoadingImpact()); |
| 369 } | 371 } |
| 370 resolveLibraryMetadata(); | 372 resolveLibraryMetadata(); |
| 371 reporter.log('Resolving...'); | 373 reporter.log('Resolving...'); |
| 372 processQueue(enqueuer.resolution, mainFunction, libraryLoader.libraries)
; | 374 processQueue(resolutionEnqueuer, mainFunction, libraryLoader.libraries); |
| 373 enqueuer.resolution.logSummary(reporter.log); | 375 resolutionEnqueuer.logSummary(reporter.log); |
| 374 | 376 |
| 375 (reporter as CompilerDiagnosticReporter) | 377 (reporter as CompilerDiagnosticReporter) |
| 376 .reportSuppressedMessagesSummary(); | 378 .reportSuppressedMessagesSummary(); |
| 377 | 379 |
| 378 if (compilationFailed) { | 380 if (compilationFailed) { |
| 379 // TODO(sigmund): more diagnostics? | 381 // TODO(sigmund): more diagnostics? |
| 380 print('compilation failed!'); | 382 print('compilation failed!'); |
| 381 exit(1); | 383 exit(1); |
| 382 } | 384 } |
| 383 | 385 |
| 384 closeResolution(); | 386 closeResolution(); |
| 385 var program = (backend as dynamic).kernelTask.program; | 387 var program = (backend as dynamic).kernelTask.program; |
| 386 print('total libraries: ${program.libraries.length}'); | 388 print('total libraries: ${program.libraries.length}'); |
| 387 }); | 389 }); |
| 388 } | 390 } |
| OLD | NEW |