| 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/entities.dart' show LibraryEntity; | 14 import 'package:compiler/src/elements/entities.dart' show LibraryEntity; |
| 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/enqueue.dart' show ResolutionEnqueuer; |
| 20 import 'package:compiler/src/io/source_file.dart'; | 20 import 'package:compiler/src/io/source_file.dart'; |
| 21 import 'package:compiler/src/options.dart'; | 21 import 'package:compiler/src/options.dart'; |
| 22 import 'package:compiler/src/parser/element_listener.dart' show ScannerOptions; | 22 import 'package:compiler/src/parser/element_listener.dart' show ScannerOptions; |
| 23 import 'package:compiler/src/parser/node_listener.dart' show NodeListener; | 23 import 'package:compiler/src/parser/node_listener.dart' show NodeListener; |
| 24 import 'package:compiler/src/parser/diet_parser_task.dart' show PartialParser; | 24 import 'package:compiler/src/parser/diet_parser_task.dart' show PartialParser; |
| 25 import 'package:compiler/src/platform_configuration.dart' as platform; | 25 import 'package:compiler/src/platform_configuration.dart' as platform; |
| 26 import 'package:compiler/src/source_file_provider.dart'; | 26 import 'package:compiler/src/source_file_provider.dart'; |
| 27 import 'package:compiler/src/universe/world_impact.dart' show WorldImpact; | 27 import 'package:compiler/src/universe/world_impact.dart' |
| 28 show WorldImpactBuilderImpl; |
| 28 import 'package:front_end/src/fasta/parser.dart' show Listener, Parser; | 29 import 'package:front_end/src/fasta/parser.dart' show Listener, Parser; |
| 29 import 'package:front_end/src/fasta/scanner.dart' show Token, scan; | 30 import 'package:front_end/src/fasta/scanner.dart' show Token, scan; |
| 30 import 'package:package_config/discovery.dart' show findPackages; | 31 import 'package:package_config/discovery.dart' show findPackages; |
| 31 import 'package:package_config/packages.dart' show Packages; | 32 import 'package:package_config/packages.dart' show Packages; |
| 32 import 'package:package_config/src/util.dart' show checkValidPackageUri; | 33 import 'package:package_config/src/util.dart' show checkValidPackageUri; |
| 33 | 34 |
| 34 /// Cumulative total number of chars scanned. | 35 /// Cumulative total number of chars scanned. |
| 35 int inputSize = 0; | 36 int inputSize = 0; |
| 36 | 37 |
| 37 /// Cumulative time spent scanning. | 38 /// Cumulative time spent scanning. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 report('kernel_gen_e2e', timer.elapsedMicroseconds); | 339 report('kernel_gen_e2e', timer.elapsedMicroseconds); |
| 339 } | 340 } |
| 340 | 341 |
| 341 // We subclass compiler to skip phases and stop after creating kernel. | 342 // We subclass compiler to skip phases and stop after creating kernel. |
| 342 class MyCompiler extends CompilerImpl { | 343 class MyCompiler extends CompilerImpl { |
| 343 MyCompiler(CompilerInput provider, CompilerDiagnostics handler, | 344 MyCompiler(CompilerInput provider, CompilerDiagnostics handler, |
| 344 CompilerOptions options) | 345 CompilerOptions options) |
| 345 : super(provider, null, handler, options) {} | 346 : super(provider, null, handler, options) {} |
| 346 | 347 |
| 347 /// Performs the compilation when all libraries have been loaded. | 348 /// Performs the compilation when all libraries have been loaded. |
| 348 void compileLoadedLibraries() => | 349 void compileLoadedLibraries(LibraryEntity rootLibrary) => |
| 349 selfTask.measureSubtask('KernelCompiler.compileLoadedLibraries', () { | 350 selfTask.measureSubtask('KernelCompiler.compileLoadedLibraries', () { |
| 350 ResolutionEnqueuer resolutionEnqueuer = startResolution(); | 351 ResolutionEnqueuer resolutionEnqueuer = startResolution(); |
| 351 WorldImpact mainImpact = computeMain(); | 352 WorldImpactBuilderImpl mainImpact = new WorldImpactBuilderImpl(); |
| 353 mainFunction = frontEndStrategy.computeMain(rootLibrary, mainImpact); |
| 352 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); | 354 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); |
| 353 | 355 |
| 354 deferredLoadTask.beforeResolution(this); | 356 deferredLoadTask.beforeResolution(this); |
| 355 impactStrategy = backend.createImpactStrategy( | 357 impactStrategy = backend.createImpactStrategy( |
| 356 supportDeferredLoad: deferredLoadTask.isProgramSplit, | 358 supportDeferredLoad: deferredLoadTask.isProgramSplit, |
| 357 supportDumpInfo: options.dumpInfo, | 359 supportDumpInfo: options.dumpInfo, |
| 358 supportSerialization: serialization.supportSerialization); | 360 supportSerialization: serialization.supportSerialization); |
| 359 | 361 |
| 360 phase = Compiler.PHASE_RESOLVING; | 362 phase = Compiler.PHASE_RESOLVING; |
| 361 resolutionEnqueuer.applyImpact(mainImpact); | 363 resolutionEnqueuer.applyImpact(mainImpact); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 377 // TODO(sigmund): more diagnostics? | 379 // TODO(sigmund): more diagnostics? |
| 378 print('compilation failed!'); | 380 print('compilation failed!'); |
| 379 exit(1); | 381 exit(1); |
| 380 } | 382 } |
| 381 | 383 |
| 382 closeResolution(); | 384 closeResolution(); |
| 383 var program = (backend as dynamic).kernelTask.program; | 385 var program = (backend as dynamic).kernelTask.program; |
| 384 print('total libraries: ${program.libraries.length}'); | 386 print('total libraries: ${program.libraries.length}'); |
| 385 }); | 387 }); |
| 386 } | 388 } |
| OLD | NEW |