Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1044)

Side by Side Diff: pkg/compiler/tool/perf.dart

Issue 2527973002: Remove direct access to enqueuer through use of WorldImpact (Closed)
Patch Set: Cleanup Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/kernel/task.dart';
15 import 'package:compiler/src/elements/elements.dart'; 14 import 'package:compiler/src/elements/elements.dart';
16 import 'package:compiler/src/common.dart'; 15 import 'package:compiler/src/common.dart';
17 import 'package:compiler/src/diagnostics/diagnostic_listener.dart'; 16 import 'package:compiler/src/diagnostics/diagnostic_listener.dart';
18 import 'package:compiler/src/diagnostics/messages.dart' 17 import 'package:compiler/src/diagnostics/messages.dart'
19 show Message, MessageTemplate; 18 show Message, MessageTemplate;
20 import 'package:compiler/src/io/source_file.dart'; 19 import 'package:compiler/src/io/source_file.dart';
21 import 'package:compiler/src/options.dart'; 20 import 'package:compiler/src/options.dart';
22 import 'package:compiler/src/parser/element_listener.dart' show ScannerOptions; 21 import 'package:compiler/src/parser/element_listener.dart' show ScannerOptions;
23 import 'package:compiler/src/parser/listener.dart'; 22 import 'package:compiler/src/parser/listener.dart';
24 import 'package:compiler/src/parser/node_listener.dart' show NodeListener; 23 import 'package:compiler/src/parser/node_listener.dart' show NodeListener;
25 import 'package:compiler/src/parser/parser.dart' show Parser; 24 import 'package:compiler/src/parser/parser.dart' show Parser;
26 import 'package:compiler/src/parser/partial_parser.dart'; 25 import 'package:compiler/src/parser/partial_parser.dart';
27 import 'package:compiler/src/platform_configuration.dart' as platform; 26 import 'package:compiler/src/platform_configuration.dart' as platform;
28 import 'package:compiler/src/scanner/scanner.dart'; 27 import 'package:compiler/src/scanner/scanner.dart';
29 import 'package:compiler/src/source_file_provider.dart'; 28 import 'package:compiler/src/source_file_provider.dart';
30 import 'package:compiler/src/tokens/token.dart' show Token; 29 import 'package:compiler/src/tokens/token.dart' show Token;
30 import 'package:compiler/src/universe/world_impact.dart' show WorldImpact;
31 import 'package:package_config/discovery.dart' show findPackages; 31 import 'package:package_config/discovery.dart' show findPackages;
32 import 'package:package_config/packages.dart' show Packages; 32 import 'package:package_config/packages.dart' show Packages;
33 import 'package:package_config/src/util.dart' show checkValidPackageUri; 33 import 'package:package_config/src/util.dart' show checkValidPackageUri;
34 34
35 /// Cumulative total number of chars scanned. 35 /// Cumulative total number of chars scanned.
36 int scanTotalChars = 0; 36 int scanTotalChars = 0;
37 37
38 /// Cumulative time spent scanning. 38 /// Cumulative time spent scanning.
39 Stopwatch scanTimer = new Stopwatch(); 39 Stopwatch scanTimer = new Stopwatch();
40 40
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 // We subclass compiler to skip phases and stop after creating kernel. 353 // We subclass compiler to skip phases and stop after creating kernel.
354 class MyCompiler extends CompilerImpl { 354 class MyCompiler extends CompilerImpl {
355 MyCompiler(CompilerInput provider, CompilerDiagnostics handler, 355 MyCompiler(CompilerInput provider, CompilerDiagnostics handler,
356 CompilerOptions options) 356 CompilerOptions options)
357 : super(provider, null, handler, options) {} 357 : super(provider, null, handler, options) {}
358 358
359 /// Performs the compilation when all libraries have been loaded. 359 /// Performs the compilation when all libraries have been loaded.
360 void compileLoadedLibraries() => 360 void compileLoadedLibraries() =>
361 selfTask.measureSubtask("KernelCompiler.compileLoadedLibraries", () { 361 selfTask.measureSubtask("KernelCompiler.compileLoadedLibraries", () {
362 computeMain(); 362 WorldImpact mainImpact = computeMain();
363 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); 363 mirrorUsageAnalyzerTask.analyzeUsage(mainApp);
364 364
365 deferredLoadTask.beforeResolution(this); 365 deferredLoadTask.beforeResolution(this);
366 impactStrategy = backend.createImpactStrategy( 366 impactStrategy = backend.createImpactStrategy(
367 supportDeferredLoad: deferredLoadTask.isProgramSplit, 367 supportDeferredLoad: deferredLoadTask.isProgramSplit,
368 supportDumpInfo: options.dumpInfo, 368 supportDumpInfo: options.dumpInfo,
369 supportSerialization: serialization.supportSerialization); 369 supportSerialization: serialization.supportSerialization);
370 370
371 phase = Compiler.PHASE_RESOLVING; 371 phase = Compiler.PHASE_RESOLVING;
372 372 enqueuer.resolution.applyImpact(mainImpact);
373 // Note: we enqueue everything in the program so we measure generating 373 // Note: we enqueue everything in the program so we measure generating
374 // kernel for the entire code, not just what's reachable from main. 374 // kernel for the entire code, not just what's reachable from main.
375 libraryLoader.libraries.forEach((LibraryElement library) { 375 libraryLoader.libraries.forEach((LibraryElement library) {
376 fullyEnqueueLibrary(library, enqueuer.resolution); 376 fullyEnqueueLibrary(library, enqueuer.resolution);
377 }); 377 });
378 378
379 backend.enqueueHelpers(enqueuer.resolution); 379 if (deferredLoadTask.isProgramSplit) {
380 enqueuer.resolution.applyImpact(
381 backend.computeDeferredLoadingImpact());
382 }
383 enqueuer.resolution.applyImpact(backend.computeHelpersImpact());
380 resolveLibraryMetadata(); 384 resolveLibraryMetadata();
381 reporter.log('Resolving...'); 385 reporter.log('Resolving...');
382 processQueue(enqueuer.resolution, mainFunction); 386 processQueue(enqueuer.resolution, mainFunction);
383 enqueuer.resolution.logSummary(reporter.log); 387 enqueuer.resolution.logSummary(reporter.log);
384 388
385 (reporter as CompilerDiagnosticReporter) 389 (reporter as CompilerDiagnosticReporter)
386 .reportSuppressedMessagesSummary(); 390 .reportSuppressedMessagesSummary();
387 391
388 if (compilationFailed) { 392 if (compilationFailed) {
389 // TODO(sigmund): more diagnostics? 393 // TODO(sigmund): more diagnostics?
390 print("compilation failed!"); 394 print("compilation failed!");
391 exit(1); 395 exit(1);
392 } 396 }
393 397
394 closeResolution(); 398 closeResolution();
395 var program = (backend as dynamic).kernelTask.program; 399 var program = (backend as dynamic).kernelTask.program;
396 print('total libraries: ${program.libraries.length}'); 400 print('total libraries: ${program.libraries.length}');
397 }); 401 });
398 } 402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698