--- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java 2016-01-12 10:00:56.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantReflectionProvider.java 2016-01-12 10:00:56.000000000 -1000 @@ -27,6 +27,7 @@ import java.lang.reflect.Array; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.ConstantReflectionProvider; import jdk.vm.ci.meta.JavaConstant; @@ -45,7 +46,7 @@ /** * Determines whether to treat {@code final} fields with default values as constant. */ - private static final boolean TrustFinalDefaultFields = HotSpotJVMCIRuntime.getBooleanProperty("TrustFinalDefaultFields", true); + private static final boolean TrustFinalDefaultFields = HotSpotJVMCIRuntime.getBooleanProperty(Option.TrustFinalDefaultFields, true); protected final HotSpotJVMCIRuntimeProvider runtime; protected final HotSpotMethodHandleAccessProvider methodHandleAccess; --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2016-01-12 10:00:57.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2016-01-12 10:00:57.000000000 -1000 @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.io.PrintStream; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -85,15 +86,66 @@ } /** + * A list of all supported JVMCI options. + */ + public enum Option { + ImplicitStableValues, + InitTimer, // Note: Not used because of visibility issues (see InitTimer.ENABLED). + PrintConfig, + PrintFlags, + ShowFlags, + TraceMethodDataFilter, + TrustFinalDefaultFields; + + /** + * Prints all option flags to {@code out}. + * + * @param out stream to print to + */ + public static void printFlags(PrintStream out) { + out.println("[List of JVMCI options]"); + for (Option e : values()) { + out.println(e); + } + } + } + + /** + * The prefix for system properties that are JVMCI options. + */ + private static final String JVMCI_OPTION_PROPERTY_PREFIX = "jvmci."; + + /** + * Gets a String value based on a system property {@linkplain VM#getSavedProperty(String) saved} + * at system initialization time. The property name must start with an upper-case letter and is + * prefixed with {@link #JVMCI_OPTION_PROPERTY_PREFIX}. + * + * @param option the name of the system property + * @param def the value to return if there is no system property corresponding to {@code name} + */ + public static String getProperty(Option option, String def) { + String optionName = option.name(); + if (!Character.isUpperCase(optionName.charAt(0))) { + throw new JVMCIError("Option name must start with upper-case letter: " + optionName); + } + String value = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + optionName); + if (value == null) { + return def; + } + return value; + } + + /** * Gets a boolean value based on a system property {@linkplain VM#getSavedProperty(String) - * saved} at system initialization time. The property name is prefixed with "{@code jvmci.}". + * saved} at system initialization time. The property name must start with an upper-case letter + * and is prefixed with {@link #JVMCI_OPTION_PROPERTY_PREFIX}. * - * @param name the name of the system property to derive a boolean value from using + * @param option the name of the system property to derive a boolean value from using * {@link Boolean#parseBoolean(String)} * @param def the value to return if there is no system property corresponding to {@code name} */ - public static boolean getBooleanProperty(String name, boolean def) { - String value = VM.getSavedProperty("jvmci." + name); + public static boolean getBooleanProperty(Option option, boolean def) { + String value = getProperty(option, null); if (value == null) { return def; } @@ -164,7 +216,16 @@ } metaAccessContext = context; - if (Boolean.valueOf(System.getProperty("jvmci.printconfig"))) { + boolean printFlags = getBooleanProperty(Option.PrintFlags, false); + boolean showFlags = getBooleanProperty(Option.ShowFlags, false); + if (printFlags || showFlags) { + Option.printFlags(System.out); + if (printFlags) { + System.exit(0); + } + } + + if (getBooleanProperty(Option.PrintConfig, false)) { printConfig(config, compilerToVm); } --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java 2016-01-12 10:00:58.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java 2016-01-12 10:00:58.000000000 -1000 @@ -29,6 +29,7 @@ import java.lang.reflect.Field; import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.LocationIdentity; import jdk.vm.ci.meta.MetaAccessProvider; @@ -44,7 +45,7 @@ /** * Mark well-known stable fields as such. */ - private static final boolean ImplicitStableValues = HotSpotJVMCIRuntime.getBooleanProperty("ImplicitStableValues", true); + private static final boolean ImplicitStableValues = HotSpotJVMCIRuntime.getBooleanProperty(Option.ImplicitStableValues, true); private final HotSpotResolvedObjectTypeImpl holder; private final String name; --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java 2016-01-12 10:00:59.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java 2016-01-12 10:00:59.000000000 -1000 @@ -37,6 +37,7 @@ import java.util.Map; import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.meta.Constant; import jdk.vm.ci.meta.ConstantPool; import jdk.vm.ci.meta.DefaultProfilingInfo; @@ -417,7 +418,7 @@ return false; } - private static final String TraceMethodDataFilter = System.getProperty("jvmci.traceMethodDataFilter"); + private static final String TraceMethodDataFilter = HotSpotJVMCIRuntime.getProperty(Option.TraceMethodDataFilter, null); @Override public ProfilingInfo getProfilingInfo(boolean includeNormal, boolean includeOSR) { --- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/InitTimer.java 2016-01-12 10:01:00.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.inittimer/src/jdk/vm/ci/inittimer/InitTimer.java 2016-01-12 10:01:00.000000000 -1000 @@ -65,9 +65,11 @@ } /** - * Specifies if initialization timing is enabled. + * Specifies if initialization timing is enabled. Note: this property cannot use + * {@code HotSpotJVMCIRuntime.getBooleanProperty} since that class is not visible from this + * package. */ - private static final boolean ENABLED = Boolean.getBoolean("jvmci.inittimer") || Boolean.getBoolean("jvmci.runtime.TimeInit"); + private static final boolean ENABLED = Boolean.getBoolean("jvmci.InitTimer"); public static final AtomicInteger nesting = ENABLED ? new AtomicInteger() : null; public static final String SPACES = " ";