# HG changeset patch # User Doug Simon # Date 1452300057 -3600 # Node ID 92fce0754cc570e50d66ea3a5fccd8727cca2900 # Parent c238d6294bc37aa03e796f1b16e32da5f14de8fa converted all explicit uses of "graal." system properties to use @Option instead and added "test." prefix to all tests using such a property diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/GraalOptions.java Sat Jan 09 01:40:57 2016 +0100 @@ -302,12 +302,15 @@ @Option(help = "Generate SSA LIR.", type = OptionType.Debug) public static final OptionValue SSA_LIR = new OptionValue<>(true); - /** - * Counts the various paths taken through snippets. - */ - @Option(help = "", type = OptionType.Debug) + @Option(help = "Enable counters for various paths in snippets.", type = OptionType.Debug) public static final OptionValue SnippetCounters = new OptionValue<>(false); + @Option(help = "Eagerly construct extra snippet info.", type = OptionType.Debug) + public static final OptionValue EagerSnippets = new OptionValue<>(false); + + @Option(help = "Use a cache for snippet graphs.", type = OptionType.Debug) + public static final OptionValue UseSnippetGraphCache = new OptionValue<>(true); + @Option(help = "Enable expensive assertions", type = OptionType.Debug) public static final OptionValue DetailedAsserts = new StableOptionValue() { @Override diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Fingerprint.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Fingerprint.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Fingerprint.java Sat Jan 09 01:40:57 2016 +0100 @@ -28,18 +28,28 @@ import java.util.List; import java.util.stream.Collectors; +import com.oracle.graal.options.Option; +import com.oracle.graal.options.OptionValue; + /** * Facility for fingerprinting execution. */ public class Fingerprint implements AutoCloseable { - public static final String ENABLED_PROPERTY_NAME = "jvmci.fingerprint"; + public static class Options { + @Option(help = "Enables execution fingerprinting.")// + public static final OptionValue UseFingerprinting = new OptionValue<>(false); + + @Option(help = "Fingerprinting event at which to execute breakpointable code.")// + public static final OptionValue FingerprintingBreakpointEvent = new OptionValue<>(-1); + } + + // public static final String ENABLED_PROPERTY_NAME = "jvmci.fingerprint"; /** - * Determines whether fingerprinting is enabled. This is set by the - * {@value #ENABLED_PROPERTY_NAME} system property when this class is initialized. + * Determines whether fingerprinting is enabled. */ - public static final boolean ENABLED = Boolean.getBoolean(ENABLED_PROPERTY_NAME); + public static final boolean ENABLED = Options.UseFingerprinting.getValue(); private static final ThreadLocal current = ENABLED ? new ThreadLocal<>() : null; @@ -100,14 +110,14 @@ } } - private static final int BREAKPOINT_EVENT = Integer.getInteger(ENABLED_PROPERTY_NAME + ".breakpointEvent", -1); + private static final int BREAKPOINT_EVENT = Options.FingerprintingBreakpointEvent.getValue(); /** * Submits an execution event for the purpose of recording or verifying a fingerprint. This must * only be called if {@link #ENABLED} is {@code true}. */ public static void submit(String format, Object... args) { - assert ENABLED : "fingerprinting must be enabled (-D" + ENABLED_PROPERTY_NAME + "=true)"; + assert ENABLED : "fingerprinting must be enabled (-G:+" + Options.UseFingerprinting.getName() + ")"; Fingerprint fingerprint = current.get(); if (fingerprint != null) { int eventId = fingerprint.nextEventId(); diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java Sat Jan 09 01:40:57 2016 +0100 @@ -55,6 +55,10 @@ public static final OptionValue VerifyGraalGraphs = new OptionValue<>(true); @Option(help = "Perform expensive verification of graph inputs, usages, successors and predecessors", type = OptionType.Debug)// public static final OptionValue VerifyGraalGraphEdges = new OptionValue<>(false); + @Option(help = "Graal graph compression is performed when percent of live nodes falls below this value", type = OptionType.Debug)// + public static final OptionValue GraphCompressionThreshold = new OptionValue<>(70); + @Option(help = "Use Unsafe to clone graph nodes thus avoiding copying fields that will be re-initialized anyway", type = OptionType.Debug)// + public static final OptionValue CloneNodesWithUnsafe = new OptionValue<>(true); } public final String name; @@ -751,11 +755,7 @@ static final Node PLACE_HOLDER = new PlaceHolderNode(); - /** - * When the percent of live nodes in {@link #nodes} fall below this number, a call to - * {@link #maybeCompress()} will actually do compression. - */ - public static final int COMPRESSION_THRESHOLD = Integer.getInteger("graal.graphCompressionThreshold", 70); + public static final int COMPRESSION_THRESHOLD = Options.GraphCompressionThreshold.getValue(); private static final DebugMetric GraphCompressions = Debug.metric("GraphCompressions"); diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Sat Jan 09 01:40:57 2016 +0100 @@ -100,7 +100,7 @@ public abstract class Node implements Cloneable, Formattable { public static final NodeClass TYPE = null; - public static final boolean USE_UNSAFE_TO_CLONE = Boolean.parseBoolean(System.getProperty("graal.node.useUnsafeToClone", "true")); + public static final boolean USE_UNSAFE_TO_CLONE = Graph.Options.CloneNodesWithUnsafe.getValue(); static final int DELETED_ID_START = -1000000000; static final int INITIAL_ID = -1; diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalCompilerFactory.java Sat Jan 09 01:40:57 2016 +0100 @@ -22,6 +22,7 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.options.OptionValue.PROFILE_OPTIONVALUE_PROPERTY_NAME; import static jdk.vm.ci.inittimer.InitTimer.timer; import java.io.File; @@ -50,6 +51,25 @@ public abstract class HotSpotGraalCompilerFactory implements JVMCICompilerFactory { + /** + * The name of the system property specifying a file containing extra Graal option settings. + */ + private static final String GRAAL_OPTIONS_FILE_PROPERTY_NAME = "graal.options.file"; + + /** + * The prefix for system properties that correspond to {@link Option} annotated fields. A field + * named {@code MyOption} will have its value set from a system property with the name + * {@code GRAAL_OPTION_PROPERTY_PREFIX + "MyOption"}. + */ + public static final String GRAAL_OPTION_PROPERTY_PREFIX = "graal.option."; + + /** + * Gets the system property assignment that would set the current value for a given option. + */ + public static String asSystemPropertySetting(OptionValue value) { + return GRAAL_OPTION_PROPERTY_PREFIX + value.getName() + "=" + value.getValue(); + } + static { initializeOptions(); } @@ -81,10 +101,10 @@ /** * Parses the options in the file denoted by the {@linkplain VM#getSavedProperty(String) saved} - * system property named {@code "graal.options.file"} if the file exists followed by the options - * encoded in saved system properties whose names start with {@code "graal.option."}. Key/value - * pairs are parsed from the file denoted by {@code "graal.options.file"} with - * {@link Properties#load(java.io.Reader)}. + * system property named {@value HotSpotGraalCompilerFactory#GRAAL_OPTIONS_FILE_PROPERTY_NAME} + * if the file exists followed by the options encoded in saved system properties whose names + * start with {@code "graal.option."}. Key/value pairs are parsed from the file denoted by + * {@code "graal.options.file"} with {@link Properties#load(java.io.Reader)}. */ @SuppressWarnings("try") private static void initializeOptions() { @@ -92,7 +112,7 @@ boolean jdk8OrEarlier = System.getProperty("java.specification.version").compareTo("1.9") < 0; GraalJarsOptionDescriptorsProvider odp = jdk8OrEarlier ? GraalJarsOptionDescriptorsProvider.create() : null; - String optionsFile = System.getProperty("graal.options.file"); + String optionsFile = System.getProperty(GRAAL_OPTIONS_FILE_PROPERTY_NAME); if (optionsFile != null) { File graalOptions = new File(optionsFile); @@ -120,9 +140,13 @@ Map optionSettings = new HashMap<>(); for (Map.Entry e : savedProps.entrySet()) { String name = (String) e.getKey(); - if (name.startsWith("graal.option.")) { - String value = (String) e.getValue(); - optionSettings.put(name.substring("graal.option.".length()), value); + if (name.startsWith(GRAAL_OPTION_PROPERTY_PREFIX)) { + if (name.equals(GRAAL_OPTIONS_FILE_PROPERTY_NAME) || name.equals(PROFILE_OPTIONVALUE_PROPERTY_NAME)) { + // Ignore well known properties that do not denote an option + } else { + String value = (String) e.getValue(); + optionSettings.put(name.substring(GRAAL_OPTION_PROPERTY_PREFIX.length()), value); + } } } diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotspotSnippetsOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotspotSnippetsOptions.java Sat Jan 09 01:40:57 2016 +0100 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.replacements; + +import com.oracle.graal.options.Option; +import com.oracle.graal.options.OptionType; +import com.oracle.graal.options.OptionValue; + +/** + * Options related to HotSpot snippets in this package. + * + * Note: This must be a top level class to work around for Eclipse bug 477597. + */ +class HotspotSnippetsOptions { + + // @formatter:off + @Option(help = "If the probability that a type check will hit one the profiled types (up to " + + "TypeCheckMaxHints) is below this value, the type check will be compiled without profiling info", type = OptionType.Expert) + static final OptionValue TypeCheckMinProfileHitProbability = new OptionValue<>(0.5); + + @Option(help = "The maximum number of profiled types that will be used when compiling a profiled type check. " + + "Note that TypeCheckMinProfileHitProbability also influences whether profiling info is used in compiled type checks.", type = OptionType.Expert) + static final OptionValue TypeCheckMaxHints = new OptionValue<>(2); + + @Option(help = "Use a VM runtime call to load and clear the exception object from the thread at the start of a compiled exception handler.", type = OptionType.Debug) + static final OptionValue LoadExceptionObjectInVM = new OptionValue<>(false); + + @Option(help = "Enable profiling of allocation sites.", type = OptionType.Debug) + static final OptionValue ProfileAllocations = new OptionValue<>(false); + + @Option(help = "Enable profiling of monitor operations.", type = OptionType.Debug) + static final OptionValue ProfileMonitors = new OptionValue<>(false); + + @Option(help = "Trace monitor operations on objects whose type contains this substring.", type = OptionType.Debug) + static final OptionValue TraceMonitorsTypeFilter = new OptionValue<>(null); + + @Option(help = "Trace monitor operations in methods whose fully qualified name contains this substring.", type = OptionType.Debug) + static final OptionValue TraceMonitorsMethodFilter = new OptionValue<>(null); + + @Option(help = "Emit extra code to dynamically check monitor operations are balanced.", type = OptionType.Debug) + static final OptionValue VerifyBalancedMonitors = new OptionValue<>(false); + //@formatter:on +} diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippets.java Sat Jan 09 01:40:57 2016 +0100 @@ -25,8 +25,8 @@ import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.PRIMARY_SUPERS_LOCATION; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.SECONDARY_SUPER_CACHE_LOCATION; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.loadHubIntrinsic; -import static com.oracle.graal.hotspot.replacements.InstanceOfSnippetsOptions.TypeCheckMaxHints; -import static com.oracle.graal.hotspot.replacements.InstanceOfSnippetsOptions.TypeCheckMinProfileHitProbability; +import static com.oracle.graal.hotspot.replacements.HotspotSnippetsOptions.TypeCheckMaxHints; +import static com.oracle.graal.hotspot.replacements.HotspotSnippetsOptions.TypeCheckMinProfileHitProbability; import static com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.checkSecondarySubType; import static com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.checkUnknownSubType; import static com.oracle.graal.hotspot.replacements.TypeCheckSnippetUtils.createHints; diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippetsOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/InstanceOfSnippetsOptions.java Sat Jan 09 01:22:31 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot.replacements; - -import com.oracle.graal.options.Option; -import com.oracle.graal.options.OptionType; -import com.oracle.graal.options.OptionValue; - -/** - * Options related to {@link InstanceOfSnippets}. - * - * Note: This must be a top level class to work around for Eclipse bug 477597. - */ -class InstanceOfSnippetsOptions { - - // @formatter:off - @Option(help = "If the probability that a type check will hit one the profiled types (up to " + - "TypeCheckMaxHints) is below this value, the type check will be compiled without profiling info", type = OptionType.Expert) - static final OptionValue TypeCheckMinProfileHitProbability = new OptionValue<>(0.5); - - @Option(help = "The maximum number of profiled types that will be used when compiling a profiled type check. " + - "Note that TypeCheckMinProfileHitProbability also influences whether profiling info is used in compiled type checks.", type = OptionType.Expert) - static final OptionValue TypeCheckMaxHints = new OptionValue<>(2); - // @formatter:on -} diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/LoadExceptionObjectSnippets.java Sat Jan 09 01:40:57 2016 +0100 @@ -65,7 +65,7 @@ /** * Alternative way to implement exception object loading. */ - private static final boolean USE_C_RUNTIME = Boolean.getBoolean("graal.loadExceptionObject.useCRuntime"); + private static final boolean USE_C_RUNTIME = HotspotSnippetsOptions.LoadExceptionObjectInVM.getValue(); @Snippet public static Object loadException(@ConstantParameter Register threadRegister) { diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/MonitorSnippets.java Sat Jan 09 01:40:57 2016 +0100 @@ -45,6 +45,10 @@ import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.useBiasedLocking; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.verifyOop; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.wordSize; +import static com.oracle.graal.hotspot.replacements.HotspotSnippetsOptions.ProfileMonitors; +import static com.oracle.graal.hotspot.replacements.HotspotSnippetsOptions.TraceMonitorsMethodFilter; +import static com.oracle.graal.hotspot.replacements.HotspotSnippetsOptions.TraceMonitorsTypeFilter; +import static com.oracle.graal.hotspot.replacements.HotspotSnippetsOptions.VerifyBalancedMonitors; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.FREQUENT_PROBABILITY; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.VERY_FAST_PATH_PROBABILITY; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.VERY_SLOW_PATH_PROBABILITY; @@ -96,9 +100,6 @@ import com.oracle.graal.nodes.memory.address.OffsetAddressNode; import com.oracle.graal.nodes.spi.LoweringTool; import com.oracle.graal.nodes.type.StampTool; -import com.oracle.graal.options.Option; -import com.oracle.graal.options.OptionType; -import com.oracle.graal.options.OptionValue; import com.oracle.graal.phases.common.inlining.InliningUtil; import com.oracle.graal.replacements.Log; import com.oracle.graal.replacements.Snippet; @@ -129,25 +130,25 @@ * JavaThread*:23 epoch:2 age:4 biased_lock:1 lock:2 (biased object) * size:32 ------------------------------------------>| (CMS free block) * PromotedObject*:29 ---------->| promo_bits:3 ----->| (CMS promoted object) - * + * * 64 bits: * -------- * unused:25 hash:31 -->| unused:1 age:4 biased_lock:1 lock:2 (normal object) * JavaThread*:54 epoch:2 unused:1 age:4 biased_lock:1 lock:2 (biased object) * PromotedObject*:61 --------------------->| promo_bits:3 ----->| (CMS promoted object) * size:64 ----------------------------------------------------->| (CMS free block) - * + * * unused:25 hash:31 -->| cms_free:1 age:4 biased_lock:1 lock:2 (COOPs && normal object) * JavaThread*:54 epoch:2 cms_free:1 age:4 biased_lock:1 lock:2 (COOPs && biased object) * narrowOop:32 unused:24 cms_free:1 unused:4 promo_bits:3 ----->| (COOPs && CMS promoted object) * unused:21 size:35 -->| cms_free:1 unused:7 ------------------>| (COOPs && CMS free block) - * + * * - hash contains the identity hash value: largest value is * 31 bits, see os::random(). Also, 64-bit vm's require * a hash value no bigger than 32 bits because they will not * properly generate a mask larger than that: see library_call.cpp * and c1_CodePatterns_sparc.cpp. - * + * * - the biased lock pattern is used to bias a lock toward a given * thread. When this pattern is set in the low three bits, the lock * is either biased toward a given thread or "anonymously" biased, @@ -156,12 +157,12 @@ * be performed by that thread without using atomic operations. * When a lock's bias is revoked, it reverts back to the normal * locking scheme described below. - * + * * Note that we are overloading the meaning of the "unlocked" state * of the header. Because we steal a bit from the age we can * guarantee that the bias pattern will never be seen for a truly * unlocked object. - * + * * Note also that the biased state contains the age bits normally * contained in the object header. Large increases in scavenge * times were seen when these bits were absent and an arbitrary age @@ -172,18 +173,18 @@ * a very large value (currently 128 bytes (32bVM) or 256 bytes (64bVM)) * to make room for the age bits & the epoch bits (used in support of * biased locking), and for the CMS "freeness" bit in the 64bVM (+COOPs). - * + * * [JavaThread* | epoch | age | 1 | 01] lock is biased toward given thread * [0 | epoch | age | 1 | 01] lock is anonymously biased - * + * * - the two lock bits are used to describe three states: locked/unlocked and monitor. - * + * * [ptr | 00] locked ptr points to real header on stack * [header | 0 | 01] unlocked regular object header * [ptr | 10] monitor inflated lock (header is wapped out) * [ptr | 11] marked used by markSweep to mark an object * not valid at any other time - * + * * We assume that stack/thread pointers have the lowest two bits cleared. * * @@ -192,34 +193,13 @@ */ public class MonitorSnippets implements Snippets { - public static class Options { - - //@formatter:off - @Option(help = "", type = OptionType.Debug) - public static final OptionValue ProfileMonitors = new OptionValue<>(false); - //@formatter:on - } - private static final boolean PROFILE_CONTEXT = false; @Fold static boolean doProfile() { - return Options.ProfileMonitors.getValue(); + return ProfileMonitors.getValue(); } - /** - * Monitor operations on objects whose type contains this substring will be traced. - */ - private static final String TRACE_TYPE_FILTER = System.getProperty("graal.monitors.trace.typeFilter"); - - /** - * Monitor operations in methods whose fully qualified name contains this substring will be - * traced. - */ - private static final String TRACE_METHOD_FILTER = System.getProperty("graal.monitors.trace.methodFilter"); - - public static final boolean CHECK_BALANCED_MONITORS = Boolean.getBoolean("graal.monitors.checkBalanced"); - @Snippet public static void monitorenter(Object object, KlassPointer hub, @ConstantParameter int lockDepth, @ConstantParameter Register threadRegister, @ConstantParameter Register stackPointerRegister, @ConstantParameter boolean trace) { @@ -509,8 +489,10 @@ @NodeIntrinsic(BreakpointNode.class) static native void bkpt(Object object, Word mark, Word tmp, Word value); + private static final boolean VERIFY_BALANCED_MONITORS = VerifyBalancedMonitors.getValue(); + public static void incCounter() { - if (CHECK_BALANCED_MONITORS) { + if (VERIFY_BALANCED_MONITORS) { final Word counter = MonitorCounterNode.counter(); final int count = counter.readInt(0, MONITOR_COUNTER_LOCATION); counter.writeInt(0, count + 1, MONITOR_COUNTER_LOCATION); @@ -518,7 +500,7 @@ } public static void decCounter() { - if (CHECK_BALANCED_MONITORS) { + if (VERIFY_BALANCED_MONITORS) { final Word counter = MonitorCounterNode.counter(); final int count = counter.readInt(0, MONITOR_COUNTER_LOCATION); counter.writeInt(0, count - 1, MONITOR_COUNTER_LOCATION); @@ -596,30 +578,32 @@ public static boolean isTracingEnabledForType(ValueNode object) { ResolvedJavaType type = StampTool.typeOrNull(object.stamp()); - if (TRACE_TYPE_FILTER == null) { + String filter = TraceMonitorsTypeFilter.getValue(); + if (filter == null) { return false; } else { - if (TRACE_TYPE_FILTER.length() == 0) { + if (filter.length() == 0) { return true; } if (type == null) { return false; } - return (type.getName().contains(TRACE_TYPE_FILTER)); + return (type.getName().contains(filter)); } } public static boolean isTracingEnabledForMethod(ResolvedJavaMethod method) { - if (TRACE_METHOD_FILTER == null) { + String filter = TraceMonitorsMethodFilter.getValue(); + if (filter == null) { return false; } else { - if (TRACE_METHOD_FILTER.length() == 0) { + if (filter.length() == 0) { return true; } if (method == null) { return false; } - return (method.format("%H.%n").contains(TRACE_METHOD_FILTER)); + return (method.format("%H.%n").contains(filter)); } } @@ -628,7 +612,7 @@ * return points of the graph to initialize and check the monitor counter respectively. */ private void checkBalancedMonitors(StructuredGraph graph, LoweringTool tool) { - if (CHECK_BALANCED_MONITORS) { + if (VERIFY_BALANCED_MONITORS) { NodeIterable nodes = graph.getNodes().filter(MonitorCounterNode.class); if (nodes.isEmpty()) { // Only insert the nodes if this is the first monitorenter being lowered. diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippets.java Sat Jan 09 01:40:57 2016 +0100 @@ -52,7 +52,6 @@ import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.verifyOop; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.wordSize; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.writeTlabTop; -import static com.oracle.graal.hotspot.replacements.NewObjectSnippetsOptions.ProfileAllocations; import static com.oracle.graal.nodes.PiArrayNode.piArrayCast; import static com.oracle.graal.nodes.PiNode.piCast; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.FAST_PATH_PROBABILITY; @@ -156,7 +155,7 @@ @Fold static boolean doProfile() { - return ProfileAllocations.getValue(); + return HotspotSnippetsOptions.ProfileAllocations.getValue(); } protected static void profileAllocation(String path, long size, String typeContext) { @@ -506,7 +505,7 @@ args.addConst("fillContents", newInstanceNode.fillContents()); args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("constantSize", true); - args.addConst("typeContext", ProfileAllocations.getValue() ? type.toJavaName(false) : ""); + args.addConst("typeContext", HotspotSnippetsOptions.ProfileAllocations.getValue() ? type.toJavaName(false) : ""); SnippetTemplate template = template(args); Debug.log("Lowering allocateInstance in %s: node=%s, template=%s, arguments=%s", graph, newInstanceNode, template, args); @@ -536,7 +535,7 @@ args.addConst("fillContents", newArrayNode.fillContents()); args.addConst("threadRegister", registers.getThreadRegister()); args.addConst("maybeUnroll", length.isConstant()); - args.addConst("typeContext", ProfileAllocations.getValue() ? arrayType.toJavaName(false) : ""); + args.addConst("typeContext", HotspotSnippetsOptions.ProfileAllocations.getValue() ? arrayType.toJavaName(false) : ""); SnippetTemplate template = template(args); Debug.log("Lowering allocateArray in %s: node=%s, template=%s, arguments=%s", graph, newArrayNode, template, args); template.instantiate(providers.getMetaAccess(), newArrayNode, DEFAULT_REPLACER, args); diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippetsOptions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/NewObjectSnippetsOptions.java Sat Jan 09 01:22:31 2016 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot.replacements; - -import com.oracle.graal.options.Option; -import com.oracle.graal.options.OptionType; -import com.oracle.graal.options.OptionValue; - -/** - * Options related to {@link NewObjectSnippets}. - * - * Note: This must be a top level class to work around for Eclipse bug 477597. - */ -class NewObjectSnippetsOptions { - - //@formatter:off - @Option(help = "", type = OptionType.Debug) - static final OptionValue ProfileAllocations = new OptionValue<>(false); - //@formatter:on -} diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java Sat Jan 09 01:40:57 2016 +0100 @@ -134,7 +134,7 @@ @Fold static boolean logging() { - return Boolean.getBoolean("graal.logExceptionHandlerStub"); + return StubOptions.TraceExceptionHandlerStub.getValue(); } /** diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewArrayStub.java Sat Jan 09 01:40:57 2016 +0100 @@ -85,7 +85,7 @@ @Fold static boolean logging() { - return Boolean.getBoolean("graal.logNewArrayStub"); + return StubOptions.TraceNewArrayStub.getValue(); } /** diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Sat Jan 09 01:40:57 2016 +0100 @@ -127,7 +127,7 @@ @Fold static boolean logging() { - return Boolean.getBoolean("graal.logNewInstanceStub"); + return StubOptions.TraceNewInstanceStub.getValue(); } /** @@ -295,7 +295,7 @@ @Fold static boolean forceSlowPath() { - return Boolean.getBoolean("graal.newInstanceStub.forceSlowPath"); + return StubOptions.ForceUseOfNewInstanceStub.getValue(); } public static final ForeignCallDescriptor NEW_INSTANCE_C = newDescriptor(NewInstanceStub.class, "newInstanceC", void.class, Word.class, KlassPointer.class); diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/StubOptions.java Sat Jan 09 01:40:57 2016 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.stubs; + +import com.oracle.graal.options.Option; +import com.oracle.graal.options.OptionType; +import com.oracle.graal.options.OptionValue; + +//JaCoCo Exclude + +/** + * Options related to HotSpot Graal-generated stubs. + * + * Note: This must be a top level class to work around for Eclipse bug 477597. + */ +public class StubOptions { + // @formatter:off + @Option(help = "Trace execution of stub used to handle an exception thrown by a callee.", type = OptionType.Debug) + static final OptionValue TraceExceptionHandlerStub = new OptionValue<>(false); + + @Option(help = "Trace execution of the stub that routes an exception to a handler in the calling frame.", type = OptionType.Debug) + static final OptionValue TraceUnwindStub = new OptionValue<>(false); + + @Option(help = "Trace execution of slow path stub for array allocation.", type = OptionType.Debug) + static final OptionValue TraceNewArrayStub = new OptionValue<>(false); + + @Option(help = "Trace execution of slow path stub for non-array object allocation.", type = OptionType.Debug) + static final OptionValue TraceNewInstanceStub = new OptionValue<>(false); + + @Option(help = "Force non-array object allocation to always use the slow path.", type = OptionType.Debug) + static final OptionValue ForceUseOfNewInstanceStub = new OptionValue<>(false); + //@formatter:on +} diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java Sat Jan 09 01:40:57 2016 +0100 @@ -97,7 +97,7 @@ @Fold static boolean logging() { - return Boolean.getBoolean("graal.logUnwindExceptionToCallerStub"); + return StubOptions.TraceUnwindStub.getValue(); } /** diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.options.test/src/com/oracle/graal/options/test/TestOptionValue.java --- a/graal/com.oracle.graal.options.test/src/com/oracle/graal/options/test/TestOptionValue.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.options.test/src/com/oracle/graal/options/test/TestOptionValue.java Sat Jan 09 01:40:57 2016 +0100 @@ -117,11 +117,11 @@ @Test public void toStringTest() { - assertEquals("com.oracle.graal.options.test.TestOptionValue$Options.Mutable=original", Mutable.toString()); + assertEquals("Mutable=original", Mutable.toString()); try (OverrideScope s1 = OptionValue.override(Mutable, "override1")) { - assertEquals("com.oracle.graal.options.test.TestOptionValue$Options.Mutable=override1", Mutable.toString()); + assertEquals("Mutable=override1", Mutable.toString()); try (OverrideScope s2 = OptionValue.override(Mutable, "override2")) { - assertEquals("com.oracle.graal.options.test.TestOptionValue$Options.Mutable=override2", Mutable.toString()); + assertEquals("Mutable=override2", Mutable.toString()); } } } diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java --- a/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.options/src/com/oracle/graal/options/OptionValue.java Sat Jan 09 01:40:57 2016 +0100 @@ -156,10 +156,16 @@ private OptionValue next; private static OptionValue head; - private static final boolean ShowReadsHistogram = Boolean.getBoolean("graal.showOptionValueReadsHistogram"); + /** + * Name of the boolean system property governing whether to profile the number of times + * {@link #getValue()} is called for each {@link OptionValue}. + */ + public static final String PROFILE_OPTIONVALUE_PROPERTY_NAME = "graal.profileOptionValue"; + + private static final boolean ProfileOptionValue = Boolean.getBoolean(PROFILE_OPTIONVALUE_PROPERTY_NAME); private static void addToHistogram(OptionValue option) { - if (ShowReadsHistogram) { + if (ProfileOptionValue) { synchronized (OptionValue.class) { option.next = head; head = option; @@ -217,7 +223,12 @@ * {@link Object#toString()}. */ public String getName() { - return descriptor == null ? super.toString() : (descriptor.getDeclaringClass().getName() + "." + descriptor.getName()); + if (descriptor == null) { + // Trigger initialization of OptionsLoader to ensure all option values have + // a descriptor which is required for them to have meaningful names. + OptionsLoader.options.hashCode(); + } + return descriptor == null ? super.toString() : descriptor.getName(); } @Override @@ -251,7 +262,7 @@ * Gets the value of this option. */ public T getValue() { - if (ShowReadsHistogram) { + if (ProfileOptionValue) { reads++; } if (!(this instanceof StableOptionValue)) { @@ -452,11 +463,7 @@ } static { - if (ShowReadsHistogram) { - // Trigger initialization of OptionsLoader to ensure all option values have - // a descriptor which is required for them to have meaningful names. - OptionsLoader.options.hashCode(); - + if (ProfileOptionValue) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Sat Jan 09 01:40:57 2016 +0100 @@ -24,6 +24,7 @@ import static com.oracle.graal.compiler.common.GraalOptions.DeoptALot; import static com.oracle.graal.compiler.common.GraalOptions.OptCanonicalizer; +import static com.oracle.graal.compiler.common.GraalOptions.UseSnippetGraphCache; import static com.oracle.graal.java.BytecodeParserOptions.InlineDuringParsing; import static com.oracle.graal.java.BytecodeParserOptions.InlineIntrinsicsDuringParsing; import static com.oracle.graal.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING; @@ -318,7 +319,6 @@ this.snippetTemplateCache = CollectionsFactory.newMap(); } - private static final boolean UseSnippetGraphCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetGraphCache", "true")); private static final DebugTimer SnippetPreparationTime = Debug.timer("SnippetPreparationTime"); /** @@ -348,12 +348,12 @@ assert method.getAnnotation(Snippet.class) != null : "Snippet must be annotated with @" + Snippet.class.getSimpleName(); assert method.hasBytecodes() : "Snippet must not be abstract or native"; - StructuredGraph graph = UseSnippetGraphCache ? graphs.get(method) : null; + StructuredGraph graph = UseSnippetGraphCache.getValue() ? graphs.get(method) : null; if (graph == null) { try (DebugCloseable a = SnippetPreparationTime.start()) { StructuredGraph newGraph = makeGraph(method, args, recursiveEntry); Debug.metric("SnippetNodeCount[%#s]", method).add(newGraph.getNodeCount()); - if (!UseSnippetGraphCache || args != null) { + if (!UseSnippetGraphCache.getValue() || args != null) { return newGraph; } graphs.putIfAbsent(method, newGraph); diff -r c238d6294bc3 -r 92fce0754cc5 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Sat Jan 09 01:22:31 2016 +0100 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Sat Jan 09 01:40:57 2016 +0100 @@ -58,6 +58,7 @@ import jdk.vm.ci.meta.Signature; import com.oracle.graal.api.replacements.SnippetReflectionProvider; +import com.oracle.graal.compiler.common.GraalOptions; import com.oracle.graal.compiler.common.type.Stamp; import com.oracle.graal.compiler.common.type.StampFactory; import com.oracle.graal.debug.Debug; @@ -109,6 +110,8 @@ import com.oracle.graal.nodes.spi.LoweringTool; import com.oracle.graal.nodes.spi.MemoryProxy; import com.oracle.graal.nodes.util.GraphUtil; +import com.oracle.graal.options.Option; +import com.oracle.graal.options.OptionValue; import com.oracle.graal.phases.common.CanonicalizerPhase; import com.oracle.graal.phases.common.DeadCodeEliminationPhase; import com.oracle.graal.phases.common.FloatingReadPhase; @@ -133,7 +136,6 @@ */ public class SnippetTemplate { - private static final boolean EAGER_SNIPPETS = Boolean.getBoolean("graal.snippets.eager"); private boolean mayRemoveLocation = false; /** @@ -527,15 +529,19 @@ private static final DebugTimer SnippetTemplateCreationTime = Debug.timer("SnippetTemplateCreationTime"); private static final DebugMetric SnippetTemplates = Debug.metric("SnippetTemplateCount"); - private static final String MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME = "graal.maxTemplatesPerSnippet"; - private static final int MaxTemplatesPerSnippet = Integer.getInteger(MAX_TEMPLATES_PER_SNIPPET_PROPERTY_NAME, 50); + static class Options { + @Option(help = "Use a LRU cache for snippet templates.")// + static final OptionValue UseSnippetTemplateCache = new OptionValue<>(true); + + @Option(help = "")// + static final OptionValue MaxTemplatesPerSnippet = new OptionValue<>(50); + } /** * Base class for snippet classes. It provides a cache for {@link SnippetTemplate}s. */ public abstract static class AbstractTemplates implements com.oracle.graal.api.replacements.SnippetTemplateCache { - static final boolean UseSnippetTemplateCache = Boolean.parseBoolean(System.getProperty("graal.useSnippetTemplateCache", "true")); protected final Providers providers; protected final SnippetReflectionProvider snippetReflection; protected final TargetDescription target; @@ -545,8 +551,9 @@ this.providers = providers; this.snippetReflection = snippetReflection; this.target = target; - if (UseSnippetTemplateCache) { - this.templates = Collections.synchronizedMap(new LRUCache<>(MaxTemplatesPerSnippet, MaxTemplatesPerSnippet)); + if (Options.UseSnippetTemplateCache.getValue()) { + int size = Options.MaxTemplatesPerSnippet.getValue(); + this.templates = Collections.synchronizedMap(new LRUCache<>(size, size)); } else { this.templates = null; } @@ -574,7 +581,7 @@ assert findMethod(declaringClass, methodName, method) == null : "found more than one method named " + methodName + " in " + declaringClass; ResolvedJavaMethod javaMethod = providers.getMetaAccess().lookupJavaMethod(method); providers.getReplacements().registerSnippet(javaMethod); - if (EAGER_SNIPPETS) { + if (GraalOptions.EagerSnippets.getValue()) { return new EagerSnippetInfo(javaMethod, privateLocations); } else { return new LazySnippetInfo(javaMethod, privateLocations); @@ -586,12 +593,12 @@ */ @SuppressWarnings("try") protected SnippetTemplate template(final Arguments args) { - SnippetTemplate template = UseSnippetTemplateCache && args.cacheable ? templates.get(args.cacheKey) : null; + SnippetTemplate template = Options.UseSnippetTemplateCache.getValue() && args.cacheable ? templates.get(args.cacheKey) : null; if (template == null) { SnippetTemplates.increment(); try (DebugCloseable a = SnippetTemplateCreationTime.start(); Scope s = Debug.scope("SnippetSpecialization", args.info.method)) { template = new SnippetTemplate(providers, snippetReflection, args); - if (UseSnippetTemplateCache && args.cacheable) { + if (Options.UseSnippetTemplateCache.getValue() && args.cacheable) { templates.put(args.cacheKey, template); } } catch (Throwable e) {