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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 2587913004: Move class/member computation from CodegenEnqueuer to CodegenWorldBuilder. (Closed)
Patch Set: Updated cf. comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index 2c1278855b7d214383b3dcd8118976fcf24f60c8..27507149e27f0a2db579992392785aa83dd02ad1 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -541,6 +541,7 @@ class JavaScriptBackend extends Backend {
PatchResolverTask patchResolverTask;
bool enabledNoSuchMethod = false;
+ bool _noSuchMethodEnabledForCodegen = false;
SourceInformationStrategy sourceInformationStrategy;
@@ -1306,6 +1307,11 @@ class JavaScriptBackend extends Backend {
noSuchMethodRegistry.onTypeInferenceComplete();
}
+ /// Called to register that an instantiated generic class has a call method.
+ /// Any backend specific [WorldImpact] of this is returned.
+ ///
+ /// Note: The [callMethod] is registered even thought it doesn't reference
+ /// the type variables.
WorldImpact registerCallMethodWithFreeTypeVariables(Element callMethod,
{bool forResolution}) {
if (forResolution || methodNeedsRti(callMethod)) {
@@ -1388,7 +1394,7 @@ class JavaScriptBackend extends Backend {
return null;
}
- WorldImpact enableNoSuchMethod() {
+ WorldImpact computeNoSuchMethodImpact() {
return impactTransformer.createImpactFor(impacts.noSuchMethodSupport);
}
@@ -1787,16 +1793,15 @@ class JavaScriptBackend extends Backend {
customElementsAnalysis.registerStaticUse(element,
forResolution: forResolution);
- if (forResolution) {
- if (element.isFunction && element.isInstanceMember) {
- MemberElement function = element;
- ClassElement cls = function.enclosingClass;
- if (function.name == Identifiers.call && !cls.typeVariables.isEmpty) {
- worldImpact.addImpact(registerCallMethodWithFreeTypeVariables(
- function,
- forResolution: true));
- }
+ if (element.isFunction && element.isInstanceMember) {
+ MemberElement function = element;
+ ClassElement cls = function.enclosingClass;
+ if (function.name == Identifiers.call && !cls.typeVariables.isEmpty) {
+ worldImpact.addImpact(registerCallMethodWithFreeTypeVariables(function,
+ forResolution: forResolution));
}
+ }
+ if (forResolution) {
// Enable isolate support if we start using something from the isolate
// library, or timers for the async library. We exclude constant fields,
// which are ending here because their initializing expression is
@@ -1831,6 +1836,10 @@ class JavaScriptBackend extends Backend {
} else if (compiler.commonElements.isFunctionApplyMethod(element)) {
hasFunctionApplySupport = true;
}
+ } else {
+ // TODO(sigmund): add other missing dependencies (internals, selectors
+ // enqueued after allocations).
+ compiler.dumpInfoTask.registerDependency(element);
}
return worldImpact;
}
@@ -2237,22 +2246,31 @@ class JavaScriptBackend extends Backend {
enqueuer.applyImpact(
typeVariableHandler.flush(forResolution: enqueuer.isResolutionQueue));
- if (!enqueuer.queueIsEmpty) return false;
-
- for (ClassElement cls in recentClasses) {
- Element element = cls.lookupLocalMember(Identifiers.noSuchMethod_);
- if (element != null && element.isInstanceMember && element.isFunction) {
- registerNoSuchMethod(element);
+ if (enqueuer.isResolutionQueue) {
+ for (ClassElement cls in recentClasses) {
+ Element element = cls.lookupLocalMember(Identifiers.noSuchMethod_);
+ if (element != null && element.isInstanceMember && element.isFunction) {
+ registerNoSuchMethod(element);
+ }
}
}
noSuchMethodRegistry.onQueueEmpty();
- if (!enabledNoSuchMethod &&
- (noSuchMethodRegistry.hasThrowingNoSuchMethod ||
- noSuchMethodRegistry.hasComplexNoSuchMethod)) {
- enqueuer.applyImpact(enableNoSuchMethod());
- enabledNoSuchMethod = true;
+ if (enqueuer.isResolutionQueue) {
+ if (!enabledNoSuchMethod &&
+ (noSuchMethodRegistry.hasThrowingNoSuchMethod ||
+ noSuchMethodRegistry.hasComplexNoSuchMethod)) {
+ enqueuer.applyImpact(computeNoSuchMethodImpact());
+ enabledNoSuchMethod = true;
+ }
+ } else {
+ if (enabledNoSuchMethod && !_noSuchMethodEnabledForCodegen) {
+ enqueuer.applyImpact(computeNoSuchMethodImpact());
+ _noSuchMethodEnabledForCodegen = true;
+ }
}
+ if (!enqueuer.queueIsEmpty) return false;
+
if (compiler.options.useKernel && compiler.mainApp != null) {
kernelTask.buildKernelIr();
}
« no previous file with comments | « pkg/compiler/lib/src/common/backend_api.dart ('k') | pkg/compiler/lib/src/js_backend/enqueuer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698