1 /*
   2  * Copyright (c) 2009, 2019, 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 
  24 
  25 package org.graalvm.compiler.core.common;
  26 
  27 import org.graalvm.compiler.options.Option;
  28 import org.graalvm.compiler.options.OptionKey;
  29 import org.graalvm.compiler.options.OptionStability;
  30 import org.graalvm.compiler.options.OptionType;
  31 
  32 /**
  33  * This class encapsulates options that control the behavior of the GraalVM compiler.
  34  */
  35 // @formatter:off
  36 public final class GraalOptions {
  37 
  38     @Option(help = "Use compiler intrinsifications.", type = OptionType.Debug)
  39     public static final OptionKey<Boolean> Intrinsify = new OptionKey<>(true);
  40 
  41     @Option(help = "Inline calls with monomorphic type profile.", type = OptionType.Expert)
  42     public static final OptionKey<Boolean> InlineMonomorphicCalls = new OptionKey<>(true);
  43 
  44     @Option(help = "Inline calls with polymorphic type profile.", type = OptionType.Expert)
  45     public static final OptionKey<Boolean> InlinePolymorphicCalls = new OptionKey<>(true);
  46 
  47     @Option(help = "Inline calls with megamorphic type profile (i.e., not all types could be recorded).", type = OptionType.Expert)
  48     public static final OptionKey<Boolean> InlineMegamorphicCalls = new OptionKey<>(true);
  49 
  50     @Option(help = "Maximum desired size of the compiler graph in nodes.", type = OptionType.User)
  51     public static final OptionKey<Integer> MaximumDesiredSize = new OptionKey<>(20000);
  52 
  53     @Option(help = "Minimum probability for methods to be inlined for megamorphic type profiles.", type = OptionType.Expert)
  54     public static final OptionKey<Double> MegamorphicInliningMinMethodProbability = new OptionKey<>(0.33D);
  55 
  56     @Option(help = "Maximum level of recursive inlining.", type = OptionType.Expert)
  57     public static final OptionKey<Integer> MaximumRecursiveInlining = new OptionKey<>(5);
  58 
  59     @Option(help = "Graphs with less than this number of nodes are trivial and therefore always inlined.", type = OptionType.Expert)
  60     public static final OptionKey<Integer> TrivialInliningSize = new OptionKey<>(10);
  61 
  62     @Option(help = "Inlining is explored up to this number of nodes in the graph for each call site.", type = OptionType.Expert)
  63     public static final OptionKey<Integer> MaximumInliningSize = new OptionKey<>(300);
  64 
  65     @Option(help = "If the previous low-level graph size of the method exceeds the threshold, it is not inlined.", type = OptionType.Expert)
  66     public static final OptionKey<Integer> SmallCompiledLowLevelGraphSize = new OptionKey<>(300);
  67 
  68     @Option(help = "", type = OptionType.Expert)
  69     public static final OptionKey<Double> LimitInlinedInvokes = new OptionKey<>(5.0);
  70 
  71     @Option(help = "", type = OptionType.Expert)
  72     public static final OptionKey<Boolean> InlineEverything = new OptionKey<>(false);
  73 
  74     // escape analysis settings
  75     @Option(help = "", type = OptionType.Debug)
  76     public static final OptionKey<Boolean> PartialEscapeAnalysis = new OptionKey<>(true);
  77 
  78     @Option(help = "", type = OptionType.Debug)
  79     public static final OptionKey<Integer> EscapeAnalysisIterations = new OptionKey<>(2);
  80 
  81     @Option(help = "", type = OptionType.Debug)
  82     public static final OptionKey<Integer> EscapeAnalysisLoopCutoff = new OptionKey<>(20);
  83 
  84     @Option(help = "", type = OptionType.Debug)
  85     public static final OptionKey<String> EscapeAnalyzeOnly = new OptionKey<>(null);
  86 
  87     @Option(help = "The maximum length of an array that will be escape analyzed.", type = OptionType.Expert)
  88     public static final OptionKey<Integer> MaximumEscapeAnalysisArrayLength = new OptionKey<>(128);
  89 
  90     @Option(help = "", type = OptionType.Debug)
  91     public static final OptionKey<Boolean> PEAInliningHints = new OptionKey<>(false);
  92 
  93     @Option(help = "", type = OptionType.Expert)
  94     public static final OptionKey<Double> TailDuplicationProbability = new OptionKey<>(0.5);
  95 
  96     @Option(help = "", type = OptionType.Expert)
  97     public static final OptionKey<Integer> TailDuplicationTrivialSize = new OptionKey<>(1);
  98 
  99     @Option(help = "", type = OptionType.Expert)
 100     public static final OptionKey<Integer> DeoptsToDisableOptimisticOptimization = new OptionKey<>(40);
 101 
 102     @Option(help = "", type = OptionType.Debug)
 103     public static final OptionKey<Boolean> LoopPeeling = new OptionKey<>(true);
 104 
 105     @Option(help = "", type = OptionType.Debug)
 106     public static final OptionKey<Boolean> ReassociateInvariants = new OptionKey<>(true);
 107 
 108     @Option(help = "", type = OptionType.Debug)
 109     public static final OptionKey<Boolean> FullUnroll = new OptionKey<>(true);
 110 
 111     @Option(help = "", type = OptionType.Debug)
 112     public static final OptionKey<Boolean> LoopUnswitch = new OptionKey<>(true);
 113 
 114     @Option(help = "", type = OptionType.Debug)
 115     public static final OptionKey<Boolean> PartialUnroll = new OptionKey<>(true);
 116 
 117     @Option(help = "", type = OptionType.Expert)
 118     public static final OptionKey<Float> MinimumPeelProbability = new OptionKey<>(0.35f);
 119 
 120     @Option(help = "", type = OptionType.Expert)
 121     public static final OptionKey<Integer> LoopMaxUnswitch = new OptionKey<>(3);
 122 
 123     @Option(help = "", type = OptionType.Debug)
 124     public static final OptionKey<Boolean> UseLoopLimitChecks = new OptionKey<>(true);
 125 
 126     // debugging settings
 127     @Option(help = "", type = OptionType.Debug)
 128     public static final OptionKey<Boolean> ZapStackOnMethodEntry = new OptionKey<>(false);
 129 
 130     @Option(help = "", type = OptionType.Debug)
 131     public static final OptionKey<Boolean> DeoptALot = new OptionKey<>(false);
 132 
 133     @Option(help = "Stress the code emitting explicit exception throwing code.", type = OptionType.Debug)
 134     public static final OptionKey<Boolean> StressExplicitExceptionCode = new OptionKey<>(false);
 135 
 136     @Option(help = "Stress the code emitting invokes with explicit exception edges.", type = OptionType.Debug)
 137     public static final OptionKey<Boolean> StressInvokeWithExceptionNode = new OptionKey<>(false);
 138 
 139     @Option(help = "Stress the code by emitting reads at earliest instead of latest point.", type = OptionType.Debug)
 140     public static final OptionKey<Boolean> StressTestEarlyReads = new OptionKey<>(false);
 141 
 142     @Option(help = "", type = OptionType.Debug)
 143     public static final OptionKey<Boolean> VerifyPhases = new OptionKey<>(false);
 144 
 145     // Debug settings:
 146     @Option(help = "Start tracing compiled GC barriers after N garbage collections (disabled if N <= 0).", type = OptionType.Debug)
 147     public static final OptionKey<Integer> GCDebugStartCycle = new OptionKey<>(-1);
 148 
 149     @Option(help = "Perform platform dependent validation of the Java heap at returns", type = OptionType.Debug)
 150     public static final OptionKey<Boolean> VerifyHeapAtReturn = new OptionKey<>(false);
 151 
 152     // Other printing settings
 153     @Option(help = "Print profiling information when parsing a method's bytecode", type = OptionType.Debug)
 154     public static final OptionKey<Boolean> PrintProfilingInformation = new OptionKey<>(false);
 155 
 156     @Option(help = "", type = OptionType.Debug)
 157     public static final OptionKey<Boolean> TraceEscapeAnalysis = new OptionKey<>(false);
 158 
 159     // HotSpot command line options
 160     @Option(help = "Print inlining optimizations", type = OptionType.Debug)
 161     public static final OptionKey<Boolean> HotSpotPrintInlining = new OptionKey<>(false);
 162 
 163     // Register allocator debugging
 164     @Option(help = "Comma separated list of registers that register allocation is limited to.", type = OptionType.Debug)
 165     public static final OptionKey<String> RegisterPressure = new OptionKey<>(null);
 166 
 167     @Option(help = "", type = OptionType.Debug)
 168     public static final OptionKey<Boolean> ConditionalElimination = new OptionKey<>(true);
 169 
 170     @Option(help = "", type = OptionType.Debug)
 171     public static final OptionKey<Integer> ConditionalEliminationMaxIterations = new OptionKey<>(4);
 172 
 173     @Option(help = "", type = OptionType.Debug)
 174     public static final OptionKey<Boolean> RawConditionalElimination = new OptionKey<>(true);
 175 
 176     @Option(help = "", type = OptionType.Debug)
 177     public static final OptionKey<Boolean> ReplaceInputsWithConstantsBasedOnStamps = new OptionKey<>(true);
 178 
 179     @Option(help = "", type = OptionType.Debug)
 180     public static final OptionKey<Boolean> RemoveNeverExecutedCode = new OptionKey<>(true);
 181 
 182     @Option(help = "", type = OptionType.Debug)
 183     public static final OptionKey<Boolean> UseExceptionProbability = new OptionKey<>(true);
 184 
 185     @Option(help = "", type = OptionType.Debug)
 186     public static final OptionKey<Boolean> OmitHotExceptionStacktrace = new OptionKey<>(false);
 187 
 188     @Option(help = "", type = OptionType.Debug)
 189     public static final OptionKey<Boolean> GenSafepoints = new OptionKey<>(true);
 190 
 191     @Option(help = "", type = OptionType.Debug)
 192     public static final OptionKey<Boolean> GenLoopSafepoints = new OptionKey<>(true);
 193 
 194     @Option(help = "", type = OptionType.Debug)
 195     public static final OptionKey<Boolean> UseTypeCheckHints = new OptionKey<>(true);
 196 
 197     @Option(help = "", type = OptionType.Expert)
 198     public static final OptionKey<Boolean> InlineVTableStubs = new OptionKey<>(true);
 199 
 200     @Option(help = "", type = OptionType.Expert)
 201     public static final OptionKey<Boolean> AlwaysInlineVTableStubs = new OptionKey<>(false);
 202 
 203     @Option(help = "", type = OptionType.Debug)
 204     public static final OptionKey<Boolean> CanOmitFrame = new OptionKey<>(true);
 205 
 206     // Ahead of time compilation
 207     @Option(help = "Try to avoid emitting code where patching is required", type = OptionType.Expert)
 208     public static final OptionKey<Boolean> ImmutableCode = new OptionKey<>(false);
 209 
 210     @Option(help = "Generate position independent code", type = OptionType.Expert)
 211     public static final OptionKey<Boolean> GeneratePIC = new OptionKey<>(false);
 212 
 213     // Runtime settings
 214     @Option(help = "", type = OptionType.Expert)
 215     public static final OptionKey<Boolean> SupportJsrBytecodes = new OptionKey<>(true);
 216 
 217     @Option(help = "", type = OptionType.Expert)
 218     public static final OptionKey<Boolean> OptAssumptions = new OptionKey<>(true);
 219 
 220     @Option(help = "", type = OptionType.Debug)
 221     public static final OptionKey<Boolean> OptConvertDeoptsToGuards = new OptionKey<>(true);
 222 
 223     @Option(help = "", type = OptionType.Debug)
 224     public static final OptionKey<Boolean> OptReadElimination = new OptionKey<>(true);
 225 
 226     @Option(help = "", type = OptionType.Debug)
 227     public static final OptionKey<Integer> ReadEliminationMaxLoopVisits = new OptionKey<>(5);
 228 
 229     @Option(help = "", type = OptionType.Debug)
 230     public static final OptionKey<Boolean> OptDeoptimizationGrouping = new OptionKey<>(true);
 231 
 232     @Option(help = "", type = OptionType.Debug)
 233     public static final OptionKey<Boolean> OptScheduleOutOfLoops = new OptionKey<>(true);
 234 
 235     @Option(help = "", type = OptionType.Debug)
 236     public static final OptionKey<Boolean> GuardPriorities = new OptionKey<>(true);
 237 
 238     @Option(help = "", type = OptionType.Debug)
 239     public static final OptionKey<Boolean> OptEliminateGuards = new OptionKey<>(true);
 240 
 241     @Option(help = "", type = OptionType.Debug)
 242     public static final OptionKey<Boolean> OptImplicitNullChecks = new OptionKey<>(true);
 243 
 244     @Option(help = "", type = OptionType.Debug)
 245     public static final OptionKey<Boolean> OptLoopTransform = new OptionKey<>(true);
 246 
 247     @Option(help = "", type = OptionType.Debug)
 248     public static final OptionKey<Boolean> OptFloatingReads = new OptionKey<>(true);
 249 
 250     @Option(help = "", type = OptionType.Debug)
 251     public static final OptionKey<Boolean> OptEliminatePartiallyRedundantGuards = new OptionKey<>(true);
 252 
 253     @Option(help = "", type = OptionType.Debug)
 254     public static final OptionKey<Boolean> OptFilterProfiledTypes = new OptionKey<>(true);
 255 
 256     @Option(help = "", type = OptionType.Debug)
 257     public static final OptionKey<Boolean> OptDevirtualizeInvokesOptimistically = new OptionKey<>(true);
 258 
 259     @Option(help = "Track the NodeSourcePosition.", type = OptionType.Debug)
 260     public static final OptionKey<Boolean> TrackNodeSourcePosition = new OptionKey<>(false);
 261 
 262     @Option(help = "Track source stack trace where a node was inserted into the graph.", type = OptionType.Debug)
 263     public static final OptionKey<Boolean> TrackNodeInsertion = new OptionKey<>(false);
 264 
 265     @Option(help = "Allow backend to match complex expressions.", type = OptionType.Debug)
 266     public static final OptionKey<Boolean> MatchExpressions = new OptionKey<>(true);
 267 
 268     @Option(help = "Enable counters for various paths in snippets.", type = OptionType.Debug)
 269     public static final OptionKey<Boolean> SnippetCounters = new OptionKey<>(false);
 270 
 271     @Option(help = "Eagerly construct extra snippet info.", type = OptionType.Debug)
 272     public static final OptionKey<Boolean> EagerSnippets = new OptionKey<>(false);
 273 
 274     @Option(help = "Use a cache for snippet graphs.", type = OptionType.Debug)
 275     public static final OptionKey<Boolean> UseSnippetGraphCache = new OptionKey<>(true);
 276 
 277     @Option(help = "file:doc-files/TraceInliningHelp.txt", type = OptionType.Debug, stability = OptionStability.STABLE)
 278     public static final OptionKey<Boolean> TraceInlining = new OptionKey<>(false);
 279 
 280     @Option(help = "Enable inlining decision tracing in stubs and snippets.", type = OptionType.Debug)
 281     public static final OptionKey<Boolean> TraceInliningForStubsAndSnippets = new OptionKey<>(false);
 282 
 283     @Option(help = "Use Graal-generated stubs for complicated LIR operations instead of embedding all the emitted code.", type = OptionType.Expert)
 284     public static final OptionKey<Boolean> UseGraalStubs = new OptionKey<>(true);
 285 
 286     @Option(help = "Encode and decode snippets and substitutions before parsing to test libgraal code path. This option is ignored in the context of libgraal.")
 287     public static final OptionKey<Boolean> UseEncodedGraphs = new OptionKey<>(false);
 288 
 289     @Option(help = "If applicable, use bulk zeroing instructions when the zeroing size in bytes exceeds this threshold.", type = OptionType.Expert)
 290     public static final OptionKey<Integer> MinimalBulkZeroingSize = new OptionKey<>(2048);
 291 
 292     @Option(help = "Alignment in bytes for loop header blocks.", type = OptionType.Expert)
 293     public static final OptionKey<Integer> LoopHeaderAlignment = new OptionKey<>(16);
 294 }