1 /*
   2  * Copyright (c) 2009, 2012, 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 com.oracle.graal.phases;
  24 
  25 /**
  26  * This class encapsulates options that control the behavior of the Graal compiler.
  27  * 
  28  * (thomaswue) WARNING: Fields of this class are treated as final by Graal.
  29  */
  30 // @formatter:off
  31 public final class GraalOptions {
  32 
  33     // Checkstyle: stop
  34     private static final boolean ____ = false;
  35     // Checkstyle: resume
  36 
  37     public static int     Threads                            = 4;
  38 
  39     // inlining settings
  40     public static boolean Inline                             = true;
  41     public static boolean AlwaysInlineIntrinsics             = ____;
  42     public static boolean Intrinsify                         = true;
  43            static boolean InlineMonomorphicCalls             = true;
  44            static boolean InlinePolymorphicCalls             = true;
  45            static boolean InlineMegamorphicCalls             = ____;
  46     public static int     MaximumDesiredSize                 = 5000;
  47     public static int     MaximumRecursiveInlining           = 1;
  48     public static boolean LimitInlinedProbability            = ____;
  49     public static boolean LimitInlinedRelevance              = true;
  50     public static float   BoostInliningForEscapeAnalysis     = 2f;
  51     public static float   RelevanceCapForInlining            = 1f;
  52     public static boolean IterativeInlining                  = ____;
  53 
  54     public static int     TrivialBytecodeSize                = 10;
  55     public static int     NormalBytecodeSize                 = 150;
  56     public static int     MaximumBytecodeSize                = 500;
  57     public static int     TrivialComplexity                  = 10;
  58     public static int     NormalComplexity                   = 60;
  59     public static int     MaximumComplexity                  = 400;
  60     public static int     TrivialCompiledCodeSize            = 150;
  61     public static int     NormalCompiledCodeSize             = 750;
  62     public static int     MaximumCompiledCodeSize            = 4000;
  63     public static int     SmallCompiledCodeSize              = 1000;
  64 
  65     // escape analysis settings
  66     public static boolean PartialEscapeAnalysis              = true;
  67     public static boolean EscapeAnalysisHistogram            = ____;
  68     public static int     EscapeAnalysisIterations           = 2;
  69     public static String  EscapeAnalyzeOnly                  = null;
  70     public static int     MaximumEscapeAnalysisArrayLength   = 32;
  71     public static boolean PEAInliningHints                   = ____;
  72 
  73     public static double  TailDuplicationProbability         = 0.5;
  74     public static int     TailDuplicationTrivialSize         = 1;
  75 
  76     // absolute probability analysis
  77     public static boolean ProbabilityAnalysis                = true;
  78 
  79     // profiling information
  80     public static int     DeoptsToDisableOptimisticOptimization = 40;
  81     public static int     MatureExecutionsBranch             = 1;
  82     public static int     MatureExecutionsPerSwitchCase      = 1;
  83     public static int     MatureExecutionsTypeProfile        = 1;
  84 
  85     // comilation queue
  86     public static int     TimedBootstrap                     = -1;
  87     public static boolean PriorityCompileQueue               = true;
  88     public static int     SlowQueueCutoff                    = 100000;
  89     public static boolean SlowCompileThreads                 = ____;
  90     public static boolean DynamicCompilePriority             = ____;
  91 
  92     // graph caching
  93     public static boolean CacheGraphs                        = true;
  94     public static int     GraphCacheSize                     = 1000;
  95     public static boolean PrintGraphCache                    = ____;
  96 
  97     //loop transform settings TODO (gd) tune
  98     public static boolean LoopPeeling                        = true;
  99     public static boolean ReassociateInvariants              = true;
 100     public static boolean FullUnroll                         = true;
 101     public static boolean LoopUnswitch                       = true;
 102     public static int     FullUnrollMaxNodes                 = 300;
 103     public static int     ExactFullUnrollMaxNodes            = 1200;
 104     public static float   MinimumPeelProbability             = 0.35f;
 105     public static int     LoopMaxUnswitch                    = 3;
 106     public static int     LoopUnswitchMaxIncrease            = 50;
 107     public static int     LoopUnswitchUncertaintyBoost       = 5;
 108 
 109     // debugging settings
 110     public static boolean ZapStackOnMethodEntry              = ____;
 111     public static boolean DeoptALot                          = ____;
 112     public static boolean VerifyPhases                       = true;
 113 
 114     public static String  PrintFilter                        = null;
 115 
 116     // Debug settings:
 117     public static boolean Debug                              = true;
 118     public static boolean DebugReplacements                  = ____;
 119     public static boolean BootstrapReplacements              = ____;
 120     public static boolean PerThreadDebugValues               = ____;
 121     public static boolean SummarizeDebugValues               = ____;
 122     public static boolean SummarizePerPhase                  = ____;
 123     public static String  Dump                               = null;
 124     public static String  Meter                              = null;
 125     public static String  Time                               = null;
 126     public static String  Log                                = null;
 127     public static String  LogFile                            = null;
 128     public static String  MethodFilter                       = null;
 129     public static boolean DumpOnError                        = ____;
 130     public static boolean GenericDynamicCounters             = ____;
 131     public static boolean BenchmarkDynamicCounters           = ____;
 132 
 133     // Ideal graph visualizer output settings
 134     public static boolean PrintBinaryGraphs                  = true;
 135     public static boolean PrintCFG                           = ____;
 136     public static boolean PrintIdealGraphFile                = ____;
 137     public static String  PrintIdealGraphAddress             = "127.0.0.1";
 138     public static int     PrintIdealGraphPort                = 4444;
 139     public static int     PrintBinaryGraphPort               = 4445;
 140 
 141     // Other printing settings
 142     public static boolean PrintQueue                         = ____;
 143     public static boolean PrintCompilation                   = ____;
 144     public static boolean PrintProfilingInformation          = ____;
 145     public static boolean PrintIRWithLIR                     = ____;
 146     public static boolean PrintCodeBytes                     = ____;
 147     public static boolean PrintBailout                       = ____;
 148     public static int     TraceLinearScanLevel               = 0;
 149     public static int     TraceLIRGeneratorLevel             = 0;
 150     public static boolean TraceEscapeAnalysis                = ____;
 151     public static int     TraceBytecodeParserLevel           = 0;
 152     public static boolean ExitVMOnBailout                    = ____;
 153     public static boolean ExitVMOnException                  = true;
 154 
 155     // Register allocator debugging
 156     public static String  RegisterPressure                   = null;
 157 
 158     // Code generator settings
 159     public static boolean ConditionalElimination             = true;
 160     public static boolean CullFrameStates                    = ____;
 161     public static boolean UseProfilingInformation            = true;
 162            static boolean RemoveNeverExecutedCode            = true;
 163            static boolean UseExceptionProbability            = true;
 164            static boolean UseExceptionProbabilityForOperations = true;
 165     public static boolean OmitHotExceptionStacktrace         = ____;
 166     public static boolean GenSafepoints                      = true;
 167     public static boolean GenLoopSafepoints                  = true;
 168            static boolean UseTypeCheckHints                  = true;
 169     public static boolean InlineVTableStubs                  = true;
 170     public static boolean AlwaysInlineVTableStubs            = ____;
 171     public static boolean GenAssertionCode                   = ____;
 172     public static boolean AlignCallsForPatching              = true;
 173     public static boolean ResolveClassBeforeStaticInvoke     = ____;
 174     public static boolean CanOmitFrame                       = true;
 175     public static int     SafepointPollOffset                = 256;
 176 
 177     public static boolean MemoryAwareScheduling              = true;
 178 
 179     // Translating tableswitch instructions
 180     public static int     MinimumJumpTableSize               = 5;
 181     public static int     RangeTestsSwitchDensity            = 5;
 182     public static double  MinTableSwitchDensity              = 0.5;
 183 
 184     public static boolean DetailedAsserts                    = ____;
 185 
 186     // Runtime settings
 187     public static int     StackShadowPages                   = 2;
 188 
 189     public static boolean SupportJsrBytecodes                = true;
 190 
 191     public static boolean OptAssumptions                     = true;
 192     public static boolean OptConvertDeoptsToGuards           = true;
 193     public static boolean OptReadElimination                 = true;
 194     public static boolean OptEarlyReadElimination            = true;
 195     public static boolean OptCanonicalizer                   = true;
 196     public static boolean OptScheduleOutOfLoops              = true;
 197     public static boolean OptEliminateGuards                 = true;
 198     public static boolean OptEliminateSafepoints             = true;
 199     public static boolean OptImplicitNullChecks              = true;
 200     public static boolean OptLivenessAnalysis                = true;
 201     public static boolean OptLoopTransform                   = true;
 202     public static boolean OptFloatingReads                   = true;
 203     public static boolean OptTailDuplication                 = true;
 204     public static boolean OptEliminatePartiallyRedundantGuards = true;
 205     public static boolean OptFilterProfiledTypes             = true;
 206     public static boolean OptDevirtualizeInvokesOptimistically = true;
 207     public static boolean OptPushThroughPi                   = true;
 208 
 209 
 210     // Intrinsification settings
 211     public static boolean IntrinsifyObjectClone              = ____;
 212     public static boolean IntrinsifyArrayCopy                = true;
 213     public static boolean IntrinsifyObjectMethods            = true;
 214     public static boolean IntrinsifySystemMethods            = true;
 215     public static boolean IntrinsifyClassMethods             = true;
 216     public static boolean IntrinsifyThreadMethods            = true;
 217     public static boolean IntrinsifyUnsafeMethods            = true;
 218     public static boolean IntrinsifyMathMethods              = true;
 219     public static boolean IntrinsifyAESMethods               = true;
 220     public static boolean IntrinsifyInstalledCodeMethods     = true;
 221     public static boolean IntrinsifyCallSiteTarget           = true;
 222     /**
 223      * Counts the various paths taken through snippets.
 224      */
 225     public static boolean SnippetCounters = false;
 226 
 227     /**
 228      * If the probability that a checkcast will hit one the profiled types (up to {@link #CheckcastMaxHints})
 229      * is below this value, the checkcast will be compiled without hints.
 230      */
 231     public static double CheckcastMinHintHitProbability = 0.5;
 232 
 233     /**
 234      * The maximum number of hint types that will be used when compiling a checkcast for which
 235      * profiling information is available. Note that {@link #CheckcastMinHintHitProbability}
 236      * also influences whether hints are used.
 237      */
 238     public static int CheckcastMaxHints = 2;
 239 
 240     /**
 241      * @see #CheckcastMinHintHitProbability
 242      */
 243     public static double InstanceOfMinHintHitProbability = 0.5;
 244 
 245     /**
 246      * @see #CheckcastMaxHints
 247      */
 248     public static int InstanceOfMaxHints = 2;
 249 
 250     static {
 251         // turn detailed assertions on when the general assertions are on (misusing the assert keyword for this)
 252         assert (DetailedAsserts = true) == true;
 253     }
 254 }