Skip to content

Commit

Permalink
[GR-52454] [GR-53085] Add exit handlers if JFR or NMT are enabled.
Browse files Browse the repository at this point in the history
PullRequest: graal/17445
  • Loading branch information
fniephaus committed Apr 7, 2024
2 parents 1caef1c + cf7ed52 commit 5ac4fcd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;
import com.oracle.svm.core.feature.InternalFeature;
import com.oracle.svm.core.jdk.RuntimeSupport;
import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature;

@AutomaticallyRegisteredFeature
public class SubstrateExitHandlerFeature implements InternalFeature {
@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
if (SubstrateOptions.InstallExitHandlers.getValue()) {
if (SubstrateOptions.needsExitHandlers()) {
RuntimeSupport.getRuntimeSupport().addStartupHook(new SubstrateExitHandlerStartupHook());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -715,10 +715,6 @@ public static boolean useLIRBackend() {
@Option(help = "Check if native-toolchain is known to work with native-image", type = Expert)//
public static final HostedOptionKey<Boolean> CheckToolchain = new HostedOptionKey<>(true);

@APIOption(name = "install-exit-handlers")//
@Option(help = "Provide java.lang.Terminator exit handlers", type = User)//
public static final HostedOptionKey<Boolean> InstallExitHandlers = new HostedOptionKey<>(false);

@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)//
public static final HostedOptionKey<Boolean> DetectUserDirectoriesInImageHeap = new HostedOptionKey<>(false);

Expand Down Expand Up @@ -889,6 +885,16 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Integer o
/** Use {@link SubstrateOptions#getPageSize()} instead. */
@Option(help = "The largest page size of machines that can run the image. The default of 0 automatically selects a typically suitable value.")//
protected static final HostedOptionKey<Integer> PageSize = new HostedOptionKey<>(0);

/** Use {@link SubstrateOptions#needsExitHandlers()} instead. */
@APIOption(name = "install-exit-handlers")//
@Option(help = "Provide java.lang.Terminator exit handlers", type = User)//
protected static final HostedOptionKey<Boolean> InstallExitHandlers = new HostedOptionKey<>(false);
}

@Fold
public static final boolean needsExitHandlers() {
return ConcealedOptions.InstallExitHandlers.getValue() || VMInspectionOptions.hasJfrSupport() || VMInspectionOptions.hasNativeMemoryTrackingSupport();
}

@Option(help = "Overwrites the available number of processors provided by the OS. Any value <= 0 means using the processor count from the OS.")//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private void printExperimentalOptions(ImageClassLoader classLoader) {
if (lmov.getValuesWithOrigins().allMatch(o -> o.getRight().isStable())) {
continue;
} else {
origins = lmov.getValuesWithOrigins().filter(p -> !isStableOrInternalOrigin(p.getRight())).map(p -> p.getRight().toString()).collect(Collectors.joining(", "));
origins = lmov.getValuesWithOrigins().filter(p -> !isStableOrInternalOrigin(p.getRight())).map(p -> p.getRight().toString()).distinct().collect(Collectors.joining(", "));
alternatives = lmov.getValuesWithOrigins().map(p -> SubstrateOptionsParser.commandArgument(option, p.getLeft().toString()))
.filter(c -> !c.startsWith(CommonOptionParser.HOSTED_OPTION_PREFIX))
.collect(Collectors.joining(", "));
Expand Down

0 comments on commit 5ac4fcd

Please sign in to comment.