--- 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); }