Skip to content

Commit d3b758d

Browse files
committed
Move the logging functionality of DynamicAccessInferenceLoggingFeature to a singleton and style fixes.
1 parent 5844f34 commit d3b758d

14 files changed

+860
-842
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import java.util.regex.Pattern;
5656
import java.util.stream.Collectors;
5757

58+
import com.oracle.svm.hosted.dynamicaccessinference.DynamicAccessInferenceLog;
5859
import com.oracle.svm.hosted.dynamicaccessinference.StrictDynamicAccessInferenceFeature;
5960
import org.graalvm.nativeimage.ImageSingletons;
6061
import org.graalvm.nativeimage.hosted.RuntimeResourceAccess;
@@ -175,6 +176,8 @@ private record CompiledConditionalPattern(ConfigurationCondition condition, Reso
175176
private int loadedConfigurations;
176177
private ImageClassLoader imageClassLoader;
177178

179+
private DynamicAccessInferenceLog inferenceLog;
180+
178181
private class ResourcesRegistryImpl extends ConditionalConfigurationRegistry implements ResourcesRegistry<ConfigurationCondition> {
179182
private final ClassInitializationSupport classInitializationSupport = ClassInitializationSupport.singleton();
180183

@@ -393,6 +396,7 @@ public void afterRegistration(AfterRegistrationAccess a) {
393396
ImageSingletons.add(RuntimeResourceSupport.class, resourcesRegistry);
394397
EmbeddedResourcesInfo embeddedResourcesInfo = new EmbeddedResourcesInfo();
395398
ImageSingletons.add(EmbeddedResourcesInfo.class, embeddedResourcesInfo);
399+
inferenceLog = ImageSingletons.contains(DynamicAccessInferenceLog.class) ? DynamicAccessInferenceLog.singleton() : null;
396400
}
397401

398402
private static ResourcesRegistryImpl resourceRegistryImpl() {
@@ -713,6 +717,9 @@ public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Rec
713717
throw VMError.shouldNotReachHere(e);
714718
}
715719
b.add(ReachabilityRegistrationNode.create(() -> RuntimeResourceAccess.addResource(clazz.getModule(), resourceName), reason));
720+
if (inferenceLog != null) {
721+
inferenceLog.logRegistration(b, reason, targetMethod, clazz, new String[]{resource});
722+
}
716723
return true;
717724
}
718725
return false;

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/dataflow/AbstractInterpreter.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -930,10 +930,10 @@ public static Context create(ResolvedJavaMethod method, int bci, int opcode) {
930930
}
931931

932932
/**
933-
* @return The default abstract value. This value usually represents an over saturated value
933+
* @return The default abstract value. This value usually represents an over-saturated value
934934
* from which no useful information can be inferred.
935935
*/
936-
protected abstract T bottom();
936+
protected abstract T defaultValue();
937937

938938
/**
939939
* Merge two matching operand stack or local variable table values from divergent control flow
@@ -956,7 +956,7 @@ public static Context create(ResolvedJavaMethod method, int bci, int opcode) {
956956
* @return The value to store in the local variable table.
957957
*/
958958
protected T storeMethodArgument(ResolvedJavaMethod method, int argumentIndex, int variableIndex) {
959-
return bottom();
959+
return defaultValue();
960960
}
961961

962962
/**
@@ -966,7 +966,7 @@ protected T storeMethodArgument(ResolvedJavaMethod method, int argumentIndex, in
966966
* @return The value representing the exception object pushed on the operand stack.
967967
*/
968968
protected T pushExceptionObject(List<JavaType> exceptionTypes) {
969-
return bottom();
969+
return defaultValue();
970970
}
971971

972972
/**
@@ -980,7 +980,7 @@ protected T pushExceptionObject(List<JavaType> exceptionTypes) {
980980
* @return The abstract value to be pushed on the operand stack.
981981
*/
982982
protected T pushConstant(Context context, AbstractFrame<T> state, Constant constant) {
983-
return bottom();
983+
return defaultValue();
984984
}
985985

986986
/**
@@ -993,7 +993,7 @@ protected T pushConstant(Context context, AbstractFrame<T> state, Constant const
993993
* @return The abstract value to be pushed on the operand stack.
994994
*/
995995
protected T pushType(Context context, AbstractFrame<T> state, JavaType type) {
996-
return bottom();
996+
return defaultValue();
997997
}
998998

999999
/**
@@ -1021,7 +1021,7 @@ protected T loadVariable(Context context, AbstractFrame<T> state, int variableIn
10211021
* @return The abstract value representing the loaded element to be pushed on the operand stack.
10221022
*/
10231023
protected T loadArrayElement(Context context, AbstractFrame<T> state, T array, T index) {
1024-
return bottom();
1024+
return defaultValue();
10251025
}
10261026

10271027
/**
@@ -1063,7 +1063,7 @@ protected void storeArrayElement(Context context, AbstractFrame<T> state, T arra
10631063
* @return The abstract value representing the result of the binary operation.
10641064
*/
10651065
protected T binaryOperation(Context context, AbstractFrame<T> state, T left, T right) {
1066-
return bottom();
1066+
return defaultValue();
10671067
}
10681068

10691069
/**
@@ -1076,7 +1076,7 @@ protected T binaryOperation(Context context, AbstractFrame<T> state, T left, T r
10761076
* @return The abstract value representing the result of the unary operation.
10771077
*/
10781078
protected T unaryOperation(Context context, AbstractFrame<T> state, T value) {
1079-
return bottom();
1079+
return defaultValue();
10801080
}
10811081

10821082
/**
@@ -1091,7 +1091,7 @@ protected T unaryOperation(Context context, AbstractFrame<T> state, T value) {
10911091
* @return The abstract value of the accessed local variable after incrementing.
10921092
*/
10931093
protected T incrementVariable(Context context, AbstractFrame<T> state, int variableIndex, int incrementBy, T value) {
1094-
return bottom();
1094+
return defaultValue();
10951095
}
10961096

10971097
/**
@@ -1104,7 +1104,7 @@ protected T incrementVariable(Context context, AbstractFrame<T> state, int varia
11041104
* @return The abstract value after casting.
11051105
*/
11061106
protected T castOperation(Context context, AbstractFrame<T> state, T value) {
1107-
return bottom();
1107+
return defaultValue();
11081108
}
11091109

11101110
/**
@@ -1118,7 +1118,7 @@ protected T castOperation(Context context, AbstractFrame<T> state, T value) {
11181118
* @return The result of the comparison operation.
11191119
*/
11201120
protected T comparisonOperation(Context context, AbstractFrame<T> state, T left, T right) {
1121-
return bottom();
1121+
return defaultValue();
11221122
}
11231123

11241124
/**
@@ -1204,7 +1204,7 @@ protected void returnVoid(Context context, AbstractFrame<T> state) {
12041204
* @return The abstract representation of the accessed field's value.
12051205
*/
12061206
protected T loadStaticField(Context context, AbstractFrame<T> state, JavaField field) {
1207-
return bottom();
1207+
return defaultValue();
12081208
}
12091209

12101210
/**
@@ -1231,7 +1231,7 @@ protected void storeStaticField(Context context, AbstractFrame<T> state, JavaFie
12311231
* @return The abstract representation of the accessed field's value.
12321232
*/
12331233
protected T loadField(Context context, AbstractFrame<T> state, JavaField field, T object) {
1234-
return bottom();
1234+
return defaultValue();
12351235
}
12361236

12371237
/**
@@ -1260,7 +1260,7 @@ protected void storeField(Context context, AbstractFrame<T> state, JavaField fie
12601260
* @return The abstract representation of the result of the invocation.
12611261
*/
12621262
protected T invokeMethod(Context context, AbstractFrame<T> state, JavaMethod method, List<T> operands) {
1263-
return bottom();
1263+
return defaultValue();
12641264
}
12651265

12661266
/**
@@ -1287,7 +1287,7 @@ protected void invokeVoidMethod(Context context, AbstractFrame<T> state, JavaMet
12871287
* @return Abstract representation of the appendix.
12881288
*/
12891289
protected T pushAppendix(JavaMethod method, JavaConstant appendix) {
1290-
return bottom();
1290+
return defaultValue();
12911291
}
12921292

12931293
/**
@@ -1300,7 +1300,7 @@ protected T pushAppendix(JavaMethod method, JavaConstant appendix) {
13001300
* @return The abstract representation of the object.
13011301
*/
13021302
protected T newObject(Context context, AbstractFrame<T> state, JavaType type) {
1303-
return bottom();
1303+
return defaultValue();
13041304
}
13051305

13061306
/**
@@ -1314,7 +1314,7 @@ protected T newObject(Context context, AbstractFrame<T> state, JavaType type) {
13141314
* @return The abstract representation of the array.
13151315
*/
13161316
protected T newArray(Context context, AbstractFrame<T> state, JavaType type, List<T> counts) {
1317-
return bottom();
1317+
return defaultValue();
13181318
}
13191319

13201320
/**
@@ -1326,7 +1326,7 @@ protected T newArray(Context context, AbstractFrame<T> state, JavaType type, Lis
13261326
* @return The abstract representation of the array's length.
13271327
*/
13281328
protected T arrayLength(Context context, AbstractFrame<T> state, T array) {
1329-
return bottom();
1329+
return defaultValue();
13301330
}
13311331

13321332
/**
@@ -1350,7 +1350,7 @@ protected void doThrow(Context context, AbstractFrame<T> state, T throwable) {
13501350
* @return The abstract representation of the instruction's result.
13511351
*/
13521352
protected T castCheckOperation(Context context, AbstractFrame<T> state, JavaType type, T object) {
1353-
return bottom();
1353+
return defaultValue();
13541354
}
13551355

13561356
/**

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/dataflow/DataFlowAnalysisException.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class DataFlowAnalysisException extends RuntimeException {
3535

3636
@Serial private static final long serialVersionUID = 1L;
3737

38-
public DataFlowAnalysisException() {
39-
super();
40-
}
41-
4238
public DataFlowAnalysisException(String message) {
4339
super(message);
4440
}

0 commit comments

Comments
 (0)