Skip to content

Commit

Permalink
[GR-60565] Move non-critical DynamicHub fields to companion object.
Browse files Browse the repository at this point in the history
PullRequest: graal/19637
  • Loading branch information
peter-hofer committed Jan 16, 2025
2 parents 9dc75a7 + 0a3b5a1 commit a44c46a
Show file tree
Hide file tree
Showing 13 changed files with 397 additions and 469 deletions.
2 changes: 2 additions & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,8 @@ def capnp_compile(args):
*/
//@formatter:off
//Checkstyle: stop
// Generated via:
// $ mx capnp-compile
""")
for line in lines:
if line.startswith("public final class "):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,54 +75,20 @@ public class DynamicHubOffsets {

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int flagsOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int additionalFlagsOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int modifiersOffset;

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int superHubOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int componentTypeOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int arrayHubOffset;

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int declaringClassOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int interfacesEncodingOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int enumConstantsReferenceOffset;

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int referenceMapIndexOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int layerIdOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int metaTypeOffset;

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int sourceFileNameOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int classInitializationInfoOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int moduleOffset;

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int nestHostOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int simpleBinaryNameOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int companionOffset;

@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int signatureOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int classRedefinedCountOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int hubMetadataOffset;
@UnknownPrimitiveField(availability = BuildPhaseProvider.ReadyForCompilation.class) //
private int reflectionMetadataOffset;

@Fold
public static DynamicHubOffsets singleton() {
Expand Down Expand Up @@ -205,38 +171,10 @@ public int getFlagsOffset() {
return flagsOffset;
}

public int getAdditionalFlagsOffset() {
return additionalFlagsOffset;
}

public int getModifiersOffset() {
return modifiersOffset;
}

public int getSuperHubOffset() {
return superHubOffset;
}

public int getComponentTypeOffset() {
return componentTypeOffset;
}

public int getArrayHubOffset() {
return arrayHubOffset;
}

public int getDeclaringClassOffset() {
return declaringClassOffset;
}

public int getInterfacesEncodingOffset() {
return interfacesEncodingOffset;
}

public int getEnumConstantsReferenceOffset() {
return enumConstantsReferenceOffset;
}

public int getReferenceMapIndexOffset() {
return referenceMapIndexOffset;
}
Expand All @@ -245,30 +183,6 @@ public int getLayerIdOffset() {
return layerIdOffset;
}

public int getMetaTypeOffset() {
return metaTypeOffset;
}

public int getSourceFileNameOffset() {
return sourceFileNameOffset;
}

public int getClassInitializationInfoOffset() {
return classInitializationInfoOffset;
}

public int getModuleOffset() {
return moduleOffset;
}

public int getNestHostOffset() {
return nestHostOffset;
}

public int getSimpleBinaryNameOffset() {
return simpleBinaryNameOffset;
}

public int getCompanionOffset() {
return companionOffset;
}
Expand All @@ -277,18 +191,6 @@ public int getSignatureOffset() {
return signatureOffset;
}

public int getClassRedefinedCountOffset() {
return classRedefinedCountOffset;
}

public int getHubMetadataOffset() {
return hubMetadataOffset;
}

public int getReflectionMetadataOffset() {
return reflectionMetadataOffset;
}

public static void writeObject(DynamicHub hub, int offset, Object value) {
if (offset < 0) {
/* field removed by analysis */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import java.util.Arrays;
import java.util.Map;

import com.oracle.svm.core.graal.meta.KnownOffsets;
import jdk.graal.compiler.core.common.NumUtil;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.word.LocationIdentity;
import org.graalvm.word.UnsignedWord;
Expand All @@ -48,6 +46,7 @@
import com.oracle.svm.core.allocationprofile.AllocationSite;
import com.oracle.svm.core.config.ConfigurationValues;
import com.oracle.svm.core.configure.ConfigurationFile;
import com.oracle.svm.core.graal.meta.KnownOffsets;
import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider;
import com.oracle.svm.core.graal.nodes.NewPodInstanceNode;
import com.oracle.svm.core.graal.nodes.NewStoredContinuationNode;
Expand Down Expand Up @@ -75,6 +74,7 @@
import jdk.graal.compiler.api.replacements.Snippet.NonNullParameter;
import jdk.graal.compiler.api.replacements.Snippet.VarargsParameter;
import jdk.graal.compiler.core.common.GraalOptions;
import jdk.graal.compiler.core.common.NumUtil;
import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor;
import jdk.graal.compiler.core.common.spi.MetaAccessExtensionProvider;
import jdk.graal.compiler.core.common.type.StampFactory;
Expand Down Expand Up @@ -346,7 +346,7 @@ private static DynamicHub slowPathHubOrUnsafeInstantiationError(DynamicHub hub)
throw new InstantiationException("Cannot allocate objects of special hybrid types: " + DynamicHub.toClass(hub).getTypeName());
} else {
if (hub.canUnsafeInstantiateAsInstanceSlowPath()) {
hub.getCompanion().setUnsafeAllocate();
hub.setCanUnsafeAllocate();
return hub;
} else {
if (MissingRegistrationUtils.throwMissingRegistrationErrors()) {
Expand Down
Loading

0 comments on commit a44c46a

Please sign in to comment.