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

Unified Diff: pkg/compiler/lib/src/enqueue.dart

Issue 1376863004: Avoid eager enqueueing from resolution (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix deferred+mirrors bug. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/enqueue.dart
diff --git a/pkg/compiler/lib/src/enqueue.dart b/pkg/compiler/lib/src/enqueue.dart
index 6d71d732d8992e8e5f5da11e092beae0165bd250..212218df4d94697e8b4708ccfcdcd1752f06d0d5 100644
--- a/pkg/compiler/lib/src/enqueue.dart
+++ b/pkg/compiler/lib/src/enqueue.dart
@@ -112,9 +112,15 @@ class WorldImpact {
// TODO(johnniwinther): Collect checked types for checked mode separately to
// support serialization.
- Iterable<DartType> get checkedTypes => const <DartType>[];
+ Iterable<DartType> get isChecks => const <DartType>[];
+
+ Iterable<DartType> get checkedModeChecks => const <DartType>[];
+
+ Iterable<DartType> get asCasts => const <DartType>[];
Iterable<MethodElement> get closurizedFunctions => const <MethodElement>[];
+
+ Iterable<LocalFunctionElement> get closures => const <LocalFunctionElement>[];
}
abstract class Enqueuer {
@@ -161,6 +167,10 @@ abstract class Enqueuer {
/// Returns [:true:] if [member] has been processed by this enqueuer.
bool isProcessed(Element member);
+ bool isClassProcessed(ClassElement cls) => _processedClasses.contains(cls);
+
+ Iterable<ClassElement> get processedClasses => _processedClasses;
+
/**
* Documentation wanted -- johnniwinther
*
@@ -190,10 +200,14 @@ abstract class Enqueuer {
worldImpact.dynamicGetters.forEach(registerDynamicGetter);
worldImpact.dynamicSetters.forEach(registerDynamicSetter);
worldImpact.staticUses.forEach(registerStaticUse);
- // TODO(johnniwinther): Register [worldImpact.instantiatedTypes] when it
- // doesn't require a [Registry].
- worldImpact.checkedTypes.forEach(registerIsCheck);
+ worldImpact.instantiatedTypes.forEach(registerInstantiatedType);
+ worldImpact.isChecks.forEach(registerIsCheck);
+ worldImpact.asCasts.forEach(registerIsCheck);
+ if (compiler.enableTypeAssertions) {
+ worldImpact.checkedModeChecks.forEach(registerIsCheck);
+ }
worldImpact.closurizedFunctions.forEach(registerGetOfStaticFunction);
+ worldImpact.closures.forEach(registerClosure);
}
// TODO(johnniwinther): Remove the need for passing the [registry].
@@ -334,6 +348,15 @@ abstract class Enqueuer {
void processClass(ClassElement superclass) {
if (_processedClasses.contains(superclass)) return;
+ // TODO(johnniwinther): Re-insert this invariant when unittests don't
+ // fail. There is already a similar invariant on the members.
+ /*if (!isResolutionQueue) {
+ assert(invariant(superclass,
+ superclass.isClosure ||
+ compiler.enqueuer.resolution.isClassProcessed(superclass),
+ message: "Class $superclass has not been "
+ "processed in resolution."));
+ }*/
_processedClasses.add(superclass);
recentClasses.add(superclass);
@@ -767,7 +790,7 @@ class ResolutionEnqueuer extends Enqueuer {
*
* Invariant: Key elements are declaration elements.
*/
- final Set<AstElement> resolvedElements;
+ final Set<AstElement> processedElements;
final Queue<ResolutionWorkItem> queue;
@@ -784,22 +807,22 @@ class ResolutionEnqueuer extends Enqueuer {
compiler,
itemCompilationContextCreator,
strategy),
- resolvedElements = new Set<AstElement>(),
+ processedElements = new Set<AstElement>(),
queue = new Queue<ResolutionWorkItem>(),
deferredTaskQueue = new Queue<DeferredTask>();
bool get isResolutionQueue => true;
- bool isProcessed(Element member) => resolvedElements.contains(member);
+ bool isProcessed(Element member) => processedElements.contains(member);
/// Returns `true` if [element] has been processed by the resolution enqueuer.
- bool hasBeenResolved(Element element) {
- return resolvedElements.contains(element.analyzableElement.declaration);
+ bool hasBeenProcessed(Element element) {
+ return processedElements.contains(element.analyzableElement.declaration);
}
- /// Registers [element] as resolved for the resolution enqueuer.
- void registerResolvedElement(AstElement element) {
- resolvedElements.add(element);
+ /// Registers [element] as processed by the resolution enqueuer.
+ void registerProcessedElement(AstElement element) {
+ processedElements.add(element);
}
/**
@@ -820,7 +843,7 @@ class ResolutionEnqueuer extends Enqueuer {
assert(invariant(element, element is AnalyzableElement,
message: 'Element $element is not analyzable.'));
- if (hasBeenResolved(element)) return false;
+ if (hasBeenProcessed(element)) return false;
if (queueIsClosed) {
throw new SpannableAssertionFailure(element,
"Resolution work list is closed. Trying to add $element.");
@@ -912,12 +935,12 @@ class ResolutionEnqueuer extends Enqueuer {
}
void _logSpecificSummary(log(message)) {
- log('Resolved ${resolvedElements.length} elements.');
+ log('Resolved ${processedElements.length} elements.');
}
void forgetElement(Element element) {
super.forgetElement(element);
- resolvedElements.remove(element);
+ processedElements.remove(element);
}
}
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698