Skip to content

Commit 1a5e49e

Browse files
committed
[GR-60100] Persist and load all possible annotation values
PullRequest: graal/19581
2 parents f9078d7 + f21824a commit 1a5e49e

File tree

6 files changed

+798
-452
lines changed

6 files changed

+798
-452
lines changed

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageLayerLoader.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant;
6969
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.EnumConstant;
7070
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.StringConstant;
71+
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveArray;
72+
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveValue;
7173
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.SharedLayerSnapshot;
7274
import com.oracle.graal.pointsto.heap.value.ValueSupplier;
7375
import com.oracle.graal.pointsto.infrastructure.ResolvedSignature;
@@ -944,7 +946,7 @@ protected void injectIdentityHashCode(Object object, Integer identityHashCode) {
944946
/* The hash code can only be injected in the SVM context. */
945947
}
946948

947-
private static Object getArray(PersistedConstant.PrimitiveData.Reader reader) {
949+
protected static Object getArray(PrimitiveArray.Reader reader) {
948950
return switch (reader.which()) {
949951
case Z -> getBooleans(reader.getZ());
950952
case B -> toArray(reader.getB(), r -> IntStream.range(0, r.size()).collect(() -> new byte[r.size()], (a, i) -> a[i] = r.get(i), combineUnsupported()));
@@ -1011,7 +1013,7 @@ private Object[] getReferencedValues(ImageHeapConstant parentConstant, StructLis
10111013
throw AnalysisError.shouldNotReachHere("This constant was not materialized in the base image.");
10121014
});
10131015
case PRIMITIVE_VALUE -> {
1014-
ConstantReference.PrimitiveValue.Reader pv = constantData.getPrimitiveValue();
1016+
PrimitiveValue.Reader pv = constantData.getPrimitiveValue();
10151017
yield JavaConstant.forPrimitive((char) pv.getTypeChar(), pv.getRawValue());
10161018
}
10171019
default -> throw GraalError.shouldNotReachHere("Unexpected constant reference: " + constantData.which());

substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageLayerWriter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant;
8282
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.EnumConstant;
8383
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.StringConstant;
84+
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveArray;
85+
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveValue;
8486
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.SharedLayerSnapshot;
8587
import com.oracle.graal.pointsto.infrastructure.OriginalFieldProvider;
8688
import com.oracle.graal.pointsto.meta.AnalysisField;
@@ -713,7 +715,7 @@ protected void persistConstantRelinkingInfo(PersistedConstant.Object.Relinking.B
713715
}
714716
}
715717

716-
private static void persistConstantPrimitiveArray(PersistedConstant.PrimitiveData.Builder builder, JavaKind componentKind, Object array) {
718+
protected static void persistConstantPrimitiveArray(PrimitiveArray.Builder builder, JavaKind componentKind, Object array) {
717719
assert componentKind.toJavaClass().equals(array.getClass().getComponentType());
718720
switch (array) {
719721
case boolean[] a -> persistArray(a, builder::initZ, (b, i) -> b.set(i, a[i]));
@@ -751,7 +753,7 @@ private void persistConstantObjectData(PersistedConstant.Object.Builder builder,
751753
} else if (object == JavaConstant.NULL_POINTER) {
752754
b.setNullPointer(Void.VOID);
753755
} else if (object instanceof PrimitiveConstant pc) {
754-
ConstantReference.PrimitiveValue.Builder pb = b.initPrimitiveValue();
756+
PrimitiveValue.Builder pb = b.initPrimitiveValue();
755757
pb.setTypeChar(NumUtil.safeToUByte(pc.getJavaKind().getTypeChar()));
756758
pb.setRawValue(pc.getRawValue());
757759
} else {

0 commit comments

Comments
 (0)