Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
import static com.oracle.svm.core.code.RuntimeMetadataDecoderImpl.ALL_RECORD_COMPONENTS_FLAG;
import static com.oracle.svm.core.code.RuntimeMetadataDecoderImpl.ALL_SIGNERS_FLAG;
import static com.oracle.svm.core.code.RuntimeMetadataDecoderImpl.CLASS_ACCESS_FLAGS_MASK;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeObject;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeInt;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeByte;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeChar;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeInt;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeObject;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeShort;
import static com.oracle.svm.core.graal.meta.DynamicHubOffsets.writeByte;
import static com.oracle.svm.core.reflect.RuntimeMetadataDecoder.NO_DATA;

import java.io.InputStream;
Expand Down Expand Up @@ -239,8 +239,8 @@ public final class DynamicHub implements AnnotatedElement, java.lang.reflect.Typ
// region open-world only fields

/**
* This stores the depth of the type in the inheritance hierarchy. If the type is an interface
* then the typeIDDepth is -1.
* This stores the depth of the type in the inheritance hierarchy. If the type is an interface,
* then the typeIDDepth is negative.
*/
@UnknownPrimitiveField(availability = AfterHostedUniverse.class)//
private int typeIDDepth;
Expand Down Expand Up @@ -673,15 +673,17 @@ public void setClosedTypeWorldData(CFunctionPointer[] vtable, int typeID, short

@Platforms(Platform.HOSTED_ONLY.class)
public void setOpenTypeWorldData(CFunctionPointer[] vtable, int typeID,
int typeCheckDepth, int numClassTypes, int numInterfaceTypes, int[] typeCheckSlots) {
int typeIDDepth, int numClassTypes, int numInterfaceTypes, int[] typeCheckSlots) {
assert this.vtable == null : "Initialization must be called only once";

this.typeID = typeID;
this.typeIDDepth = typeCheckDepth;
this.typeIDDepth = typeIDDepth;
this.numClassTypes = numClassTypes;
this.numInterfaceTypes = numInterfaceTypes;
this.openTypeWorldTypeCheckSlots = typeCheckSlots;
this.vtable = vtable;

VMError.guarantee(getNumClassTypes() == numClassTypes);
}

@Platforms(Platform.HOSTED_ONLY.class)
Expand Down Expand Up @@ -839,8 +841,9 @@ public int getTypeIDDepth() {
return typeIDDepth;
}

/** @see #setOpenTypeWorldData */
public int getNumClassTypes() {
return numClassTypes;
return (typeIDDepth < 0) ? -(typeIDDepth + 1) : (typeIDDepth + 1);
}

public int getNumInterfaceTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,6 @@ private void initializeExcludedFields() {
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "arrayHub"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "additionalFlags"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "layoutEncoding"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "numClassTypes"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "numInterfaceTypes"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "openTypeWorldTypeCheckSlots"));
excludedFields.add(ReflectionUtil.lookupField(DynamicHub.class, "typeIDDepth"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1967,15 +1967,16 @@ private static void generateOpenTypeWorldTypeMetadata(Map<HostedType, OpenTypeWo
for (var entry : typeInfoMap.entrySet()) {
HostedType type = entry.getKey();
OpenTypeWorldTypeInfo info = entry.getValue();
int idDepth = isInterface(type) ? -1 : info.classDisplay.length - 1;
int numClassTypes = info.classDisplay.length;
VMError.guarantee(numClassTypes != 0, "breaks idDepth representation below");
int idDepth = (isInterface(type) ? -numClassTypes : numClassTypes) - 1;
if (idDepth >= 0) {
assert info.classDisplay[idDepth] == type.typeID : String.format("Mismatch between class display and type. idDepth: %s typeID: %s info: %s ", idDepth, type.typeID, info);
}

int numInterfaceTypes = info.implementedInterfaces.size();
List<HostedType> orderedInterfaces = info.implementedInterfaces.stream().sorted(Comparator.comparingInt(HostedType::getTypeID)).toList();
int[] interfaceTypeIDs = orderedInterfaces.stream().mapToInt(HostedType::getTypeID).toArray();
int numClassTypes = info.classDisplay.length;
int[] typeIDSlots = new int[numClassTypes + numInterfaceTypes];
System.arraycopy(info.classDisplay, 0, typeIDSlots, 0, numClassTypes);
System.arraycopy(interfaceTypeIDs, 0, typeIDSlots, numClassTypes, numInterfaceTypes);
Expand Down