Skip to content
Merged
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 @@ -2563,7 +2563,7 @@ public FieldAccessor newFieldAccessor(Field field0, boolean override) {

@Substitute
private Constructor<?> generateConstructor(Class<?> cl, Constructor<?> constructorToCall) {
ConstructorAccessor acc = (ConstructorAccessor) SerializationSupport.getSerializationConstructorAccessor(cl, constructorToCall.getDeclaringClass());
ConstructorAccessor acc = (ConstructorAccessor) SerializationSupport.getRuntimeSerializationConstructorAccessor(cl, constructorToCall.getDeclaringClass());
/*
* Unlike other root constructors, this constructor is not copied for mutation but directly
* mutated, as it is not cached. To cache this constructor, setAccessible call must be done
Expand Down

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ struct PersistedAnalysisType {
wrappedType :union {
none @31 :Void; # default
serializationGenerated :group {
rawDeclaringClass @32 :Text;
rawTargetConstructor @33 :Text;
rawDeclaringClassId @32 :TypeId;
rawTargetConstructorId @33 :TypeId;
}
lambda :group {
capturingClass @34 :Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
import com.oracle.svm.core.meta.MethodRef;
import com.oracle.svm.core.reflect.proxy.DynamicProxySupport;
import com.oracle.svm.core.reflect.serialize.SerializationSupport;
import com.oracle.svm.shared.util.VMError;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.hosted.SVMHost;
import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport;
Expand Down Expand Up @@ -128,6 +127,7 @@
import com.oracle.svm.shaded.org.capnproto.PrimitiveList;
import com.oracle.svm.shaded.org.capnproto.StructList;
import com.oracle.svm.shaded.org.capnproto.Text;
import com.oracle.svm.shared.util.VMError;
import com.oracle.svm.util.AnnotationUtil;
import com.oracle.svm.util.GuestAccess;
import com.oracle.svm.util.JVMCIReflectionUtil;
Expand Down Expand Up @@ -446,14 +446,18 @@ protected boolean delegateLoadType(PersistedAnalysisType.Reader typeData) {
}
if (wrappedType.isSerializationGenerated()) {
SerializationGenerated.Reader sg = wrappedType.getSerializationGenerated();
String rawDeclaringClassName = sg.getRawDeclaringClass().toString();
String rawTargetConstructorClassName = sg.getRawTargetConstructor().toString();
Class<?> rawDeclaringClass = imageLayerBuildingSupport.lookupClass(false, rawDeclaringClassName);
Class<?> rawTargetConstructorClass = imageLayerBuildingSupport.lookupClass(false, rawTargetConstructorClassName);
int rawDeclaringClassId = sg.getRawDeclaringClassId();
int rawTargetConstructorClassId = sg.getRawTargetConstructorId();
AnalysisType rawDeclaringType = getAnalysisTypeForBaseLayerId(rawDeclaringClassId);
AnalysisType rawTargetConstructorType = getAnalysisTypeForBaseLayerId(rawTargetConstructorClassId);
Class<?> rawDeclaringClass = rawDeclaringType.getJavaClass();
Class<?> rawTargetConstructorClass = rawTargetConstructorType.getJavaClass();
Constructor<?> rawTargetConstructor = ReflectionUtil.lookupConstructor(rawTargetConstructorClass);
Constructor<?> constructor = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(rawDeclaringClass, rawTargetConstructor);
SerializationSupport.currentLayer().addConstructorAccessor(rawDeclaringClass, rawTargetConstructorClass, SerializationFeature.getConstructorAccessor(constructor));
Class<?> constructorAccessor = SerializationSupport.getSerializationConstructorAccessor(rawDeclaringClass, rawTargetConstructorClass).getClass();
DynamicHub rawDeclaringHub = typeToHub(rawDeclaringType);
DynamicHub rawTargetConstructorHub = typeToHub(rawTargetConstructorType);
SerializationSupport.currentLayer().addConstructorAccessor(rawDeclaringHub, rawTargetConstructorHub, SerializationFeature.getConstructorAccessor(constructor));
Class<?> constructorAccessor = SerializationSupport.getHostedSerializationConstructorAccessor(rawDeclaringHub, rawTargetConstructorHub).getClass();
metaAccess.lookupJavaType(constructorAccessor);
return true;
} else if (wrappedType.isLambda()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
import com.oracle.svm.hosted.meta.HostedUniverse;
import com.oracle.svm.hosted.thread.VMThreadLocalCollector;
import com.oracle.svm.shared.util.ModuleSupport;
import com.oracle.svm.shared.util.ReflectionUtil;
import com.oracle.svm.shared.util.VMError;
import com.oracle.svm.util.GuestAccess;
import com.oracle.svm.util.JVMCIReflectionUtil;
import com.oracle.svm.util.OriginalMethodProvider;
import com.oracle.svm.shared.util.ReflectionUtil;

import jdk.graal.compiler.api.replacements.SnippetReflectionProvider;
import jdk.graal.compiler.debug.CounterKey;
Expand Down Expand Up @@ -340,7 +340,7 @@ private static String getGeneratedSerializationName(AnalysisType type) {
}

private static String generatedSerializationClassName(SerializationSupport.SerializationLookupKey serializationLookupKey) {
return GENERATED_SERIALIZATION + ":" + serializationLookupKey.getDeclaringClass() + "," + serializationLookupKey.getTargetConstructorClass();
return GENERATED_SERIALIZATION + ":" + serializationLookupKey.declaringClassId() + "," + serializationLookupKey.targetConstructorClassId();
}

private static String addModuleName(String elementName, String moduleName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ protected void delegatePersistType(AnalysisType type, PersistedAnalysisType.Buil
if (type.toJavaName(true).contains(GENERATED_SERIALIZATION)) {
WrappedType.SerializationGenerated.Builder b = builder.getWrappedType().initSerializationGenerated();
var key = SerializationSupport.currentLayer().getKeyFromConstructorAccessorClass(type.getJavaClass());
b.setRawDeclaringClass(key.getDeclaringClass().getName());
b.setRawTargetConstructor(key.getTargetConstructorClass().getName());
b.setRawDeclaringClassId(key.declaringClassId());
b.setRawTargetConstructorId(key.targetConstructorClassId());
} else if (LambdaUtils.isLambdaType(type)) {
WrappedType.Lambda.Builder b = builder.getWrappedType().initLambda();
b.setCapturingClass(LambdaUtils.capturingClass(type.toJavaName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
@SuppressWarnings("all")
public final class SharedLayerSnapshotCapnProtoSchemaHolder {
public static class PersistedAnalysisType {
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)4,(short)14);
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)5,(short)13);
public static final class Factory extends com.oracle.svm.shaded.org.capnproto.StructFactory<Builder, Reader> {
public Factory() {
}
Expand Down Expand Up @@ -360,8 +360,9 @@ public final WrappedType.Builder getWrappedType() {
}
public final WrappedType.Builder initWrappedType() {
_setShortField(7,(short)0);
_setIntField(7,0);
_setIntField(8,0);
_clearPointerField(12);
_clearPointerField(13);
return new PersistedAnalysisType.WrappedType.Builder(segment, data, pointers, dataSize, pointerCount);
}

Expand Down Expand Up @@ -550,7 +551,7 @@ public final boolean getIsRecord() {
}

public static class WrappedType {
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)4,(short)14);
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)5,(short)13);
public static final class Factory extends com.oracle.svm.shaded.org.capnproto.StructFactory<Builder, Reader> {
public Factory() {
}
Expand Down Expand Up @@ -606,8 +607,8 @@ public final SerializationGenerated.Builder getSerializationGenerated() {
}
public final SerializationGenerated.Builder initSerializationGenerated() {
_setShortField(7, (short)PersistedAnalysisType.WrappedType.Which.SERIALIZATION_GENERATED.ordinal());
_clearPointerField(12);
_clearPointerField(13);
_setIntField(7,0);
_setIntField(8,0);
return new PersistedAnalysisType.WrappedType.SerializationGenerated.Builder(segment, data, pointers, dataSize, pointerCount);
}

Expand Down Expand Up @@ -693,7 +694,7 @@ public enum Which {
_NOT_IN_SCHEMA,
}
public static class SerializationGenerated {
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)4,(short)14);
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)5,(short)13);
public static final class Factory extends com.oracle.svm.shaded.org.capnproto.StructFactory<Builder, Reader> {
public Factory() {
}
Expand All @@ -720,55 +721,33 @@ public static final class Builder extends com.oracle.svm.shaded.org.capnproto.St
public final Reader asReader() {
return new Reader(segment, data, pointers, dataSize, pointerCount, 0x7fffffff);
}
public final boolean hasRawDeclaringClass() {
return !_pointerFieldIsNull(12);
public final int getRawDeclaringClassId() {
return _getIntField(7);
}
public final com.oracle.svm.shaded.org.capnproto.Text.Builder getRawDeclaringClass() {
return _getPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 12, null, 0, 0);
}
public final void setRawDeclaringClass(com.oracle.svm.shaded.org.capnproto.Text.Reader value) {
_setPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 12, value);
}
public final void setRawDeclaringClass(String value) {
_setPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 12, new com.oracle.svm.shaded.org.capnproto.Text.Reader(value));
}
public final com.oracle.svm.shaded.org.capnproto.Text.Builder initRawDeclaringClass(int size) {
return _initPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 12, size);
public final void setRawDeclaringClassId(int value) {
_setIntField(7, value);
}
public final boolean hasRawTargetConstructor() {
return !_pointerFieldIsNull(13);
}
public final com.oracle.svm.shaded.org.capnproto.Text.Builder getRawTargetConstructor() {
return _getPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 13, null, 0, 0);
}
public final void setRawTargetConstructor(com.oracle.svm.shaded.org.capnproto.Text.Reader value) {
_setPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 13, value);
}
public final void setRawTargetConstructor(String value) {
_setPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 13, new com.oracle.svm.shaded.org.capnproto.Text.Reader(value));

public final int getRawTargetConstructorId() {
return _getIntField(8);
}
public final com.oracle.svm.shaded.org.capnproto.Text.Builder initRawTargetConstructor(int size) {
return _initPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 13, size);
public final void setRawTargetConstructorId(int value) {
_setIntField(8, value);
}

}

public static final class Reader extends com.oracle.svm.shaded.org.capnproto.StructReader {
Reader(com.oracle.svm.shaded.org.capnproto.SegmentReader segment, int data, int pointers,int dataSize, short pointerCount, int nestingLimit){
super(segment, data, pointers, dataSize, pointerCount, nestingLimit);
}

public boolean hasRawDeclaringClass() {
return !_pointerFieldIsNull(12);
}
public com.oracle.svm.shaded.org.capnproto.Text.Reader getRawDeclaringClass() {
return _getPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 12, null, 0, 0);
public final int getRawDeclaringClassId() {
return _getIntField(7);
}

public boolean hasRawTargetConstructor() {
return !_pointerFieldIsNull(13);
}
public com.oracle.svm.shaded.org.capnproto.Text.Reader getRawTargetConstructor() {
return _getPointerField(com.oracle.svm.shaded.org.capnproto.Text.factory, 13, null, 0, 0);
public final int getRawTargetConstructorId() {
return _getIntField(8);
}

}
Expand All @@ -777,7 +756,7 @@ public com.oracle.svm.shaded.org.capnproto.Text.Reader getRawTargetConstructor()


public static class Lambda {
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)4,(short)14);
public static final com.oracle.svm.shaded.org.capnproto.StructSize STRUCT_SIZE = new com.oracle.svm.shaded.org.capnproto.StructSize((short)5,(short)13);
public static final class Factory extends com.oracle.svm.shaded.org.capnproto.StructFactory<Builder, Reader> {
public Factory() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.RuntimeSerializationSupport;

import com.oracle.graal.pointsto.ObjectScanner.OtherReason;
import com.oracle.graal.pointsto.meta.AnalysisMetaAccess;
import com.oracle.graal.pointsto.meta.AnalysisType;
import com.oracle.svm.configure.ConfigurationFile;
import com.oracle.svm.configure.ConfigurationParserOption;
import com.oracle.svm.configure.SerializationConfigurationParser;
Expand All @@ -72,11 +75,12 @@
import com.oracle.svm.core.reflect.serialize.SerializationSupport;
import com.oracle.svm.core.reflect.target.ReflectionSubstitutionSupport;
import com.oracle.svm.core.util.BasedOnJDKFile;
import com.oracle.svm.shared.util.VMError;
import com.oracle.svm.hosted.ConditionalConfigurationRegistry;
import com.oracle.svm.hosted.ConfigurationTypeResolver;
import com.oracle.svm.hosted.FeatureImpl;
import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl;
import com.oracle.svm.hosted.ImageClassLoader;
import com.oracle.svm.hosted.SVMHost;
import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport;
import com.oracle.svm.hosted.config.ConfigurationParserUtils;
import com.oracle.svm.hosted.lambda.LambdaParser;
Expand All @@ -85,6 +89,7 @@
import com.oracle.svm.hosted.reflect.ReflectionFeature;
import com.oracle.svm.hosted.reflect.proxy.DynamicProxyFeature;
import com.oracle.svm.hosted.reflect.proxy.ProxyRegistry;
import com.oracle.svm.shared.util.VMError;
import com.oracle.svm.util.GuestAccess;
import com.oracle.svm.util.LogUtils;
import com.oracle.svm.shared.util.ReflectionUtil;
Expand Down Expand Up @@ -458,10 +463,16 @@ private void registerConstructorAccessor(AccessCondition cnd, Class<?> serializa

void beforeAnalysis(Feature.BeforeAnalysisAccess beforeAnalysisAccess) {
setAnalysisAccess(beforeAnalysisAccess);
BeforeAnalysisAccessImpl accessImpl = (BeforeAnalysisAccessImpl) beforeAnalysisAccess;
serializationSupport.setObjectRescanner(object -> accessImpl.rescanObject(object, OtherReason.UNKNOWN));
universe = accessImpl.getUniverse();
stubConstructor = newConstructorForSerialization(SerializationSupport.StubForAbstractClass.class, null);
pendingConstructorRegistrations.forEach(Runnable::run);
pendingConstructorRegistrations = null;
serializationSupport.setStubConstructor(stubConstructor);
AnalysisMetaAccess metaAccess = accessImpl.getMetaAccess();
SVMHost hostVM = accessImpl.getHostVM();
serializationSupport.setStubConstructor(hostVM.dynamicHub(metaAccess.lookupJavaType(stubConstructor.getDeclaringClass())));
serializationSupport.setSerializedLambdaClass(hostVM.dynamicHub(metaAccess.lookupJavaType(DynamicHub.class)));
}

private static void registerQueriesForInheritableMethod(boolean preserved, Class<?> clazz, String methodName, Class<?>... args) {
Expand Down Expand Up @@ -715,7 +726,11 @@ private Class<?> addConstructorAccessor(Class<?> serializationTargetClass, Class
}

Class<?> targetConstructorClass = targetConstructor.getDeclaringClass();
serializationSupport.addConstructorAccessor(serializationTargetClass, targetConstructorClass, getConstructorAccessor(targetConstructor));
AnalysisMetaAccess analysisMetaAccess = universe.getBigbang().getMetaAccess();
AnalysisType serializationTargetType = analysisMetaAccess.lookupJavaType(serializationTargetClass);
AnalysisType targetConstructorType = analysisMetaAccess.lookupJavaType(targetConstructorClass);
SVMHost hostVM = (SVMHost) universe.hostVM();
serializationSupport.addConstructorAccessor(hostVM.dynamicHub(serializationTargetType), hostVM.dynamicHub(targetConstructorType), getConstructorAccessor(targetConstructor));
return targetConstructorClass;
}
}