Skip to content

Commit be2d761

Browse files
committed
Rename RuntimeConditionSet to RuntimeDynamicAccessMetadata
1 parent 822c6fc commit be2d761

20 files changed

+222
-207
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/RuntimeMetadataDecoderImpl.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
import com.oracle.svm.core.SubstrateUtil;
4343
import com.oracle.svm.core.c.NonmovableArrays;
44-
import com.oracle.svm.core.configure.RuntimeConditionSet;
44+
import com.oracle.svm.core.configure.RuntimeDynamicAccessMetadata;
4545
import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton;
4646
import com.oracle.svm.core.hub.DynamicHub;
4747
import com.oracle.svm.core.layeredimagesingleton.MultiLayeredImageSingleton;
@@ -356,15 +356,15 @@ private static Object decodeField(UnsafeArrayTypeReader buf, Class<?> declaringC
356356
boolean complete = (modifiers & COMPLETE_FLAG_MASK) != 0;
357357
boolean preserved = (modifiers & PRESERVED_FLAG_MASK) != 0;
358358

359-
RuntimeConditionSet conditions = decodeConditions(buf, layerId, preserved);
359+
RuntimeDynamicAccessMetadata dynamicAccessMetadata = decodeDynamicAccessMetadata(buf, layerId, preserved);
360360
if (inHeap) {
361361
Field field = (Field) decodeObject(buf, layerId);
362362
if (publicOnly && !Modifier.isPublic(field.getModifiers())) {
363363
/*
364364
* Generate negative copy of the field. Finding a non-public field when looking for
365365
* a public one should not result in a missing registration exception.
366366
*/
367-
return ReflectionObjectFactory.newField(conditions, declaringClass, field.getName(), Object.class, field.getModifiers() | NEGATIVE_FLAG_MASK, false,
367+
return ReflectionObjectFactory.newField(dynamicAccessMetadata, declaringClass, field.getName(), Object.class, field.getModifiers() | NEGATIVE_FLAG_MASK, false,
368368
null, null, ReflectionObjectFactory.FIELD_OFFSET_NONE, null, null);
369369
}
370370
if (reflectOnly) {
@@ -393,7 +393,8 @@ private static Object decodeField(UnsafeArrayTypeReader buf, Class<?> declaringC
393393
if (!reflectOnly) {
394394
return new FieldDescriptor(declaringClass, name);
395395
}
396-
return ReflectionObjectFactory.newField(conditions, declaringClass, name, negative ? Object.class : type, modifiers, false, null, null, ReflectionObjectFactory.FIELD_OFFSET_NONE, null,
396+
return ReflectionObjectFactory.newField(dynamicAccessMetadata, declaringClass, name, negative ? Object.class : type, modifiers, false, null, null,
397+
ReflectionObjectFactory.FIELD_OFFSET_NONE, null,
397398
null);
398399
}
399400
boolean trustedFinal = buf.getU1() == 1;
@@ -406,13 +407,14 @@ private static Object decodeField(UnsafeArrayTypeReader buf, Class<?> declaringC
406407
modifiers |= NEGATIVE_FLAG_MASK;
407408
}
408409

409-
Field reflectField = ReflectionObjectFactory.newField(conditions, declaringClass, name, type, modifiers, trustedFinal, signature, annotations, offset, deletedReason, typeAnnotations);
410+
Field reflectField = ReflectionObjectFactory.newField(dynamicAccessMetadata, declaringClass, name, type, modifiers, trustedFinal, signature, annotations, offset, deletedReason,
411+
typeAnnotations);
410412
return reflectOnly ? reflectField : new FieldDescriptor(reflectField);
411413
}
412414

413-
private static RuntimeConditionSet decodeConditions(UnsafeArrayTypeReader buf, int layerId, boolean preserved) {
415+
private static RuntimeDynamicAccessMetadata decodeDynamicAccessMetadata(UnsafeArrayTypeReader buf, int layerId, boolean preserved) {
414416
var conditionTypes = decodeArray(buf, Class.class, _ -> decodeType(buf, layerId), layerId);
415-
return RuntimeConditionSet.createDecoded(conditionTypes, preserved);
417+
return RuntimeDynamicAccessMetadata.createDecoded(conditionTypes, preserved);
416418
}
417419

418420
/**
@@ -523,7 +525,7 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
523525
boolean inHeap = (modifiers & IN_HEAP_FLAG_MASK) != 0;
524526
boolean complete = (modifiers & COMPLETE_FLAG_MASK) != 0;
525527
boolean preserved = (modifiers & PRESERVED_FLAG_MASK) != 0;
526-
RuntimeConditionSet conditions = decodeConditions(buf, layerId, preserved);
528+
RuntimeDynamicAccessMetadata dynamicAccessMetadata = decodeDynamicAccessMetadata(buf, layerId, preserved);
527529
if (inHeap) {
528530
Executable executable = (Executable) decodeObject(buf, layerId);
529531
if (publicOnly && !Modifier.isPublic(executable.getModifiers())) {
@@ -532,10 +534,12 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
532534
* looking for a public one should not result in a missing registration exception.
533535
*/
534536
if (isMethod) {
535-
executable = ReflectionObjectFactory.newMethod(conditions, declaringClass, executable.getName(), executable.getParameterTypes(), Object.class, null, modifiers | NEGATIVE_FLAG_MASK,
537+
executable = ReflectionObjectFactory.newMethod(dynamicAccessMetadata, declaringClass, executable.getName(), executable.getParameterTypes(), Object.class, null,
538+
modifiers | NEGATIVE_FLAG_MASK,
536539
null, null, null, null, null, null, null, layerId);
537540
} else {
538-
executable = ReflectionObjectFactory.newConstructor(conditions, declaringClass, executable.getParameterTypes(), null, modifiers | NEGATIVE_FLAG_MASK, null, null, null, null, null,
541+
executable = ReflectionObjectFactory.newConstructor(dynamicAccessMetadata, declaringClass, executable.getParameterTypes(), null, modifiers | NEGATIVE_FLAG_MASK, null, null, null,
542+
null, null,
539543
null);
540544
}
541545
}
@@ -578,13 +582,13 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
578582
if (!reflectOnly) {
579583
return new MethodDescriptor(declaringClass, name, (String[]) parameterTypes);
580584
}
581-
return ReflectionObjectFactory.newMethod(conditions, declaringClass, name, (Class<?>[]) parameterTypes, negative ? Object.class : returnType, null, modifiers,
585+
return ReflectionObjectFactory.newMethod(dynamicAccessMetadata, declaringClass, name, (Class<?>[]) parameterTypes, negative ? Object.class : returnType, null, modifiers,
582586
null, null, null, null, null, null, null, layerId);
583587
} else {
584588
if (!reflectOnly) {
585589
return new ConstructorDescriptor(declaringClass, (String[]) parameterTypes);
586590
}
587-
return ReflectionObjectFactory.newConstructor(conditions, declaringClass, (Class<?>[]) parameterTypes, null, modifiers, null, null, null, null, null, null);
591+
return ReflectionObjectFactory.newConstructor(dynamicAccessMetadata, declaringClass, (Class<?>[]) parameterTypes, null, modifiers, null, null, null, null, null, null);
588592
}
589593
}
590594
Class<?>[] exceptionTypes = decodeArray(buf, Class.class, _ -> decodeType(buf, layerId), layerId);
@@ -601,14 +605,14 @@ private static Object decodeExecutable(UnsafeArrayTypeReader buf, Class<?> decla
601605

602606
Target_java_lang_reflect_Executable executable;
603607
if (isMethod) {
604-
Method method = ReflectionObjectFactory.newMethod(conditions, declaringClass, name, (Class<?>[]) parameterTypes, returnType, exceptionTypes, modifiers,
608+
Method method = ReflectionObjectFactory.newMethod(dynamicAccessMetadata, declaringClass, name, (Class<?>[]) parameterTypes, returnType, exceptionTypes, modifiers,
605609
signature, annotations, parameterAnnotations, annotationDefault, accessor, reflectParameters, typeAnnotations, layerId);
606610
if (!reflectOnly) {
607611
return new MethodDescriptor(method);
608612
}
609613
executable = SubstrateUtil.cast(method, Target_java_lang_reflect_Executable.class);
610614
} else {
611-
Constructor<?> constructor = ReflectionObjectFactory.newConstructor(conditions, declaringClass, (Class<?>[]) parameterTypes, exceptionTypes,
615+
Constructor<?> constructor = ReflectionObjectFactory.newConstructor(dynamicAccessMetadata, declaringClass, (Class<?>[]) parameterTypes, exceptionTypes,
612616
modifiers, signature, annotations, parameterAnnotations, accessor, reflectParameters, typeAnnotations);
613617
if (!reflectOnly) {
614618
return new ConstructorDescriptor(constructor);

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/ConditionalRuntimeValue.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929

3030
/**
3131
* A image-heap stored {@link ConditionalRuntimeValue#value} that is guarded by run-time computed
32-
* {@link ConditionalRuntimeValue#conditions}.
32+
* conditions.
3333
* </p>
34-
* {@link ConditionalRuntimeValue#conditions} are stored as an array to save space in the image
35-
* heap. This is subject to further optimizations.
34+
* The conditions are stored in {@link ConditionalRuntimeValue#dynamicAccessMetadata} as an array to
35+
* save space in the image heap. This is subject to further optimizations.
3636
*
3737
* @param <T> type of the stored value.
3838
*/
3939
public final class ConditionalRuntimeValue<T> {
40-
final RuntimeConditionSet conditions;
40+
final RuntimeDynamicAccessMetadata dynamicAccessMetadata;
4141
volatile T value;
4242

43-
public ConditionalRuntimeValue(RuntimeConditionSet conditions, T value) {
44-
this.conditions = conditions;
43+
public ConditionalRuntimeValue(RuntimeDynamicAccessMetadata dynamicAccessMetadata, T value) {
44+
this.dynamicAccessMetadata = dynamicAccessMetadata;
4545
this.value = value;
4646
}
4747

@@ -50,12 +50,12 @@ public T getValueUnconditionally() {
5050
return value;
5151
}
5252

53-
public RuntimeConditionSet getConditions() {
54-
return conditions;
53+
public RuntimeDynamicAccessMetadata getDynamicAccessMetadata() {
54+
return dynamicAccessMetadata;
5555
}
5656

5757
public T getValue() {
58-
if (conditions.satisfied()) {
58+
if (dynamicAccessMetadata.satisfied()) {
5959
return value;
6060
} else {
6161
return null;

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/RuntimeConditionSet.java renamed to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/configure/RuntimeDynamicAccessMetadata.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,33 @@
4141
import com.oracle.svm.util.LogUtils;
4242

4343
/**
44-
* Represents a group of {@link #conditions} that guard a value. The conditions are encoded
44+
* The dynamic access metadata for some value that can be accessed at run time. Contains a set of
45+
* {@link #conditions} that dictate whether the value (e.g., a resource) should be accessible; also
46+
* tracks whether the value is present because it was preserved.
4547
* <p>
4648
* If any of the {@link #conditions} is satisfied then the whole set becomes also
47-
* {@link #satisfied}. {@link RuntimeConditionSet}s can be created at build time
49+
* {@link #satisfied}. {@link RuntimeDynamicAccessMetadata}s can be created at build time
4850
* {@link #createHosted(AccessCondition,boolean)} and stored to the image heap, or it can be encoded
4951
* ({@link #getTypesForEncoding()} and later decoded at run time
5052
* ({@link #createDecoded(Object[], boolean)}. The current implementation does not cache
5153
* {@link #conditions}, although this will be implemented in the future (GR-49526)
5254
*/
53-
public class RuntimeConditionSet {
55+
public class RuntimeDynamicAccessMetadata {
5456

5557
private Object[] conditions;
5658
private boolean satisfied;
5759
private volatile boolean preserved;
5860

5961
@Platforms(Platform.HOSTED_ONLY.class)
60-
public static RuntimeConditionSet emptySet(boolean preserved) {
61-
return new RuntimeConditionSet(new Object[0], preserved);
62-
62+
public static RuntimeDynamicAccessMetadata emptySet(boolean preserved) {
63+
return new RuntimeDynamicAccessMetadata(new Object[0], preserved);
6364
}
6465

6566
@Platforms(Platform.HOSTED_ONLY.class)
66-
public static RuntimeConditionSet createHosted(AccessCondition condition, boolean preserved) {
67-
var conditionSet = new RuntimeConditionSet(new Object[0], preserved);
68-
conditionSet.addCondition(condition);
69-
return conditionSet;
67+
public static RuntimeDynamicAccessMetadata createHosted(AccessCondition condition, boolean preserved) {
68+
var metadata = new RuntimeDynamicAccessMetadata(new Object[0], preserved);
69+
metadata.addCondition(condition);
70+
return metadata;
7071
}
7172

7273
@Platforms(Platform.HOSTED_ONLY.class)
@@ -101,12 +102,12 @@ public Set<Class<?>> getTypesForEncoding() {
101102
}
102103
}
103104

104-
public static RuntimeConditionSet unmodifiableEmptySet() {
105-
return UnmodifiableRuntimeConditionSet.UNMODIFIABLE_EMPTY_SET;
105+
public static RuntimeDynamicAccessMetadata unmodifiableEmptyMetadata() {
106+
return UnmodifiableRuntimeDynamicAccessMetadata.UNMODIFIABLE_EMPTY_METADATA;
106107
}
107108

108-
public static RuntimeConditionSet createDecoded(Object[] conditions, boolean preserved) {
109-
return new RuntimeConditionSet(conditions, preserved);
109+
public static RuntimeDynamicAccessMetadata createDecoded(Object[] conditions, boolean preserved) {
110+
return new RuntimeDynamicAccessMetadata(conditions, preserved);
110111
}
111112

112113
/**
@@ -160,7 +161,7 @@ public String toString() {
160161
return conditionsString + " = " + satisfied;
161162
}
162163

163-
private RuntimeConditionSet(Object[] conditions, boolean preserved) {
164+
private RuntimeDynamicAccessMetadata(Object[] conditions, boolean preserved) {
164165
setConditions(conditions);
165166
this.preserved = preserved;
166167
}
@@ -199,10 +200,10 @@ private static Set<Class<?>> getTypesForEncoding(Object condition) {
199200
}
200201
}
201202

202-
public static final class UnmodifiableRuntimeConditionSet extends RuntimeConditionSet {
203-
private static final RuntimeConditionSet UNMODIFIABLE_EMPTY_SET = new UnmodifiableRuntimeConditionSet(new Object[0]);
203+
public static final class UnmodifiableRuntimeDynamicAccessMetadata extends RuntimeDynamicAccessMetadata {
204+
private static final RuntimeDynamicAccessMetadata UNMODIFIABLE_EMPTY_METADATA = new UnmodifiableRuntimeDynamicAccessMetadata(new Object[0]);
204205

205-
private UnmodifiableRuntimeConditionSet(Object[] conditions) {
206+
private UnmodifiableRuntimeDynamicAccessMetadata(Object[] conditions) {
206207
super(conditions, false);
207208
}
208209

0 commit comments

Comments
 (0)