Change MemberTypeInformation.member type to MemberEntity

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2967153002 .
This commit is contained in:
Johnni Winther 2017-07-06 12:18:59 +02:00
parent 4ea9fa80ea
commit ae532f70c4
4 changed files with 15 additions and 30 deletions

View file

@ -431,7 +431,7 @@ abstract class TracerVisitor implements TypeInformationVisitor {
return (name == '[]=');
}
bool isClosure(Element element) {
bool isClosure(MemberEntity element) {
if (!element.isFunction) return false;
/// Creating an instance of a class that implements [Function] also
@ -442,8 +442,8 @@ abstract class TracerVisitor implements TypeInformationVisitor {
if (element.isInstanceMember && element.name == Identifiers.call) {
return true;
}
Element outermost = element.outermostEnclosingMemberOrTopLevel;
return outermost.declaration != element.declaration;
ClassEntity cls = element.enclosingClass;
return cls != null && cls.isClosure;
}
void visitMemberTypeInformation(MemberTypeInformation info) {

View file

@ -393,7 +393,7 @@ abstract class MemberTypeInformation extends ElementTypeInformation
MemberTypeInformation._internal(this._member) : super._internal(null);
MemberElement get member => _member;
MemberEntity get member => _member;
String get debugName => '$member';

View file

@ -667,9 +667,14 @@ class JavaScriptBackend {
/// One category of elements that do not apply is runtime helpers that the
/// backend calls, but the optimizations don't see those calls.
bool canFieldBeUsedForGlobalOptimizations(
FieldElement element, ClosedWorld closedWorld) {
return !closedWorld.backendUsage.isFieldUsedByBackend(element) &&
!mirrorsData.invokedReflectively(element);
FieldEntity element, ClosedWorld closedWorld) {
if (closedWorld.backendUsage.isFieldUsedByBackend(element)) {
return false;
}
if ((element.isTopLevel || element.isStatic) && !element.isAssignable) {
return true;
}
return !mirrorsData.isMemberAccessibleByReflection(element);
}
/// Returns true if global optimizations such as type inferencing can apply to
@ -678,11 +683,9 @@ class JavaScriptBackend {
/// One category of elements that do not apply is runtime helpers that the
/// backend calls, but the optimizations don't see those calls.
bool canFunctionParametersBeUsedForGlobalOptimizations(
FunctionElement element, ClosedWorld closedWorld) {
if (element.isLocal) return true;
MethodElement method = element;
return !closedWorld.backendUsage.isFunctionUsedByBackend(method) &&
!mirrorsData.invokedReflectively(method);
FunctionEntity function, ClosedWorld closedWorld) {
return !closedWorld.backendUsage.isFunctionUsedByBackend(function) &&
!mirrorsData.isMemberAccessibleByReflection(function);
}
bool operatorEqHandlesNullArgument(FunctionEntity operatorEqfunction) {

View file

@ -131,8 +131,6 @@ abstract class MirrorsData {
bool retainMetadataOfMember(covariant MemberEntity element);
bool retainMetadataOfParameter(ParameterElement element);
bool invokedReflectively(Element element);
/// Returns true if this element has to be enqueued due to
/// mirror usage. Might be a subset of [referencedFromMirrorSystem] if
/// normal tree shaking is still active ([isTreeShakingDisabled] is false).
@ -314,22 +312,6 @@ class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder {
}
}
bool invokedReflectively(Element element) {
if (element.isParameter) {
ParameterElement parameter = element;
if (invokedReflectively(parameter.functionDeclaration)) return true;
}
if (element.isField) {
if (Elements.isStaticOrTopLevel(element) &&
(element.isFinal || element.isConst)) {
return false;
}
}
return isAccessibleByReflection(element.declaration);
}
/// Sets of elements that are needed by reflection. Computed using
/// [computeMembersNeededForReflection] on first use.
Set<ClassElement> _classesNeededForReflection;