1 /*
   2  * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.core.common;
  24 
  25 import org.graalvm.compiler.debug.Assertions;
  26 import org.graalvm.compiler.options.Option;
  27 import org.graalvm.compiler.options.OptionKey;
  28 import org.graalvm.compiler.options.OptionType;
  29 
  30 /**
  31  * This class encapsulates options that control the behavior of the Graal compiler.
  32  */
  33 // @formatter:off
  34 public final class GraalOptions {
  35 
  36     @Option(help = "Use compiler intrinsifications.", type = OptionType.Debug)
  37     public static final OptionKey<Boolean> Intrinsify = new OptionKey<>(true);
  38 
  39     @Option(help = "Inline calls with monomorphic type profile.", type = OptionType.Expert)
  40     public static final OptionKey<Boolean> InlineMonomorphicCalls = new OptionKey<>(true);
  41 
  42     @Option(help = "Inline calls with polymorphic type profile.", type = OptionType.Expert)
  43     public static final OptionKey<Boolean> InlinePolymorphicCalls = new OptionKey<>(true);
  44 
  45     @Option(help = "Inline calls with megamorphic type profile (i.e., not all types could be recorded).", type = OptionType.Expert)
  46     public static final OptionKey<Boolean> InlineMegamorphicCalls = new OptionKey<>(true);
  47 
  48     @Option(help = "Maximum desired size of the compiler graph in nodes.", type = OptionType.User)
  49     public static final OptionKey<Integer> MaximumDesiredSize = new OptionKey<>(20000);
  50 
  51     @Option(help = "Minimum probability for methods to be inlined for megamorphic type profiles.", type = OptionType.Expert)
  52     public static final OptionKey<Double> MegamorphicInliningMinMethodProbability = new OptionKey<>(0.33D);
  53 
  54     @Option(help = "Maximum level of recursive inlining.", type = OptionType.Expert)
  55     public static final OptionKey<Integer> MaximumRecursiveInlining = new OptionKey<>(5);
  56 
  57     @Option(help = "Graphs with less than this number of nodes are trivial and therefore always inlined.", type = OptionType.Expert)
  58     public static final OptionKey<Integer> TrivialInliningSize = new OptionKey<>(10);
  59 
  60     @Option(help = "Inlining is explored up to this number of nodes in the graph for each call site.", type = OptionType.Expert)
  61     public static final OptionKey<Integer> MaximumInliningSize = new OptionKey<>(300);
  62 
  63     @Option(help = "If the previous low-level graph size of the method exceeds the threshold, it is not inlined.", type = OptionType.Expert)
  64     public static final OptionKey<Integer> SmallCompiledLowLevelGraphSize = new OptionKey<>(300);
  65 
  66     @Option(help = "", type = OptionType.Expert)
  67     public static final OptionKey<Double> LimitInlinedInvokes = new OptionKey<>(5.0);
  68 
  69     @Option(help = "", type = OptionType.Expert)
  70     public static final OptionKey<Boolean> InlineEverything = new OptionKey<>(false);
  71 
  72     // escape analysis settings
  73     @Option(help = "", type = OptionType.Debug)
  74     public static final OptionKey<Boolean> PartialEscapeAnalysis = new OptionKey<>(true);
  75 
  76     @Option(help = "", type = OptionType.Debug)
  77     public static final OptionKey<Integer> EscapeAnalysisIterations = new OptionKey<>(2);
  78 
  79     @Option(help = "", type = OptionType.Debug)
  80     public static final OptionKey<Integer> EscapeAnalysisLoopCutoff = new OptionKey<>(20);
  81 
  82     @Option(help = "", type = OptionType.Debug)
  83     public static final OptionKey<String> EscapeAnalyzeOnly = new OptionKey<>(null);
  84 
  85     @Option(help = "", type = OptionType.Expert)
  86     public static final OptionKey<Integer> MaximumEscapeAnalysisArrayLength = new OptionKey<>(32);
  87 
  88     @Option(help = "", type = OptionType.Debug)
  89     public static final OptionKey<Boolean> PEAInliningHints = new OptionKey<>(false);
  90 
  91     @Option(help = "", type = OptionType.Expert)
  92     public static final OptionKey<Double> TailDuplicationProbability = new OptionKey<>(0.5);
  93 
  94     @Option(help = "", type = OptionType.Expert)
  95     public static final OptionKey<Integer> TailDuplicationTrivialSize = new OptionKey<>(1);
  96 
  97     @Option(help = "", type = OptionType.Expert)
  98     public static final OptionKey<Integer> DeoptsToDisableOptimisticOptimization = new OptionKey<>(40);
  99 
 100     @Option(help = "", type = OptionType.Debug)
 101     public static final OptionKey<Boolean> LoopPeeling = new OptionKey<>(true);
 102 
 103     @Option(help = "", type = OptionType.Debug)
 104     public static final OptionKey<Boolean> ReassociateInvariants = new OptionKey<>(true);
 105 
 106     @Option(help = "", type = OptionType.Debug)
 107     public static final OptionKey<Boolean> FullUnroll = new OptionKey<>(true);
 108 
 109     @Option(help = "", type = OptionType.Debug)
 110     public static final OptionKey<Boolean> LoopUnswitch = new OptionKey<>(true);
 111 
 112     @Option(help = "", type = OptionType.Debug)
 113     public static final OptionKey<Boolean> PartialUnroll = new OptionKey<>(true);
 114 
 115     @Option(help = "", type = OptionType.Expert)
 116     public static final OptionKey<Float> MinimumPeelProbability = new OptionKey<>(0.35f);
 117 
 118     @Option(help = "", type = OptionType.Expert)
 119     public static final OptionKey<Integer> LoopMaxUnswitch = new OptionKey<>(3);
 120 
 121     @Option(help = "", type = OptionType.Debug)
 122     public static final OptionKey<Boolean> UseLoopLimitChecks = new OptionKey<>(true);
 123 
 124     // debugging settings
 125     @Option(help = "", type = OptionType.Debug)
 126     public static final OptionKey<Boolean> ZapStackOnMethodEntry = new OptionKey<>(false);
 127 
 128     @Option(help = "", type = OptionType.Debug)
 129     public static final OptionKey<Boolean> DeoptALot = new OptionKey<>(false);
 130 
 131     @Option(help = "Stress the code emitting explicit exception throwing code.", type = OptionType.Debug)
 132     public static final OptionKey<Boolean> StressExplicitExceptionCode = new OptionKey<>(false);
 133 
 134     @Option(help = "Stress the code emitting invokes with explicit exception edges.", type = OptionType.Debug)
 135     public static final OptionKey<Boolean> StressInvokeWithExceptionNode = new OptionKey<>(false);
 136 
 137     @Option(help = "Stress the code by emitting reads at earliest instead of latest point.", type = OptionType.Debug)
 138     public static final OptionKey<Boolean> StressTestEarlyReads = new OptionKey<>(false);
 139 
 140     @Option(help = "", type = OptionType.Debug)
 141     public static final OptionKey<Boolean> VerifyPhases = new OptionKey<>(false);
 142 
 143     // Debug settings:
 144     @Option(help = "", type = OptionType.Debug)
 145     public static final OptionKey<Integer> GCDebugStartCycle = new OptionKey<>(-1);
 146 
 147     @Option(help = "Perform platform dependent validation of the Java heap at returns", type = OptionType.Debug)
 148     public static final OptionKey<Boolean> VerifyHeapAtReturn = new OptionKey<>(false);
 149 
 150     // Other printing settings
 151     @Option(help = "Print profiling information when parsing a method's bytecode", type = OptionType.Debug)
 152     public static final OptionKey<Boolean> PrintProfilingInformation = new OptionKey<>(false);
 153 
 154     @Option(help = "", type = OptionType.Debug)
 155     public static final OptionKey<Boolean> TraceEscapeAnalysis = new OptionKey<>(false);
 156 
 157     // HotSpot command line options
 158     @Option(help = "Print inlining optimizations", type = OptionType.Debug)
 159     public static final OptionKey<Boolean> HotSpotPrintInlining = new OptionKey<>(false);
 160 
 161     // Register allocator debugging
 162     @Option(help = "Comma separated list of registers that register allocation is limited to.", type = OptionType.Debug)
 163     public static final OptionKey<String> RegisterPressure = new OptionKey<>(null);
 164 
 165     @Option(help = "", type = OptionType.Debug)
 166     public static final OptionKey<Boolean> ConditionalElimination = new OptionKey<>(true);
 167 
 168     @Option(help = "", type = OptionType.Debug)
 169     public static final OptionKey<Boolean> RawConditionalElimination = new OptionKey<>(true);
 170 
 171     @Option(help = "", type = OptionType.Debug)
 172     public static final OptionKey<Boolean> ReplaceInputsWithConstantsBasedOnStamps = new OptionKey<>(true);
 173 
 174     @Option(help = "", type = OptionType.Debug)
 175     public static final OptionKey<Boolean> RemoveNeverExecutedCode = new OptionKey<>(true);
 176 
 177     @Option(help = "", type = OptionType.Debug)
 178     public static final OptionKey<Boolean> UseExceptionProbability = new OptionKey<>(true);
 179 
 180     @Option(help = "", type = OptionType.Debug)
 181     public static final OptionKey<Boolean> OmitHotExceptionStacktrace = new OptionKey<>(false);
 182 
 183     @Option(help = "", type = OptionType.Debug)
 184     public static final OptionKey<Boolean> GenSafepoints = new OptionKey<>(true);
 185 
 186     @Option(help = "", type = OptionType.Debug)
 187     public static final OptionKey<Boolean> GenLoopSafepoints = new OptionKey<>(true);
 188 
 189     @Option(help = "", type = OptionType.Debug)
 190     public static final OptionKey<Boolean> UseTypeCheckHints = new OptionKey<>(true);
 191 
 192     @Option(help = "", type = OptionType.Expert)
 193     public static final OptionKey<Boolean> InlineVTableStubs = new OptionKey<>(true);
 194 
 195     @Option(help = "", type = OptionType.Expert)
 196     public static final OptionKey<Boolean> AlwaysInlineVTableStubs = new OptionKey<>(false);
 197 
 198     @Option(help = "", type = OptionType.Debug)
 199     public static final OptionKey<Boolean> ResolveClassBeforeStaticInvoke = new OptionKey<>(false);
 200 
 201     @Option(help = "", type = OptionType.Debug)
 202     public static final OptionKey<Boolean> CanOmitFrame = new OptionKey<>(true);
 203 
 204     // Ahead of time compilation
 205     @Option(help = "Try to avoid emitting code where patching is required", type = OptionType.Expert)
 206     public static final OptionKey<Boolean> ImmutableCode = new OptionKey<>(false);
 207 
 208     @Option(help = "Generate position independent code", type = OptionType.Expert)
 209     public static final OptionKey<Boolean> GeneratePIC = new OptionKey<>(false);
 210 
 211     @Option(help = "", type = OptionType.Expert)
 212     public static final OptionKey<Boolean> CallArrayCopy = new OptionKey<>(true);
 213 
 214     // Runtime settings
 215     @Option(help = "", type = OptionType.Expert)
 216     public static final OptionKey<Boolean> SupportJsrBytecodes = new OptionKey<>(true);
 217 
 218     @Option(help = "", type = OptionType.Expert)
 219     public static final OptionKey<Boolean> OptAssumptions = new OptionKey<>(true);
 220 
 221     @Option(help = "", type = OptionType.Debug)
 222     public static final OptionKey<Boolean> OptConvertDeoptsToGuards = new OptionKey<>(true);
 223 
 224     @Option(help = "", type = OptionType.Debug)
 225     public static final OptionKey<Boolean> OptReadElimination = new OptionKey<>(true);
 226 
 227     @Option(help = "", type = OptionType.Debug)
 228     public static final OptionKey<Integer> ReadEliminationMaxLoopVisits = new OptionKey<>(5);
 229 
 230     @Option(help = "", type = OptionType.Debug)
 231     public static final OptionKey<Boolean> OptDeoptimizationGrouping = new OptionKey<>(true);
 232 
 233     @Option(help = "", type = OptionType.Debug)
 234     public static final OptionKey<Boolean> OptScheduleOutOfLoops = new OptionKey<>(true);
 235 
 236     @Option(help = "", type = OptionType.Debug)
 237     public static final OptionKey<Boolean> OptEliminateGuards = new OptionKey<>(true);
 238 
 239     @Option(help = "", type = OptionType.Debug)
 240     public static final OptionKey<Boolean> OptImplicitNullChecks = new OptionKey<>(true);
 241 
 242     @Option(help = "", type = OptionType.Debug)
 243     public static final OptionKey<Boolean> OptClearNonLiveLocals = new OptionKey<>(true);
 244 
 245     @Option(help = "", type = OptionType.Debug)
 246     public static final OptionKey<Boolean> OptLoopTransform = new OptionKey<>(true);
 247 
 248     @Option(help = "", type = OptionType.Debug)
 249     public static final OptionKey<Boolean> OptFloatingReads = new OptionKey<>(true);
 250 
 251     @Option(help = "", type = OptionType.Debug)
 252     public static final OptionKey<Boolean> OptEliminatePartiallyRedundantGuards = new OptionKey<>(true);
 253 
 254     @Option(help = "", type = OptionType.Debug)
 255     public static final OptionKey<Boolean> OptFilterProfiledTypes = new OptionKey<>(true);
 256 
 257     @Option(help = "", type = OptionType.Debug)
 258     public static final OptionKey<Boolean> OptDevirtualizeInvokesOptimistically = new OptionKey<>(true);
 259 
 260     @Option(help = "Allow backend to match complex expressions.", type = OptionType.Debug)
 261     public static final OptionKey<Boolean> MatchExpressions = new OptionKey<>(true);
 262 
 263     @Option(help = "Enable counters for various paths in snippets.", type = OptionType.Debug)
 264     public static final OptionKey<Boolean> SnippetCounters = new OptionKey<>(false);
 265 
 266     @Option(help = "Eagerly construct extra snippet info.", type = OptionType.Debug)
 267     public static final OptionKey<Boolean> EagerSnippets = new OptionKey<>(false);
 268 
 269     @Option(help = "Use a cache for snippet graphs.", type = OptionType.Debug)
 270     public static final OptionKey<Boolean> UseSnippetGraphCache = new OptionKey<>(true);
 271 
 272     @Option(help = "Enable expensive assertions.", type = OptionType.Debug)
 273     public static final OptionKey<Boolean> DetailedAsserts = new OptionKey<>(Assertions.ENABLED);
 274 
 275     @Option(help = "Enable experimental Trace Register Allocation.", type = OptionType.Debug)
 276     public static final OptionKey<Boolean> TraceRA = new OptionKey<>(false);
 277 
 278 }