53
53
import com .oracle .svm .core .option .HostedOptionKey ;
54
54
import com .oracle .svm .core .option .RuntimeOptionKey ;
55
55
import com .oracle .svm .core .option .SubstrateOptionsParser ;
56
+ import com .oracle .svm .core .thread .VMOperation ;
56
57
import com .oracle .svm .core .util .VMError ;
57
58
58
59
import jdk .graal .compiler .api .replacements .Fold ;
@@ -89,6 +90,11 @@ public static class Options {
89
90
}
90
91
91
92
private RecordOptions options ;
93
+
94
+ /**
95
+ * The configuration set to trace with. Do not read this field directly when tracing; instead
96
+ * use {@link #getConfigurationSetForTracing()} to acquire it.
97
+ */
92
98
private volatile ConfigurationSet config ;
93
99
94
100
@ Fold
@@ -104,6 +110,18 @@ public boolean enabled() {
104
110
return options != null ;
105
111
}
106
112
113
+ /**
114
+ * Returns the configuration set to trace with. Returns {@code null} if tracing should not be
115
+ * performed for some reason.
116
+ */
117
+ private ConfigurationSet getConfigurationSetForTracing () {
118
+ if (VMOperation .isInProgress ()) {
119
+ // Do not trace during VM operations.
120
+ return null ;
121
+ }
122
+ return config ;
123
+ }
124
+
107
125
/**
108
126
* Marks the given type as reachable from reflection.
109
127
*
@@ -123,7 +141,7 @@ public void traceProxyType(List<String> interfaceNames) {
123
141
124
142
private ConfigurationType traceReflectionTypeImpl (ConfigurationTypeDescriptor typeDescriptor ) {
125
143
assert enabled ();
126
- ConfigurationSet configurationSet = config ;
144
+ ConfigurationSet configurationSet = getConfigurationSetForTracing () ;
127
145
if (configurationSet != null ) {
128
146
return configurationSet .getReflectionConfiguration ().getOrCreateType (UnresolvedConfigurationCondition .alwaysTrue (), typeDescriptor );
129
147
}
@@ -150,7 +168,7 @@ public ConfigurationType traceJNIType(String className) {
150
168
*/
151
169
public void traceResource (String resourceName , String moduleName ) {
152
170
assert enabled ();
153
- ConfigurationSet configurationSet = config ;
171
+ ConfigurationSet configurationSet = getConfigurationSetForTracing () ;
154
172
if (configurationSet != null ) {
155
173
configurationSet .getResourceConfiguration ().addGlobPattern (UnresolvedConfigurationCondition .alwaysTrue (), resourceName , moduleName );
156
174
}
@@ -161,7 +179,7 @@ public void traceResource(String resourceName, String moduleName) {
161
179
*/
162
180
public void traceResourceBundle (String baseName ) {
163
181
assert enabled ();
164
- ConfigurationSet configurationSet = config ;
182
+ ConfigurationSet configurationSet = getConfigurationSetForTracing () ;
165
183
if (configurationSet != null ) {
166
184
configurationSet .getResourceConfiguration ().addBundle (UnresolvedConfigurationCondition .alwaysTrue (), baseName , List .of ());
167
185
}
0 commit comments