--- old/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2016-01-12 12:10:55.000000000 -1000 +++ new/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java 2016-01-12 12:10:55.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,19 +86,76 @@ } /** - * 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.}". - * - * @param name 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} + * A list of all supported JVMCI options. */ - public static boolean getBooleanProperty(String name, boolean def) { - String value = VM.getSavedProperty("jvmci." + name); - if (value == null) { - return def; + public enum Option { + ImplicitStableValues(boolean.class, true), + InitTimer(boolean.class, false), // Note: Not used (see InitTimer.ENABLED). + PrintConfig(boolean.class, false), + PrintFlags(boolean.class, false), + ShowFlags(boolean.class, false), + TraceMethodDataFilter(String.class, null), + TrustFinalDefaultFields(String.class, true); + + /** + * The prefix for system properties that are JVMCI options. + */ + private static final String JVMCI_OPTION_PROPERTY_PREFIX = "jvmci."; + + private final Class type; + private final Object value; + private final boolean isDefault; + + private Option(Class type, Object defaultValue) { + assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name(); + this.type = type; + + String propertyValue = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + name()); + if (propertyValue == null) { + this.value = defaultValue; + this.isDefault = true; + } else { + if (type == boolean.class) { + this.value = Boolean.parseBoolean(propertyValue); + } else if (type == String.class) { + this.value = propertyValue; + } else { + throw new JVMCIError("Unexpected option type " + type); + } + this.isDefault = false; + } + } + + /** + * Returns the option's value as boolean. + * + * @return option's value + */ + public boolean getBoolean() { + return (boolean) value; + } + + /** + * Returns the option's value as String. + * + * @return option's value + */ + public String getString() { + return (String) value; + } + + /** + * 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 option : values()) { + String assign = option.isDefault ? ":=" : " ="; + out.printf("%9s %-40s %s %-14s%n", option.type.getSimpleName(), option, assign, option.value); + } } - return Boolean.parseBoolean(value); } public static HotSpotJVMCIBackendFactory findFactory(String architecture) { @@ -164,7 +222,16 @@ } metaAccessContext = context; - if (Boolean.valueOf(System.getProperty("jvmci.printconfig"))) { + boolean printFlags = Option.PrintFlags.getBoolean(); + boolean showFlags = Option.ShowFlags.getBoolean(); + if (printFlags || showFlags) { + Option.printFlags(System.out); + if (printFlags) { + System.exit(0); + } + } + + if (Option.PrintConfig.getBoolean()) { printConfig(config, compilerToVm); }