Skip to content
Permalink
Browse files
8252518: cache result of CompilerToVM.getComponentType
Reviewed-by: kvn, never
  • Loading branch information
Doug Simon committed Sep 22, 2020
1 parent c1df13b commit 0f26ab16ddf10cefc0b528aa12c7c2378a864063
Showing 1 changed file with 13 additions and 5 deletions.
@@ -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}.
@@ -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
@@ -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()) {

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.