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

Unified Diff: pkg/compiler/lib/src/resolution/registry.dart

Issue 1385183002: Revert "Avoid eager enqueueing from resolution" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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/resolution/members.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/registry.dart
diff --git a/pkg/compiler/lib/src/resolution/registry.dart b/pkg/compiler/lib/src/resolution/registry.dart
index 51aa37c4250bc8f48dd5b956d449e5505b10d7b0..592ad34752185c443f2b47bd25225bead02d8b19 100644
--- a/pkg/compiler/lib/src/resolution/registry.dart
+++ b/pkg/compiler/lib/src/resolution/registry.dart
@@ -7,11 +7,6 @@ library dart2js.resolution.registry;
import '../common/backend_api.dart' show
Backend,
ForeignResolver;
-import '../common/resolution.dart' show
- Feature,
- ListLiteralUse,
- MapLiteralUse,
- ResolutionWorldImpact;
import '../common/registry.dart' show
Registry;
import '../compiler.dart' show
@@ -21,9 +16,9 @@ import '../dart_types.dart';
import '../diagnostics/invariant.dart' show
invariant;
import '../enqueue.dart' show
- ResolutionEnqueuer;
+ ResolutionEnqueuer,
+ WorldImpact;
import '../elements/elements.dart';
-import '../helpers/helpers.dart';
import '../tree/tree.dart';
import '../util/util.dart' show
Setlet;
@@ -42,7 +37,11 @@ import 'members.dart' show
import 'tree_elements.dart' show
TreeElementMapping;
-// TODO(johnniwinther): Remove this.
+/// [ResolutionRegistry] collects all resolution information. It stores node
+/// related information in a [TreeElements] mapping and registers calls with
+/// [Backend], [World] and [Enqueuer].
+// TODO(johnniwinther): Split this into an interface and implementation class.
+
class EagerRegistry implements Registry {
final Compiler compiler;
final TreeElementMapping mapping;
@@ -101,34 +100,18 @@ class EagerRegistry implements Registry {
String toString() => 'EagerRegistry for ${mapping.analyzedElement}';
}
-class _ResolutionWorldImpact implements ResolutionWorldImpact {
+class ResolutionWorldImpact implements WorldImpact {
final Registry registry;
- // TODO(johnniwinther): Do we benefit from lazy initialization of the
- // [Setlet]s?
Setlet<UniverseSelector> _dynamicInvocations;
Setlet<UniverseSelector> _dynamicGetters;
Setlet<UniverseSelector> _dynamicSetters;
Setlet<InterfaceType> _instantiatedTypes;
Setlet<Element> _staticUses;
- Setlet<DartType> _isChecks;
- Setlet<DartType> _asCasts;
- Setlet<DartType> _checkedModeChecks;
+ Setlet<DartType> _checkedTypes;
Setlet<MethodElement> _closurizedFunctions;
- Setlet<LocalFunctionElement> _closures;
- Setlet<Feature> _features;
- // TODO(johnniwinther): This seems to be a union of other sets.
- Setlet<DartType> _requiredTypes;
- Setlet<MapLiteralUse> _mapLiterals;
- Setlet<ListLiteralUse> _listLiterals;
- Setlet<DartType> _typeLiterals;
- Setlet<String> _constSymbolNames;
-
- _ResolutionWorldImpact(Compiler compiler, TreeElementMapping mapping)
- : this.registry = new EagerRegistry(compiler, mapping);
- void registerDependency(Element element) {
- registry.registerDependency(element);
- }
+ ResolutionWorldImpact(Compiler compiler, TreeElementMapping mapping)
+ : this.registry = new EagerRegistry(compiler, mapping);
void registerDynamicGetter(UniverseSelector selector) {
if (_dynamicGetters == null) {
@@ -170,6 +153,10 @@ class _ResolutionWorldImpact implements ResolutionWorldImpact {
}
void registerInstantiatedType(InterfaceType type) {
+ // TODO(johnniwinther): Enable this when registration doesn't require a
+ // [Registry].
+ throw new UnsupportedError(
+ 'Lazy registration of instantiated not supported.');
if (_instantiatedTypes == null) {
_instantiatedTypes = new Setlet<InterfaceType>();
}
@@ -182,58 +169,6 @@ class _ResolutionWorldImpact implements ResolutionWorldImpact {
? _instantiatedTypes : const <InterfaceType>[];
}
- void registerTypeLiteral(DartType type) {
- if (_typeLiterals == null) {
- _typeLiterals = new Setlet<DartType>();
- }
- _typeLiterals.add(type);
- }
-
- @override
- Iterable<DartType> get typeLiterals {
- return _typeLiterals != null
- ? _typeLiterals : const <DartType>[];
- }
-
- void registerRequiredType(DartType type) {
- if (_requiredTypes == null) {
- _requiredTypes = new Setlet<DartType>();
- }
- _requiredTypes.add(type);
- }
-
- @override
- Iterable<DartType> get requiredTypes {
- return _requiredTypes != null
- ? _requiredTypes : const <DartType>[];
- }
-
- void registerMapLiteral(MapLiteralUse mapLiteralUse) {
- if (_mapLiterals == null) {
- _mapLiterals = new Setlet<MapLiteralUse>();
- }
- _mapLiterals.add(mapLiteralUse);
- }
-
- @override
- Iterable<MapLiteralUse> get mapLiterals {
- return _mapLiterals != null
- ? _mapLiterals : const <MapLiteralUse>[];
- }
-
- void registerListLiteral(ListLiteralUse listLiteralUse) {
- if (_listLiterals == null) {
- _listLiterals = new Setlet<ListLiteralUse>();
- }
- _listLiterals.add(listLiteralUse);
- }
-
- @override
- Iterable<ListLiteralUse> get listLiterals {
- return _listLiterals != null
- ? _listLiterals : const <ListLiteralUse>[];
- }
-
void registerStaticUse(Element element) {
if (_staticUses == null) {
_staticUses = new Setlet<Element>();
@@ -246,43 +181,17 @@ class _ResolutionWorldImpact implements ResolutionWorldImpact {
return _staticUses != null ? _staticUses : const <Element>[];
}
- void registerIsCheck(DartType type) {
- if (_isChecks == null) {
- _isChecks = new Setlet<DartType>();
- }
- _isChecks.add(type);
- }
-
- @override
- Iterable<DartType> get isChecks {
- return _isChecks != null
- ? _isChecks : const <DartType>[];
- }
-
- void registerAsCast(DartType type) {
- if (_asCasts == null) {
- _asCasts = new Setlet<DartType>();
+ void registerCheckedType(DartType type) {
+ if (_checkedTypes == null) {
+ _checkedTypes = new Setlet<DartType>();
}
- _asCasts.add(type);
+ _checkedTypes.add(type);
}
@override
- Iterable<DartType> get asCasts {
- return _asCasts != null
- ? _asCasts : const <DartType>[];
- }
-
- void registerCheckedModeCheckedType(DartType type) {
- if (_checkedModeChecks == null) {
- _checkedModeChecks = new Setlet<DartType>();
- }
- _checkedModeChecks.add(type);
- }
-
- @override
- Iterable<DartType> get checkedModeChecks {
- return _checkedModeChecks != null
- ? _checkedModeChecks : const <DartType>[];
+ Iterable<DartType> get checkedTypes {
+ return _checkedTypes != null
+ ? _checkedTypes : const <DartType>[];
}
void registerClosurizedFunction(MethodElement element) {
@@ -297,61 +206,17 @@ class _ResolutionWorldImpact implements ResolutionWorldImpact {
return _closurizedFunctions != null
? _closurizedFunctions : const <MethodElement>[];
}
-
- void registerClosure(LocalFunctionElement element) {
- if (_closures == null) {
- _closures = new Setlet<LocalFunctionElement>();
- }
- _closures.add(element);
- }
-
- @override
- Iterable<LocalFunctionElement> get closures {
- return _closures != null
- ? _closures : const <LocalFunctionElement>[];
- }
-
- void registerConstSymbolName(String name) {
- if (_constSymbolNames == null) {
- _constSymbolNames = new Setlet<String>();
- }
- _constSymbolNames.add(name);
- }
-
- @override
- Iterable<String> get constSymbolNames {
- return _constSymbolNames != null
- ? _constSymbolNames : const <String>[];
- }
-
- void registerFeature(Feature feature) {
- if (_features == null) {
- _features = new Setlet<Feature>();
- }
- _features.add(feature);
- }
-
- @override
- Iterable<Feature> get features {
- return _features != null ? _features : const <Feature>[];
- }
-
- String toString() => '$registry';
}
-/// [ResolutionRegistry] collects all resolution information. It stores node
-/// related information in a [TreeElements] mapping and registers calls with
-/// [Backend], [World] and [Enqueuer].
-// TODO(johnniwinther): Split this into an interface and implementation class.
class ResolutionRegistry implements Registry {
final Compiler compiler;
final TreeElementMapping mapping;
- final _ResolutionWorldImpact worldImpact;
+ final ResolutionWorldImpact worldImpact;
ResolutionRegistry(Compiler compiler, TreeElementMapping mapping)
: this.compiler = compiler,
this.mapping = mapping,
- this.worldImpact = new _ResolutionWorldImpact(compiler, mapping);
+ this.worldImpact = new ResolutionWorldImpact(compiler, mapping);
bool get isForResolution => true;
@@ -536,7 +401,7 @@ class ResolutionRegistry implements Registry {
}
void registerImplicitSuperCall(FunctionElement superConstructor) {
- registerDependency(superConstructor);
+ universe.registerImplicitSuperCall(this, superConstructor);
}
// TODO(johnniwinther): Remove this.
@@ -548,49 +413,47 @@ class ResolutionRegistry implements Registry {
}
void registerLazyField() {
- worldImpact.registerFeature(Feature.LAZY_FIELD);
+ backend.resolutionCallbacks.onLazyField(this);
}
- void registerMetadataConstant(MetadataAnnotation metadata) {
- backend.registerMetadataConstant(metadata, metadata.annotatedElement, this);
+ void registerMetadataConstant(MetadataAnnotation metadata,
+ Element annotatedElement) {
+ backend.registerMetadataConstant(metadata, annotatedElement, this);
}
void registerThrowRuntimeError() {
- worldImpact.registerFeature(Feature.THROW_RUNTIME_ERROR);
+ backend.resolutionCallbacks.onThrowRuntimeError(this);
}
void registerCompileTimeError(ErroneousElement error) {
- worldImpact.registerFeature(Feature.COMPILE_TIME_ERROR);
+ backend.resolutionCallbacks.onCompileTimeError(this, error);
}
void registerTypeVariableBoundCheck() {
- worldImpact.registerFeature(Feature.TYPE_VARIABLE_BOUNDS_CHECK);
+ backend.resolutionCallbacks.onTypeVariableBoundCheck(this);
}
void registerThrowNoSuchMethod() {
- worldImpact.registerFeature(Feature.THROW_NO_SUCH_METHOD);
+ backend.resolutionCallbacks.onThrowNoSuchMethod(this);
}
- /// Register a checked mode check against [type].
- void registerCheckedModeCheck(DartType type) {
- worldImpact.registerCheckedModeCheckedType(type);
- mapping.addRequiredType(type);
- }
-
- /// Register an is-test or is-not-test of [type].
void registerIsCheck(DartType type) {
- worldImpact.registerIsCheck(type);
+ worldImpact.registerCheckedType(type);
+ backend.resolutionCallbacks.onIsCheck(type, this);
mapping.addRequiredType(type);
}
- /// Register an as-cast of [type].
- void registerAsCast(DartType type) {
- worldImpact.registerAsCast(type);
+ void registerAsCheck(DartType type) {
+ registerIsCheck(type);
+ backend.resolutionCallbacks.onAsCheck(type, this);
mapping.addRequiredType(type);
}
void registerClosure(LocalFunctionElement element) {
- worldImpact.registerClosure(element);
+ if (element.computeType(compiler.resolution).containsTypeVariables) {
+ backend.registerClosureWithFreeTypeVariables(element, world, this);
+ }
+ world.registerClosure(element);
}
void registerSuperUse(Node node) {
@@ -602,30 +465,22 @@ class ResolutionRegistry implements Registry {
}
void registerSuperNoSuchMethod() {
- worldImpact.registerFeature(Feature.SUPER_NO_SUCH_METHOD);
+ backend.resolutionCallbacks.onSuperNoSuchMethod(this);
}
- void registerTypeLiteral(Send node, DartType type) {
- mapping.setType(node, type);
- worldImpact.registerTypeLiteral(type);
+ void registerTypeVariableExpression(TypeVariableElement element) {
+ backend.resolutionCallbacks.onTypeVariableExpression(this, element);
}
- void registerLiteralList(Node node,
- InterfaceType type,
- {bool isConstant,
- bool isEmpty}) {
- setType(node, type);
- worldImpact.registerListLiteral(
- new ListLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty));
+ void registerTypeLiteral(Send node, DartType type) {
+ mapping.setType(node, type);
+ backend.resolutionCallbacks.onTypeLiteral(type, this);
+ backend.registerInstantiatedType(compiler.coreTypes.typeType, world, this);
}
- void registerMapLiteral(Node node,
- InterfaceType type,
- {bool isConstant,
- bool isEmpty}) {
+ void registerMapLiteral(Node node, DartType type, bool isConstant) {
setType(node, type);
- worldImpact.registerMapLiteral(
- new MapLiteralUse(type, isConstant: isConstant, isEmpty: isEmpty));
+ backend.resolutionCallbacks.onMapLiteral(this, type, isConstant);
}
void registerForeignCall(Node node,
@@ -652,49 +507,49 @@ class ResolutionRegistry implements Registry {
}
void registerConstSymbol(String name) {
- worldImpact.registerConstSymbolName(name);
+ backend.registerConstSymbol(name, this);
}
void registerSymbolConstructor() {
- worldImpact.registerFeature(Feature.SYMBOL_CONSTRUCTOR);
+ backend.resolutionCallbacks.onSymbolConstructor(this);
}
void registerInstantiatedType(InterfaceType type) {
- worldImpact.registerInstantiatedType(type);
+ backend.registerInstantiatedType(type, world, this);
mapping.addRequiredType(type);
}
void registerAbstractClassInstantiation() {
- worldImpact.registerFeature(Feature.ABSTRACT_CLASS_INSTANTIATION);
+ backend.resolutionCallbacks.onAbstractClassInstantiation(this);
}
void registerNewSymbol() {
- worldImpact.registerFeature(Feature.NEW_SYMBOL);
+ backend.registerNewSymbol(this);
}
void registerRequiredType(DartType type, Element enclosingElement) {
- worldImpact.registerRequiredType(type);
+ backend.registerRequiredType(type, enclosingElement);
mapping.addRequiredType(type);
}
void registerStringInterpolation() {
- worldImpact.registerFeature(Feature.STRING_INTERPOLATION);
+ backend.resolutionCallbacks.onStringInterpolation(this);
}
void registerFallThroughError() {
- worldImpact.registerFeature(Feature.FALL_THROUGH_ERROR);
+ backend.resolutionCallbacks.onFallThroughError(this);
}
void registerCatchStatement() {
- worldImpact.registerFeature(Feature.CATCH_STATEMENT);
+ backend.resolutionCallbacks.onCatchStatement(this);
}
void registerStackTraceInCatch() {
- worldImpact.registerFeature(Feature.STACK_TRACE_IN_CATCH);
+ backend.resolutionCallbacks.onStackTraceInCatch(this);
}
void registerSyncForIn(Node node) {
- worldImpact.registerFeature(Feature.SYNC_FOR_IN);
+ backend.resolutionCallbacks.onSyncForIn(this);
}
ClassElement defaultSuperclass(ClassElement element) {
@@ -707,7 +562,7 @@ class ResolutionRegistry implements Registry {
}
void registerThrowExpression() {
- worldImpact.registerFeature(Feature.THROW_EXPRESSION);
+ backend.resolutionCallbacks.onThrowExpression(this);
}
void registerDependency(Element element) {
@@ -725,12 +580,11 @@ class ResolutionRegistry implements Registry {
}
void registerInstantiation(InterfaceType type) {
- registerInstantiatedType(type);
+ backend.registerInstantiatedType(type, world, this);
}
void registerAssert(bool hasMessage) {
- worldImpact.registerFeature(
- hasMessage ? Feature.ASSERT_WITH_MESSAGE : Feature.ASSERT);
+ backend.resolutionCallbacks.onAssert(hasMessage, this);
}
void registerSendStructure(Send node, SendStructure sendStructure) {
@@ -744,27 +598,15 @@ class ResolutionRegistry implements Registry {
}
void registerAsyncMarker(FunctionElement element) {
- switch (element.asyncMarker) {
- case AsyncMarker.SYNC:
- break;
- case AsyncMarker.SYNC_STAR:
- worldImpact.registerFeature(Feature.SYNC_STAR);
- break;
- case AsyncMarker.ASYNC:
- worldImpact.registerFeature(Feature.ASYNC);
- break;
- case AsyncMarker.ASYNC_STAR:
- worldImpact.registerFeature(Feature.ASYNC_STAR);
- break;
- }
+ backend.registerAsyncMarker(element, world, this);
}
void registerAsyncForIn(AsyncForIn node) {
- worldImpact.registerFeature(Feature.ASYNC_FOR_IN);
+ backend.resolutionCallbacks.onAsyncForIn(node, this);
}
void registerIncDecOperation() {
- worldImpact.registerFeature(Feature.INC_DEC_OPERATION);
+ backend.resolutionCallbacks.onIncDecOperation(this);
}
void registerTryStatement() {
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698