Skip to content

Commit

Permalink
8252518: cache result of CompilerToVM.getComponentType
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, never
  • Loading branch information
Doug Simon committed Sep 22, 2020
1 parent c1df13b commit 0f26ab1
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem
private HotSpotConstantPool constantPool;
private final JavaConstant mirror;
private HotSpotResolvedObjectTypeImpl superClass;
private HotSpotResolvedJavaType componentType;

/**
* Managed exclusively by {@link HotSpotJDKReflection#getField}.
Expand Down Expand Up @@ -157,7 +158,14 @@ public int getAccessFlags() {

@Override
public ResolvedJavaType getComponentType() {
return runtime().compilerToVm.getComponentType(this);
if (componentType == null) {
if (isArray()) {
componentType = runtime().compilerToVm.getComponentType(this);
} else {
componentType = this;
}
}
return this.equals(componentType) ? null : componentType;
}

@Override
Expand Down Expand Up @@ -298,12 +306,12 @@ public HotSpotResolvedObjectTypeImpl getSingleImplementor() {

@Override
public HotSpotResolvedObjectTypeImpl getSupertype() {
if (isArray()) {
ResolvedJavaType componentType = getComponentType();
if (componentType.equals(getJavaLangObject()) || componentType.isPrimitive()) {
ResolvedJavaType component = getComponentType();
if (component != null) {
if (component.equals(getJavaLangObject()) || component.isPrimitive()) {
return getJavaLangObject();
}
HotSpotResolvedObjectTypeImpl supertype = ((HotSpotResolvedObjectTypeImpl) componentType).getSupertype();
HotSpotResolvedObjectTypeImpl supertype = ((HotSpotResolvedObjectTypeImpl) component).getSupertype();
return (HotSpotResolvedObjectTypeImpl) supertype.getArrayClass();
}
if (isInterface()) {
Expand Down

1 comment on commit 0f26ab1

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 0f26ab1 Sep 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.