Skip to content

Commit

Permalink
[GR-60100] Persist and load all possible annotation values
Browse files Browse the repository at this point in the history
PullRequest: graal/19581
  • Loading branch information
Zeavee committed Dec 13, 2024
2 parents f9078d7 + f21824a commit 1a5e49e
Show file tree
Hide file tree
Showing 6 changed files with 798 additions and 452 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.EnumConstant;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.StringConstant;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveArray;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveValue;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.SharedLayerSnapshot;
import com.oracle.graal.pointsto.heap.value.ValueSupplier;
import com.oracle.graal.pointsto.infrastructure.ResolvedSignature;
Expand Down Expand Up @@ -944,7 +946,7 @@ protected void injectIdentityHashCode(Object object, Integer identityHashCode) {
/* The hash code can only be injected in the SVM context. */
}

private static Object getArray(PersistedConstant.PrimitiveData.Reader reader) {
protected static Object getArray(PrimitiveArray.Reader reader) {
return switch (reader.which()) {
case Z -> getBooleans(reader.getZ());
case B -> toArray(reader.getB(), r -> IntStream.range(0, r.size()).collect(() -> new byte[r.size()], (a, i) -> a[i] = r.get(i), combineUnsupported()));
Expand Down Expand Up @@ -1011,7 +1013,7 @@ private Object[] getReferencedValues(ImageHeapConstant parentConstant, StructLis
throw AnalysisError.shouldNotReachHere("This constant was not materialized in the base image.");
});
case PRIMITIVE_VALUE -> {
ConstantReference.PrimitiveValue.Reader pv = constantData.getPrimitiveValue();
PrimitiveValue.Reader pv = constantData.getPrimitiveValue();
yield JavaConstant.forPrimitive((char) pv.getTypeChar(), pv.getRawValue());
}
default -> throw GraalError.shouldNotReachHere("Unexpected constant reference: " + constantData.which());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.EnumConstant;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PersistedConstant.Object.Relinking.StringConstant;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveArray;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.PrimitiveValue;
import com.oracle.graal.pointsto.heap.SharedLayerSnapshotCapnProtoSchemaHolder.SharedLayerSnapshot;
import com.oracle.graal.pointsto.infrastructure.OriginalFieldProvider;
import com.oracle.graal.pointsto.meta.AnalysisField;
Expand Down Expand Up @@ -713,7 +715,7 @@ protected void persistConstantRelinkingInfo(PersistedConstant.Object.Relinking.B
}
}

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

0 comments on commit 1a5e49e

Please sign in to comment.