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

Side by Side Diff: pkg/compiler/lib/src/compiler.dart

Issue 2735763002: Create ResolutionEnqueuer after library loading. (Closed)
Patch Set: Fix. Created 3 years, 9 months 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) 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 library dart2js.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show EventSink, Future; 7 import 'dart:async' show EventSink, Future;
8 8
9 import '../compiler_new.dart' as api; 9 import '../compiler_new.dart' as api;
10 import 'closure.dart' as closureMapping show ClosureTask; 10 import 'closure.dart' as closureMapping show ClosureTask;
(...skipping 21 matching lines...) Expand all
32 import 'dump_info.dart' show DumpInfoTask; 32 import 'dump_info.dart' show DumpInfoTask;
33 import 'elements/elements.dart'; 33 import 'elements/elements.dart';
34 import 'elements/entities.dart'; 34 import 'elements/entities.dart';
35 import 'elements/modelx.dart' show ErroneousElementX; 35 import 'elements/modelx.dart' show ErroneousElementX;
36 import 'elements/resolution_types.dart' 36 import 'elements/resolution_types.dart'
37 show 37 show
38 ResolutionDartType, 38 ResolutionDartType,
39 ResolutionDynamicType, 39 ResolutionDynamicType,
40 ResolutionInterfaceType, 40 ResolutionInterfaceType,
41 Types; 41 Types;
42 import 'enqueue.dart' show Enqueuer, EnqueueTask, ResolutionEnqueuer; 42 import 'enqueue.dart'
43 show DeferredAction, Enqueuer, EnqueueTask, ResolutionEnqueuer;
43 import 'environment.dart'; 44 import 'environment.dart';
44 import 'id_generator.dart'; 45 import 'id_generator.dart';
45 import 'io/source_information.dart' show SourceInformation; 46 import 'io/source_information.dart' show SourceInformation;
46 import 'js_backend/backend.dart' show JavaScriptBackend; 47 import 'js_backend/backend.dart' show JavaScriptBackend;
47 import 'library_loader.dart' 48 import 'library_loader.dart'
48 show 49 show
49 ElementScanner, 50 ElementScanner,
50 LibraryLoader, 51 LibraryLoader,
51 LibraryLoaderTask, 52 LibraryLoaderTask,
52 LoadedLibraries, 53 LoadedLibraries,
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 /// This operation assumes an unclosed resolution queue and is only supported 569 /// This operation assumes an unclosed resolution queue and is only supported
569 /// when the '--analyze-main' option is used. 570 /// when the '--analyze-main' option is used.
570 Future<LibraryElement> analyzeUri(Uri libraryUri, 571 Future<LibraryElement> analyzeUri(Uri libraryUri,
571 {bool skipLibraryWithPartOfTag: true}) { 572 {bool skipLibraryWithPartOfTag: true}) {
572 assert(options.analyzeMain); 573 assert(options.analyzeMain);
573 reporter.log('Analyzing $libraryUri (${options.buildId})'); 574 reporter.log('Analyzing $libraryUri (${options.buildId})');
574 return libraryLoader 575 return libraryLoader
575 .loadLibrary(libraryUri, skipFileWithPartOfTag: true) 576 .loadLibrary(libraryUri, skipFileWithPartOfTag: true)
576 .then((LibraryElement library) { 577 .then((LibraryElement library) {
577 if (library == null) return null; 578 if (library == null) return null;
578 enqueuer.resolution.applyImpact(computeImpactForLibrary(library)); 579 ResolutionEnqueuer resolutionEnqueuer = startResolution();
579 emptyQueue(enqueuer.resolution, onProgress: showResolutionProgress); 580 resolutionEnqueuer.applyImpact(computeImpactForLibrary(library));
580 enqueuer.resolution.logSummary(reporter.log); 581 emptyQueue(resolutionEnqueuer, onProgress: showResolutionProgress);
582 resolutionEnqueuer.logSummary(reporter.log);
581 return library; 583 return library;
582 }); 584 });
583 } 585 }
584 586
587 /// Starts the resolution phase, creating the [ResolutionEnqueuer] if not
588 /// already created.
Siggi Cherem (dart-lang) 2017/03/14 05:27:55 why would it be created before? or is that only in
Johnni Winther 2017/03/15 12:46:53 Due to [analyzeUri]. Added to the comment.
589 ResolutionEnqueuer startResolution() {
590 ResolutionEnqueuer resolutionEnqueuer;
591 if (enqueuer.hasResolution) {
592 resolutionEnqueuer = enqueuer.resolution;
593 } else {
594 resolutionEnqueuer = enqueuer.createResolutionEnqueuer();
595 backend.onResolutionStart(resolutionEnqueuer);
596 }
597 resolutionEnqueuer.addDeferredActions(libraryLoader.pullDeferredActions());
598 return resolutionEnqueuer;
599 }
600
585 /// Performs the compilation when all libraries have been loaded. 601 /// Performs the compilation when all libraries have been loaded.
586 void compileLoadedLibraries() => 602 void compileLoadedLibraries() =>
587 selfTask.measureSubtask("Compiler.compileLoadedLibraries", () { 603 selfTask.measureSubtask("Compiler.compileLoadedLibraries", () {
588 Enqueuer resolutionEnqueuer = enqueuer.createResolutionEnqueuer(); 604 ResolutionEnqueuer resolutionEnqueuer = startResolution();
589 WorldImpact mainImpact = computeMain(); 605 WorldImpact mainImpact = computeMain();
590 606
591 mirrorUsageAnalyzerTask.analyzeUsage(mainApp); 607 mirrorUsageAnalyzerTask.analyzeUsage(mainApp);
592 608
593 // In order to see if a library is deferred, we must compute the 609 // In order to see if a library is deferred, we must compute the
594 // compile-time constants that are metadata. This means adding 610 // compile-time constants that are metadata. This means adding
595 // something to the resolution queue. So we cannot wait with 611 // something to the resolution queue. So we cannot wait with
596 // this until after the resolution queue is processed. 612 // this until after the resolution queue is processed.
597 deferredLoadTask.beforeResolution(this); 613 deferredLoadTask.beforeResolution(this);
598 impactStrategy = backend.createImpactStrategy( 614 impactStrategy = backend.createImpactStrategy(
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 if (library != null && library.isSynthesized) { 2059 if (library != null && library.isSynthesized) {
2044 return null; 2060 return null;
2045 } 2061 }
2046 if (library == null && required) { 2062 if (library == null && required) {
2047 throw new SpannableAssertionFailure( 2063 throw new SpannableAssertionFailure(
2048 library, "The library '${uri}' was not found."); 2064 library, "The library '${uri}' was not found.");
2049 } 2065 }
2050 return library; 2066 return library;
2051 } 2067 }
2052 } 2068 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/enqueue.dart » ('j') | pkg/compiler/lib/src/library_loader.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698