001/*
002 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.compiler.common;
024
025import jdk.internal.jvmci.options.*;
026
027/**
028 * This class encapsulates options that control the behavior of the Graal compiler.
029 */
030// @formatter:off
031public final class GraalOptions {
032
033    @Option(help = "Use compiler intrinsifications.", type = OptionType.Debug)
034    public static final OptionValue<Boolean> Intrinsify = new OptionValue<>(true);
035
036    @Option(help = "Inline calls with monomorphic type profile.", type = OptionType.Expert)
037    public static final OptionValue<Boolean> InlineMonomorphicCalls = new OptionValue<>(true);
038
039    @Option(help = "Inline calls with polymorphic type profile.", type = OptionType.Expert)
040    public static final OptionValue<Boolean> InlinePolymorphicCalls = new OptionValue<>(true);
041
042    @Option(help = "Inline calls with megamorphic type profile (i.e., not all types could be recorded).", type = OptionType.Expert)
043    public static final OptionValue<Boolean> InlineMegamorphicCalls = new OptionValue<>(true);
044
045    @Option(help = "Maximum desired size of the compiler graph in nodes.", type = OptionType.User)
046    public static final OptionValue<Integer> MaximumDesiredSize = new OptionValue<>(20000);
047
048    @Option(help = "Minimum probability for methods to be inlined for megamorphic type profiles.", type = OptionType.Expert)
049    public static final OptionValue<Double> MegamorphicInliningMinMethodProbability = new OptionValue<>(0.33D);
050
051    @Option(help = "Maximum level of recursive inlining.", type = OptionType.Expert)
052    public static final OptionValue<Integer> MaximumRecursiveInlining = new OptionValue<>(5);
053
054    @Option(help = "Graphs with less than this number of nodes are trivial and therefore always inlined.", type = OptionType.Expert)
055    public static final OptionValue<Integer> TrivialInliningSize = new OptionValue<>(10);
056
057    @Option(help = "Inlining is explored up to this number of nodes in the graph for each call site.", type = OptionType.Expert)
058    public static final OptionValue<Integer> MaximumInliningSize = new OptionValue<>(300);
059
060    @Option(help = "If the previous low-level graph size of the method exceeds the threshold, it is not inlined.", type = OptionType.Expert)
061    public static final OptionValue<Integer> SmallCompiledLowLevelGraphSize = new OptionValue<>(300);
062
063    @Option(help = "", type = OptionType.Expert)
064    public static final OptionValue<Double> LimitInlinedInvokes = new OptionValue<>(5.0);
065
066    @Option(help = "", type = OptionType.Expert)
067    public static final OptionValue<Boolean> InlineEverything = new OptionValue<>(false);
068
069    // escape analysis settings
070    @Option(help = "", type = OptionType.Debug)
071    public static final OptionValue<Boolean> PartialEscapeAnalysis = new OptionValue<>(true);
072
073    @Option(help = "", type = OptionType.Debug)
074    public static final OptionValue<Integer> EscapeAnalysisIterations = new OptionValue<>(2);
075
076    @Option(help = "", type = OptionType.Debug)
077    public static final OptionValue<String> EscapeAnalyzeOnly = new OptionValue<>(null);
078
079    @Option(help = "", type = OptionType.Expert)
080    public static final OptionValue<Integer> MaximumEscapeAnalysisArrayLength = new OptionValue<>(32);
081
082    @Option(help = "", type = OptionType.Debug)
083    public static final OptionValue<Boolean> PEAInliningHints = new OptionValue<>(false);
084
085    @Option(help = "", type = OptionType.Expert)
086    public static final OptionValue<Double> TailDuplicationProbability = new OptionValue<>(0.5);
087
088    @Option(help = "", type = OptionType.Expert)
089    public static final OptionValue<Integer> TailDuplicationTrivialSize = new OptionValue<>(1);
090
091    @Option(help = "", type = OptionType.Expert)
092    public static final OptionValue<Integer> DeoptsToDisableOptimisticOptimization = new OptionValue<>(40);
093
094    @Option(help = "", type = OptionType.Debug)
095    public static final OptionValue<Boolean> LoopPeeling = new OptionValue<>(true);
096
097    @Option(help = "", type = OptionType.Debug)
098    public static final OptionValue<Boolean> ReassociateInvariants = new OptionValue<>(true);
099
100    @Option(help = "", type = OptionType.Debug)
101    public static final OptionValue<Boolean> FullUnroll = new OptionValue<>(true);
102
103    @Option(help = "", type = OptionType.Debug)
104    public static final OptionValue<Boolean> LoopUnswitch = new OptionValue<>(true);
105
106    @Option(help = "", type = OptionType.Expert)
107    public static final OptionValue<Float> MinimumPeelProbability = new OptionValue<>(0.35f);
108
109    @Option(help = "", type = OptionType.Expert)
110    public static final OptionValue<Integer> LoopMaxUnswitch = new OptionValue<>(3);
111
112    @Option(help = "", type = OptionType.Debug)
113    public static final OptionValue<Boolean> UseLoopLimitChecks = new OptionValue<>(true);
114
115    // debugging settings
116    @Option(help = "", type = OptionType.Debug)
117    public static final OptionValue<Boolean> ZapStackOnMethodEntry = new OptionValue<>(false);
118
119    @Option(help = "", type = OptionType.Debug)
120    public static final OptionValue<Boolean> DeoptALot = new OptionValue<>(false);
121
122    @Option(help = "Stressed the code emitting explicit exception throwing code.", type = OptionType.Debug)
123    public static final StableOptionValue<Boolean> StressExplicitExceptionCode = new StableOptionValue<>(false);
124
125    @Option(help = "Stressed the code emitting explicit exception throwing code.", type = OptionType.Debug)
126    public static final StableOptionValue<Boolean> StressInvokeWithExceptionNode = new StableOptionValue<>(false);
127
128    @Option(help = "", type = OptionType.Debug)
129    public static final OptionValue<Boolean> VerifyPhases = new OptionValue<>(false);
130
131    // Debug settings:
132    @Option(help = "", type = OptionType.Debug)
133    public static final OptionValue<Boolean> BootstrapReplacements = new OptionValue<>(false);
134
135    @Option(help = "", type = OptionType.Debug)
136    public static final OptionValue<Integer> GCDebugStartCycle = new OptionValue<>(-1);
137
138    @Option(help = "Perform platform dependent validation of the Java heap at returns", type = OptionType.Debug)
139    public static final OptionValue<Boolean> VerifyHeapAtReturn = new OptionValue<>(false);
140
141    // Ideal graph visualizer output settings
142    @Option(help = "Dump IdealGraphVisualizer output in binary format", type = OptionType.Debug)
143    public static final OptionValue<Boolean> PrintBinaryGraphs = new OptionValue<>(true);
144
145    @Option(help = "Output probabilities for fixed nodes during binary graph dumping", type = OptionType.Debug)
146    public static final OptionValue<Boolean> PrintGraphProbabilities = new OptionValue<>(false);
147
148    @Option(help = "Enable dumping to the C1Visualizer. Enabling this option implies PrintBackendCFG.", type = OptionType.Debug)
149    public static final OptionValue<Boolean> PrintCFG = new OptionValue<>(false);
150
151    @Option(help = "Enable dumping LIR, register allocation and code generation info to the C1Visualizer.", type = OptionType.Debug)
152    public static final OptionValue<Boolean> PrintBackendCFG = new OptionValue<>(true);
153
154    @Option(help = "Enable dumping to the IdealGraphVisualizer.", type = OptionType.Debug)
155    public static final OptionValue<Boolean> PrintIdealGraph = new OptionValue<>(true);
156
157    @Option(help = "", type = OptionType.Debug)
158    public static final OptionValue<Boolean> PrintIdealGraphFile = new OptionValue<>(false);
159
160    @Option(help = "", type = OptionType.Debug)
161    public static final OptionValue<String> PrintIdealGraphAddress = new OptionValue<>("127.0.0.1");
162
163    @Option(help = "", type = OptionType.Debug)
164    public static final OptionValue<Integer> PrintIdealGraphPort = new OptionValue<>(4444);
165
166    @Option(help = "", type = OptionType.Debug)
167    public static final OptionValue<Integer> PrintBinaryGraphPort = new OptionValue<>(4445);
168
169    @Option(help = "", type = OptionType.Debug)
170    public static final OptionValue<Boolean> PrintIdealGraphSchedule = new OptionValue<>(false);
171
172    // Other printing settings
173    @Option(help = "Print profiling information when parsing a method's bytecode", type = OptionType.Debug)
174    public static final OptionValue<Boolean> PrintProfilingInformation = new OptionValue<>(false);
175
176    @Option(help = "", type = OptionType.Debug)
177    public static final OptionValue<Boolean> PrintCodeBytes = new OptionValue<>(false);
178
179
180    @Option(help = "", type = OptionType.Debug)
181    public static final StableOptionValue<Boolean> TraceEscapeAnalysis = new StableOptionValue<>(false);
182
183    // HotSpot command line options
184    @Option(help = "Print inlining optimizations", type = OptionType.Debug)
185    public static final OptionValue<Boolean> HotSpotPrintInlining = new OptionValue<>(false);
186
187    // Register allocator debugging
188    @Option(help = "Comma separated list of registers that register allocation is limited to.", type = OptionType.Debug)
189    public static final OptionValue<String> RegisterPressure = new OptionValue<>(null);
190
191    @Option(help = "", type = OptionType.Debug)
192    public static final OptionValue<Boolean> ConditionalElimination = new OptionValue<>(true);
193
194    @Option(help = "", type = OptionType.Debug)
195    public static final OptionValue<Boolean> RemoveNeverExecutedCode = new OptionValue<>(true);
196
197    @Option(help = "", type = OptionType.Debug)
198    public static final OptionValue<Boolean> UseExceptionProbability = new OptionValue<>(true);
199
200    @Option(help = "", type = OptionType.Debug)
201    public static final OptionValue<Boolean> UseExceptionProbabilityForOperations = new OptionValue<>(true);
202
203    @Option(help = "", type = OptionType.Debug)
204    public static final OptionValue<Boolean> OmitHotExceptionStacktrace = new OptionValue<>(false);
205
206    @Option(help = "", type = OptionType.Debug)
207    public static final OptionValue<Boolean> GenSafepoints = new OptionValue<>(true);
208
209    @Option(help = "", type = OptionType.Debug)
210    public static final OptionValue<Boolean> GenLoopSafepoints = new OptionValue<>(true);
211
212    @Option(help = "", type = OptionType.Debug)
213    public static final OptionValue<Boolean> UseTypeCheckHints = new OptionValue<>(true);
214
215    @Option(help = "", type = OptionType.Expert)
216    public static final OptionValue<Boolean> InlineVTableStubs = new OptionValue<>(true);
217
218    @Option(help = "", type = OptionType.Expert)
219    public static final OptionValue<Boolean> AlwaysInlineVTableStubs = new OptionValue<>(false);
220
221    @Option(help = "", type = OptionType.Debug)
222    public static final OptionValue<Boolean> ResolveClassBeforeStaticInvoke = new OptionValue<>(false);
223
224    @Option(help = "", type = OptionType.Debug)
225    public static final OptionValue<Boolean> CanOmitFrame = new OptionValue<>(true);
226
227    // Ahead of time compilation
228    @Option(help = "Try to avoid emitting code where patching is required", type = OptionType.Expert)
229    public static final OptionValue<Boolean> ImmutableCode = new OptionValue<>(false);
230
231    @Option(help = "Generate position independent code", type = OptionType.Expert)
232    public static final OptionValue<Boolean> GeneratePIC = new OptionValue<>(false);
233
234    @Option(help = "", type = OptionType.Expert)
235    public static final OptionValue<Boolean> CallArrayCopy = new OptionValue<>(true);
236
237    // Runtime settings
238    @Option(help = "", type = OptionType.Expert)
239    public static final OptionValue<Boolean> SupportJsrBytecodes = new OptionValue<>(true);
240
241    @Option(help = "", type = OptionType.Expert)
242    public static final OptionValue<Boolean> OptAssumptions = new OptionValue<>(true);
243
244    @Option(help = "", type = OptionType.Debug)
245    public static final OptionValue<Boolean> OptConvertDeoptsToGuards = new OptionValue<>(true);
246
247    @Option(help = "", type = OptionType.Debug)
248    public static final OptionValue<Boolean> OptReadElimination = new OptionValue<>(true);
249
250    @Option(help = "", type = OptionType.Debug)
251    public static final OptionValue<Boolean> OptCanonicalizer = new OptionValue<>(true);
252
253    @Option(help = "", type = OptionType.Debug)
254    public static final OptionValue<Boolean> OptDeoptimizationGrouping = new OptionValue<>(true);
255
256    @Option(help = "", type = OptionType.Debug)
257    public static final OptionValue<Boolean> OptScheduleOutOfLoops = new OptionValue<>(true);
258
259    @Option(help = "", type = OptionType.Debug)
260    public static final OptionValue<Boolean> OptEliminateGuards = new OptionValue<>(true);
261
262    @Option(help = "", type = OptionType.Debug)
263    public static final OptionValue<Boolean> OptImplicitNullChecks = new OptionValue<>(true);
264
265    @Option(help = "", type = OptionType.Debug)
266    public static final OptionValue<Boolean> OptClearNonLiveLocals = new OptionValue<>(true);
267
268    @Option(help = "", type = OptionType.Debug)
269    public static final OptionValue<Boolean> OptLoopTransform = new OptionValue<>(true);
270
271    @Option(help = "", type = OptionType.Debug)
272    public static final OptionValue<Boolean> OptFloatingReads = new OptionValue<>(true);
273
274    @Option(help = "", type = OptionType.Debug)
275    public static final OptionValue<Boolean> OptEliminatePartiallyRedundantGuards = new OptionValue<>(true);
276
277    @Option(help = "", type = OptionType.Debug)
278    public static final OptionValue<Boolean> OptFilterProfiledTypes = new OptionValue<>(true);
279
280    @Option(help = "", type = OptionType.Debug)
281    public static final OptionValue<Boolean> OptDevirtualizeInvokesOptimistically = new OptionValue<>(true);
282
283    @Option(help = "", type = OptionType.Debug)
284    public static final OptionValue<Boolean> OptPushThroughPi = new OptionValue<>(true);
285
286    @Option(help = "Allow backend to match complex expressions.", type = OptionType.Debug)
287    public static final OptionValue<Boolean> MatchExpressions = new OptionValue<>(true);
288
289    @Option(help = "Generate SSA LIR.", type = OptionType.Debug)
290    public static final OptionValue<Boolean> SSA_LIR = new OptionValue<>(true);
291
292    /**
293     * Counts the various paths taken through snippets.
294     */
295    @Option(help = "", type = OptionType.Debug)
296    public static final OptionValue<Boolean> SnippetCounters = new OptionValue<>(false);
297
298    @Option(help = "Enable expensive assertions", type = OptionType.Debug)
299    public static final OptionValue<Boolean> DetailedAsserts = new StableOptionValue<Boolean>() {
300        @Override
301        protected Boolean defaultValue() {
302            boolean enabled = false;
303            // turn detailed assertions on when the general assertions are on (misusing the assert keyword for this)
304            assert (enabled = true) == true;
305            return enabled;
306        }
307    };
308}