Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/
package com.oracle.svm.core;

import static com.oracle.svm.core.jvmstat.PerfManager.Options.PerfDataMemoryMappedFile;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -78,14 +80,14 @@ public final class VMInspectionOptions {
", '" + MONITORING_JCMD_NAME + "' (experimental)" +
", or '" + MONITORING_ALL_NAME + "' (deprecated behavior: defaults to '" + MONITORING_ALL_NAME + "' if no argument is provided)";

@APIOption(name = ENABLE_MONITORING_OPTION, defaultValue = MONITORING_DEFAULT_NAME) //
@APIOption(name = ENABLE_MONITORING_OPTION, defaultValue = MONITORING_DEFAULT_NAME)//
@Option(help = "Enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain " + MONITORING_ALLOWED_VALUES_TEXT + ". " +
"For example: '--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_HEAPDUMP_NAME + "," + MONITORING_JFR_NAME + "'.", type = OptionType.User) //
"For example: '--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_HEAPDUMP_NAME + "," + MONITORING_JFR_NAME + "'.", type = OptionType.User)//
public static final HostedOptionKey<AccumulatingLocatableMultiOptionValue.Strings> EnableMonitoringFeatures = new HostedOptionKey<>(
AccumulatingLocatableMultiOptionValue.Strings.buildWithCommaDelimiter(),
VMInspectionOptions::validateEnableMonitoringFeatures);

@Option(help = "Dumps all runtime compiled methods on SIGUSR2.", type = OptionType.User) //
@Option(help = "Dumps all runtime compiled methods on SIGUSR2.", type = OptionType.User)//
public static final HostedOptionKey<Boolean> DumpRuntimeCompilationOnSignal = new HostedOptionKey<>(false, VMInspectionOptions::notSupportedOnWindows);

static {
Expand All @@ -100,7 +102,7 @@ private static void notSupportedOnWindows(HostedOptionKey<Boolean> optionKey) {
}
}

@Option(help = "Print native memory tracking statistics on shutdown if native memory tracking is enabled.", type = OptionType.User) //
@Option(help = "Print native memory tracking statistics on shutdown if native memory tracking is enabled.", type = OptionType.User)//
public static final RuntimeOptionKey<Boolean> PrintNMTStatistics = new RuntimeOptionKey<>(false);

@Platforms(Platform.HOSTED_ONLY.class)
Expand All @@ -122,6 +124,11 @@ public static void validateEnableMonitoringFeatures(@SuppressWarnings("unused")
if (Platform.includedIn(WINDOWS_BASE.class)) {
Set<String> notSupported = getEnabledMonitoringFeatures();
notSupported.retainAll(NOT_SUPPORTED_ON_WINDOWS);
if (!PerfDataMemoryMappedFile.getValue()) {
/* Only not supported on Windows, if a memory-mapped file is needed. */
notSupported.remove(MONITORING_JVMSTAT_NAME);
}

if (!notSupported.isEmpty()) {
String msg = String.format("the option '%s' contains value(s) that are not supported on Windows: %s. Those values will be ignored.", getDefaultMonitoringCommandArgument(),
String.join(", ", notSupported));
Expand Down Expand Up @@ -191,7 +198,8 @@ public static boolean hasJfrSupport() {

@Fold
public static boolean hasJvmstatSupport() {
return hasAllOrKeywordMonitoringSupport(MONITORING_JVMSTAT_NAME) && !Platform.includedIn(WINDOWS_BASE.class);
/* Only not supported on Windows, if a memory-mapped file is needed. */
return hasAllOrKeywordMonitoringSupport(MONITORING_JVMSTAT_NAME) && (!Platform.includedIn(WINDOWS_BASE.class) || !PerfDataMemoryMappedFile.getValue());
}

@Fold
Expand Down Expand Up @@ -221,7 +229,7 @@ public static boolean hasJCmdSupport() {

static class DeprecatedOptions {
@Option(help = "Enables features that allow the VM to be inspected during run time.", type = OptionType.User, //
deprecated = true, deprecationMessage = "Please use '--" + ENABLE_MONITORING_OPTION + "'") //
deprecated = true, deprecationMessage = "Please use '--" + ENABLE_MONITORING_OPTION + "'")//
static final HostedOptionKey<Boolean> AllowVMInspection = new HostedOptionKey<>(false) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
Expand All @@ -232,7 +240,7 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
};

@Option(help = "Dumps all thread stacktraces on SIGQUIT/SIGBREAK.", type = OptionType.User, //
deprecated = true, deprecationMessage = "Please use '--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_THREADDUMP_NAME + "'") //
deprecated = true, deprecationMessage = "Please use '--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_THREADDUMP_NAME + "'")//
public static final HostedOptionKey<Boolean> DumpThreadStacksOnSignal = new HostedOptionKey<>(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@

import java.nio.ByteBuffer;

import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.nativeimage.c.type.CLongPointer;

import jdk.graal.compiler.api.replacements.Fold;

public interface PerfDataSupport {
@Fold
static PerfDataSupport singleton() {
return ImageSingletons.lookup(PerfDataSupport.class);
}

ByteBuffer attach(int lvmid);

void detach(ByteBuffer bb);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.oracle.svm.core.option.HostedOptionKey;
import com.oracle.svm.core.option.RuntimeOptionKey;
import com.oracle.svm.core.thread.RecurringCallbackSupport;
import com.oracle.svm.core.util.ImageHeapMap;
import com.oracle.svm.core.util.VMError;

import jdk.graal.compiler.options.Option;
Expand All @@ -65,7 +66,7 @@ public class PerfManager {
public PerfManager() {
perfDataHolders = new ArrayList<>();
mutablePerfDataEntries = new ArrayList<>();
longEntries = EconomicMap.create();
longEntries = ImageHeapMap.createNonLayeredMap();
perfDataThread = new PerfDataThread(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import java.nio.ByteBuffer;

import org.graalvm.nativeimage.ImageSingletons;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

Expand All @@ -36,32 +34,32 @@
public final class Target_jdk_internal_perf_Perf {
@Substitute
public ByteBuffer attach(int lvmid) {
return ImageSingletons.lookup(PerfDataSupport.class).attach(lvmid);
return PerfDataSupport.singleton().attach(lvmid);
}

@Substitute
public void detach(ByteBuffer bb) {
ImageSingletons.lookup(PerfDataSupport.class).detach(bb);
PerfDataSupport.singleton().detach(bb);
}

@Substitute
public long highResCounter() {
return ImageSingletons.lookup(PerfDataSupport.class).highResCounter();
return PerfDataSupport.singleton().highResCounter();
}

@Substitute
public long highResFrequency() {
return ImageSingletons.lookup(PerfDataSupport.class).highResFrequency();
return PerfDataSupport.singleton().highResFrequency();
}

@Substitute
public ByteBuffer createLong(String name, int variability, int units, long value) {
return ImageSingletons.lookup(PerfDataSupport.class).createLong(name, variability, units, value);
return PerfDataSupport.singleton().createLong(name, variability, units, value);
}

@Substitute
public ByteBuffer createByteArray(String name, int variability, int units, byte[] value, int maxLength) {
return ImageSingletons.lookup(PerfDataSupport.class).createByteArray(name, variability, units, value, maxLength);
return PerfDataSupport.singleton().createByteArray(name, variability, units, value, maxLength);
}

@Substitute
Expand Down
Loading