Skip to content

Commit 5ac4fcd

Browse files
committed
[GR-52454] [GR-53085] Add exit handlers if JFR or NMT are enabled.
PullRequest: graal/17445
2 parents 1caef1c + cf7ed52 commit 5ac4fcd

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateExitHandlerFeature.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626

2727
import com.oracle.svm.core.annotate.Alias;
2828
import com.oracle.svm.core.annotate.TargetClass;
29+
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
2930
import com.oracle.svm.core.feature.InternalFeature;
3031
import com.oracle.svm.core.jdk.RuntimeSupport;
31-
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
3232

3333
@AutomaticallyRegisteredFeature
3434
public class SubstrateExitHandlerFeature implements InternalFeature {
3535
@Override
3636
public void beforeAnalysis(BeforeAnalysisAccess access) {
37-
if (SubstrateOptions.InstallExitHandlers.getValue()) {
37+
if (SubstrateOptions.needsExitHandlers()) {
3838
RuntimeSupport.getRuntimeSupport().addStartupHook(new SubstrateExitHandlerStartupHook());
3939
}
4040
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateOptions.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -715,10 +715,6 @@ public static boolean useLIRBackend() {
715715
@Option(help = "Check if native-toolchain is known to work with native-image", type = Expert)//
716716
public static final HostedOptionKey<Boolean> CheckToolchain = new HostedOptionKey<>(true);
717717

718-
@APIOption(name = "install-exit-handlers")//
719-
@Option(help = "Provide java.lang.Terminator exit handlers", type = User)//
720-
public static final HostedOptionKey<Boolean> InstallExitHandlers = new HostedOptionKey<>(false);
721-
722718
@Option(help = "When set to true, the image generator verifies that the image heap does not contain a home directory as a substring", type = User, stability = OptionStability.STABLE)//
723719
public static final HostedOptionKey<Boolean> DetectUserDirectoriesInImageHeap = new HostedOptionKey<>(false);
724720

@@ -889,6 +885,16 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Integer o
889885
/** Use {@link SubstrateOptions#getPageSize()} instead. */
890886
@Option(help = "The largest page size of machines that can run the image. The default of 0 automatically selects a typically suitable value.")//
891887
protected static final HostedOptionKey<Integer> PageSize = new HostedOptionKey<>(0);
888+
889+
/** Use {@link SubstrateOptions#needsExitHandlers()} instead. */
890+
@APIOption(name = "install-exit-handlers")//
891+
@Option(help = "Provide java.lang.Terminator exit handlers", type = User)//
892+
protected static final HostedOptionKey<Boolean> InstallExitHandlers = new HostedOptionKey<>(false);
893+
}
894+
895+
@Fold
896+
public static final boolean needsExitHandlers() {
897+
return ConcealedOptions.InstallExitHandlers.getValue() || VMInspectionOptions.hasJfrSupport() || VMInspectionOptions.hasNativeMemoryTrackingSupport();
892898
}
893899

894900
@Option(help = "Overwrites the available number of processors provided by the OS. Any value <= 0 means using the processor count from the OS.")//

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private void printExperimentalOptions(ImageClassLoader classLoader) {
356356
if (lmov.getValuesWithOrigins().allMatch(o -> o.getRight().isStable())) {
357357
continue;
358358
} else {
359-
origins = lmov.getValuesWithOrigins().filter(p -> !isStableOrInternalOrigin(p.getRight())).map(p -> p.getRight().toString()).collect(Collectors.joining(", "));
359+
origins = lmov.getValuesWithOrigins().filter(p -> !isStableOrInternalOrigin(p.getRight())).map(p -> p.getRight().toString()).distinct().collect(Collectors.joining(", "));
360360
alternatives = lmov.getValuesWithOrigins().map(p -> SubstrateOptionsParser.commandArgument(option, p.getLeft().toString()))
361361
.filter(c -> !c.startsWith(CommonOptionParser.HOSTED_OPTION_PREFIX))
362362
.collect(Collectors.joining(", "));

0 commit comments

Comments
 (0)