Chromium Code Reviews| Index: pkg/compiler/lib/src/universe/resolution_world_builder.dart |
| diff --git a/pkg/compiler/lib/src/universe/resolution_world_builder.dart b/pkg/compiler/lib/src/universe/resolution_world_builder.dart |
| index 7967585e351d41224772f345da16a190c526e8ed..7d9b5898d172de85500c1e1e7458b50197f940a2 100644 |
| --- a/pkg/compiler/lib/src/universe/resolution_world_builder.dart |
| +++ b/pkg/compiler/lib/src/universe/resolution_world_builder.dart |
| @@ -5,23 +5,29 @@ |
| part of world_builder; |
| abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld { |
| + /// Set of all local functions in the program. Used by the mirror tracking |
| + /// system to find all live closure instances. |
| + Iterable<LocalFunctionElement> get localFunctions; |
| + |
| /// Set of (live) local functions (closures) whose signatures reference type |
|
Siggi Cherem (dart-lang)
2017/03/14 03:02:34
Just to be sure: this is only for RTI and so it in
Johnni Winther
2017/03/14 16:59:46
Yes
|
| /// variables. |
| /// |
| /// A live function is one whose enclosing member function has been enqueued. |
| - Iterable<Element> get closuresWithFreeTypeVariables; |
| - |
| - /// Set of (live) `call` methods whose signatures reference type variables. |
| - /// |
| - /// A live `call` method is one whose enclosing class has been instantiated. |
| - Iterable<Element> get callMethodsWithFreeTypeVariables; |
| + Iterable<LocalFunctionElement> get localFunctionsWithFreeTypeVariables; |
| - /// Set of all closures in the program. Used by the mirror tracking system |
| - /// to find all live closure instances. |
| - Iterable<LocalFunctionElement> get allClosures; |
| + /// Set of live local functions (closures) whose signatures reference type |
| + /// variables. |
| + /// A local function is considered live if the enclosing member function is |
|
Siggi Cherem (dart-lang)
2017/03/14 03:02:34
nit: add extra line to divide the paragraph
Johnni Winther
2017/03/14 16:59:46
Duplicate paragraph, removed.
|
| + /// live. |
| /// Set of methods in instantiated classes that are potentially closurized. |
| - Iterable<Element> get closurizedMembers; |
| + Iterable<MethodElement> get closurizedMembers; |
| + |
| + /// Set of live closurized members whose signatures reference type variables. |
| + /// |
| + /// A `call` method is considered live if the enclosing class has been |
|
Siggi Cherem (dart-lang)
2017/03/14 03:02:34
`call` method => closurized member
Johnni Winther
2017/03/14 16:59:46
Done.
|
| + /// instantiated. |
| + Iterable<MethodElement> get closurizedMembersWithFreeTypeVariables; |
| /// Returns `true` if [cls] is considered to be implemented by an |
| /// instantiated class, either directly, through subclasses or through |
| @@ -57,9 +63,6 @@ abstract class ResolutionEnqueuerWorldBuilder extends ResolutionWorldBuilder { |
| /// Returns the classes registered as directly or indirectly instantiated. |
| Iterable<ClassEntity> get processedClasses; |
| - /// Registers that the generic [element] has been closurized. |
| - void registerClosureWithFreeTypeVariables(MemberEntity element); |
| - |
| /// Registers that [element] has been closurized. |
| void registerClosurizedMember(MemberEntity element); |
| @@ -303,32 +306,27 @@ class ElementResolutionWorldBuilder implements ResolutionEnqueuerWorldBuilder { |
| final Set<Element> fieldSetters = new Set<Element>(); |
| final Set<ResolutionDartType> isChecks = new Set<ResolutionDartType>(); |
| - /** |
| - * Set of (live) [:call:] methods whose signatures reference type variables. |
| - * |
| - * A live [:call:] method is one whose enclosing class has been instantiated. |
| - */ |
| - final Set<Element> callMethodsWithFreeTypeVariables = new Set<Element>(); |
| + /// Set of all closures in the program. Used by the mirror tracking system |
| + /// to find all live closure instances. |
| + final Set<LocalFunctionElement> localFunctions = |
| + new Set<LocalFunctionElement>(); |
| - /** |
| - * Set of (live) local functions (closures) whose signatures reference type |
| - * variables. |
| - * |
| - * A live function is one whose enclosing member function has been enqueued. |
| - */ |
| - final Set<Element> closuresWithFreeTypeVariables = new Set<Element>(); |
| + /// Set of live local functions (closures) whose signatures reference type |
| + /// variables. |
| + /// A local function is considered live if the enclosing member function is |
|
Siggi Cherem (dart-lang)
2017/03/14 03:02:34
\n
Johnni Winther
2017/03/14 16:59:46
Done.
|
| + /// live. |
| + final Set<LocalFunctionElement> localFunctionsWithFreeTypeVariables = |
| + new Set<LocalFunctionElement>(); |
| - /** |
| - * Set of all closures in the program. Used by the mirror tracking system |
| - * to find all live closure instances. |
| - */ |
| - final Set<LocalFunctionElement> allClosures = new Set<LocalFunctionElement>(); |
| + /// Set of methods in instantiated classes that are potentially closurized. |
| + final Set<MethodElement> closurizedMembers = new Set<MethodElement>(); |
| - /** |
| - * Set of methods in instantiated classes that are potentially |
| - * closurized. |
| - */ |
| - final Set<Element> closurizedMembers = new Set<Element>(); |
| + /// Set of live closurized members whose signatures reference type variables. |
| + /// |
| + /// A `call` method is considered live if the enclosing class has been |
|
Siggi Cherem (dart-lang)
2017/03/14 03:02:34
`call` method => closurized member
Johnni Winther
2017/03/14 16:59:46
Done.
|
| + /// instantiated. |
| + final Set<MethodElement> closurizedMembersWithFreeTypeVariables = |
| + new Set<MethodElement>(); |
| final SelectorConstraintsStrategy selectorConstraintsStrategy; |
| @@ -419,12 +417,11 @@ class ElementResolutionWorldBuilder implements ResolutionEnqueuerWorldBuilder { |
| return _implementedClasses.contains(cls.declaration); |
| } |
| - void registerClosureWithFreeTypeVariables(MemberElement element) { |
| - closuresWithFreeTypeVariables.add(element); |
| - } |
| - |
| void registerClosurizedMember(MemberElement element) { |
| closurizedMembers.add(element); |
| + if (element.type.containsTypeVariables) { |
| + closurizedMembersWithFreeTypeVariables.add(element); |
| + } |
| } |
| /// Register [type] as (directly) instantiated. |
| @@ -640,11 +637,11 @@ class ElementResolutionWorldBuilder implements ResolutionEnqueuerWorldBuilder { |
| fieldSetters.add(element); |
| break; |
| case StaticUseKind.CLOSURE: |
| - LocalFunctionElement closure = staticUse.element; |
| - if (closure.type.containsTypeVariables) { |
| - closuresWithFreeTypeVariables.add(closure); |
| + LocalFunctionElement localFunction = staticUse.element; |
| + if (localFunction.type.containsTypeVariables) { |
| + localFunctionsWithFreeTypeVariables.add(localFunction); |
| } |
| - allClosures.add(element); |
| + localFunctions.add(element); |
| break; |
| case StaticUseKind.SUPER_TEAR_OFF: |
| useSet.addAll(usage.tearOff()); |
| @@ -674,16 +671,6 @@ class ElementResolutionWorldBuilder implements ResolutionEnqueuerWorldBuilder { |
| } |
| } |
| - // TODO(ahe): Replace this method with something that is O(1), for example, |
| - // by using a map. |
| - List<LocalFunctionElement> slowDirectlyNestedClosures(Element element) { |
| - // Return new list to guard against concurrent modifications. |
| - return new List<LocalFunctionElement>.from( |
| - allClosures.where((LocalFunctionElement closure) { |
| - return closure.executableContext == element; |
| - })); |
| - } |
| - |
| /// Return the canonical [_ClassUsage] for [cls]. |
| _ClassUsage _getClassUsage(ClassElement cls) { |
| return _processedClasses.putIfAbsent(cls, () { |
| @@ -764,7 +751,7 @@ class ElementResolutionWorldBuilder implements ResolutionEnqueuerWorldBuilder { |
| if (member.isFunction && |
| member.name == Identifiers.call && |
| !cls.typeVariables.isEmpty) { |
| - callMethodsWithFreeTypeVariables.add(member); |
| + closurizedMembersWithFreeTypeVariables.add(member); |
| } |
| if (_hasInvokedGetter(member)) { |