1 /*
   2  * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_PPC_GLOBALS_PPC_HPP
  27 #define CPU_PPC_GLOBALS_PPC_HPP
  28 
  29 #include "utilities/globalDefinitions.hpp"
  30 #include "utilities/macros.hpp"
  31 
  32 // Sets the default values for platform dependent flags used by the runtime system.
  33 // (see globals.hpp)
  34 
  35 define_pd_global(bool, ImplicitNullChecks,    true);  // Generate code for implicit null checks.
  36 define_pd_global(bool, TrapBasedNullChecks,   true);
  37 define_pd_global(bool, UncommonNullCast,      true);  // Uncommon-trap NULLs passed to check cast.
  38 
  39 #define DEFAULT_STACK_YELLOW_PAGES (2)
  40 #define DEFAULT_STACK_RED_PAGES (1)
  41 // Java_java_net_SocketOutputStream_socketWrite0() uses a 64k buffer on the
  42 // stack if compiled for unix and LP64. To pass stack overflow tests we need
  43 // 20 shadow pages.
  44 #define DEFAULT_STACK_SHADOW_PAGES (20 DEBUG_ONLY(+2))
  45 #define DEFAULT_STACK_RESERVED_PAGES (1)
  46 
  47 #define MIN_STACK_YELLOW_PAGES DEFAULT_STACK_YELLOW_PAGES
  48 #define MIN_STACK_RED_PAGES DEFAULT_STACK_RED_PAGES
  49 #define MIN_STACK_SHADOW_PAGES (3 DEBUG_ONLY(+1))
  50 #define MIN_STACK_RESERVED_PAGES (0)
  51 
  52 define_pd_global(intx, StackYellowPages,      DEFAULT_STACK_YELLOW_PAGES);
  53 define_pd_global(intx, StackRedPages,         DEFAULT_STACK_RED_PAGES);
  54 define_pd_global(intx, StackShadowPages,      DEFAULT_STACK_SHADOW_PAGES);
  55 define_pd_global(intx, StackReservedPages,    DEFAULT_STACK_RESERVED_PAGES);
  56 
  57 // Use large code-entry alignment.
  58 define_pd_global(uintx, CodeCacheSegmentSize,  128);
  59 define_pd_global(intx,  CodeEntryAlignment,    128);
  60 define_pd_global(intx,  OptoLoopAlignment,     16);
  61 define_pd_global(intx,  InlineFrequencyCount,  100);
  62 define_pd_global(intx,  InlineSmallCode,       1500);
  63 
  64 // Flags for template interpreter.
  65 define_pd_global(bool, RewriteBytecodes,      true);
  66 define_pd_global(bool, RewriteFrequentPairs,  true);
  67 
  68 define_pd_global(bool, PreserveFramePointer,  false);
  69 
  70 define_pd_global(uintx, TypeProfileLevel, 111);
  71 
  72 define_pd_global(bool, CompactStrings, true);
  73 
  74 // 2x unrolled loop is shorter with more than 9 HeapWords.
  75 define_pd_global(intx, InitArrayShortSize, 9*BytesPerLong);
  76 
  77 // Platform dependent flag handling: flags only defined on this platform.
  78 #include "runtime/flags/jvmFlag.hpp"
  79 PRODUCT_FLAG(uintx,    PowerArchitecturePPC64, 0, JVMFlag::DEFAULT,
  80                        "CPU Version: x for PowerX. Currently recognizes Power5 to "
  81                        "Power8. Default is 0. Newer CPUs will be recognized as Power8.");
  82 
  83 PRODUCT_FLAG(bool,     SuperwordUseVSX, false, JVMFlag::DEFAULT,
  84                        "Use Power8 VSX instructions for superword optimization.");
  85 
  86 
  87     //  Reoptimize code-sequences of calls at runtime, e.g. replace an 
  88     //  indirect call by a direct call.                                
  89 PRODUCT_FLAG(bool,     ReoptimizeCallSequences, true, JVMFlag::DEFAULT,
  90                        "Reoptimize code-sequences of calls at runtime.");
  91 
  92 
  93     //  Power 8: Configure Data Stream Control Register. 
  94 PRODUCT_FLAG(uint64_t, DSCR_PPC64, (uintx)-1, JVMFlag::DEFAULT,
  95                        "Power8 or later: Specify encoded value for Data Stream Control "
  96                        "Register");
  97 
  98 PRODUCT_FLAG(uint64_t, DSCR_DPFD_PPC64, 8, JVMFlag::DEFAULT,
  99                        "Power8 or later: DPFD (default prefetch depth) value of the "
 100                        "Data Stream Control Register."
 101                        " 0: hardware default, 1: none, 2-7: min-max, 8: don't touch");
 102 
 103 PRODUCT_FLAG(uint64_t, DSCR_URG_PPC64, 8, JVMFlag::DEFAULT,
 104                        "Power8 or later: URG (depth attainment urgency) value of the "
 105                        "Data Stream Control Register."
 106                        " 0: hardware default, 1: none, 2-7: min-max, 8: don't touch");
 107 
 108 PRODUCT_FLAG(bool,     UseLoadInstructionsForStackBangingPPC64, false, JVMFlag::DEFAULT,
 109                        "Use load instructions for stack banging.");
 110 
 111 
 112     //  special instructions 
 113 PRODUCT_FLAG(bool,     UseCountLeadingZerosInstructionsPPC64, true, JVMFlag::DEFAULT,
 114                        "Use count leading zeros instructions.");
 115 
 116 PRODUCT_FLAG(bool,     UseCountTrailingZerosInstructionsPPC64, false, JVMFlag::DEFAULT,
 117                        "Use count trailing zeros instructions.");
 118 
 119 PRODUCT_FLAG(bool,     UseExtendedLoadAndReserveInstructionsPPC64, false, JVMFlag::DEFAULT,
 120                        "Use extended versions of load-and-reserve instructions.");
 121 
 122 PRODUCT_FLAG(bool,     UseRotateAndMaskInstructionsPPC64, true, JVMFlag::DEFAULT,
 123                        "Use rotate and mask instructions.");
 124 
 125 PRODUCT_FLAG(bool,     UseStaticBranchPredictionInCompareAndSwapPPC64, true, JVMFlag::DEFAULT,
 126                        "Use static branch prediction hints in CAS operations.");
 127 
 128 PRODUCT_FLAG(bool,     UseStaticBranchPredictionForUncommonPathsPPC64, false, JVMFlag::DEFAULT,
 129                        "Use static branch prediction hints for uncommon paths.");
 130 
 131 PRODUCT_FLAG(bool,     UsePower6SchedulerPPC64, false, JVMFlag::DEFAULT,
 132                        "Use Power6 Scheduler.");
 133 
 134 PRODUCT_FLAG(bool,     InsertEndGroupPPC64, false, JVMFlag::DEFAULT,
 135                        "Insert EndGroup instructions to optimize for Power6.");
 136 
 137 
 138     //  Trap based checks. 
 139     //  Trap based checks use the ppc trap instructions to check certain 
 140     //  conditions. This instruction raises a SIGTRAP caught by the      
 141     //  exception handler of the VM.                                     
 142 PRODUCT_FLAG(bool,     UseSIGTRAP, true, JVMFlag::DEFAULT,
 143                        "Allow trap instructions that make use of SIGTRAP. Use this to "
 144                        "switch off all optimizations requiring SIGTRAP.");
 145 
 146 PRODUCT_FLAG(bool,     TrapBasedICMissChecks, true, JVMFlag::DEFAULT,
 147                        "Raise and handle SIGTRAP if inline cache miss detected.");
 148 
 149 PRODUCT_FLAG(bool,     TrapBasedNotEntrantChecks, true, JVMFlag::DEFAULT,
 150                        "Raise and handle SIGTRAP if calling not entrant or zombie"
 151                        " method.");
 152 
 153 PRODUCT_FLAG(bool,     TraceTraps, false, JVMFlag::DEFAULT,
 154                        "Trace all traps the signal handler"
 155                        "handles.");
 156 
 157 PRODUCT_FLAG(bool,     ZapMemory, false, JVMFlag::DEFAULT,
 158                        "Write 0x0101... to empty memory."
 159                        " Use this to ease debugging.");
 160 
 161 
 162     //  Use Restricted Transactional Memory for lock elision 
 163 PRODUCT_FLAG(bool,     UseRTMLocking, false, JVMFlag::DEFAULT,
 164                        "Enable RTM lock eliding for inflated locks in compiled code");
 165 
 166 PRODUCT_FLAG(bool,     UseRTMForStackLocks, false, JVMFlag::EXPERIMENTAL,
 167                        "Enable RTM lock eliding for stack locks in compiled code");
 168 
 169 PRODUCT_FLAG(bool,     UseRTMDeopt, false, JVMFlag::DEFAULT,
 170                        "Perform deopt and recompilation based on RTM abort ratio");
 171 
 172 PRODUCT_FLAG(int,      RTMRetryCount, 5, JVMFlag::RANGE,
 173                        "Number of RTM retries on lock abort or busy");
 174    FLAG_RANGE(         RTMRetryCount, 0, max_jint);
 175 
 176 PRODUCT_FLAG(int,      RTMSpinLoopCount, 100, JVMFlag::EXPERIMENTAL | JVMFlag::RANGE,
 177                        "Spin count for lock to become free before RTM retry");
 178    FLAG_RANGE(         RTMSpinLoopCount, 0, 32767);
 179 
 180 PRODUCT_FLAG(int,      RTMAbortThreshold, 1000, JVMFlag::EXPERIMENTAL | JVMFlag::RANGE,
 181                        "Calculate abort ratio after this number of aborts");
 182    FLAG_RANGE(         RTMAbortThreshold, 0, max_jint);
 183 
 184 PRODUCT_FLAG(int,      RTMLockingThreshold, 10000, JVMFlag::EXPERIMENTAL | JVMFlag::RANGE,
 185                        "Lock count at which to do RTM lock eliding without "
 186                        "abort ratio calculation");
 187    FLAG_RANGE(         RTMLockingThreshold, 0, max_jint);
 188 
 189 PRODUCT_FLAG(int,      RTMAbortRatio, 50, JVMFlag::EXPERIMENTAL | JVMFlag::RANGE,
 190                        "Lock abort ratio at which to stop use RTM lock eliding");
 191    FLAG_RANGE(         RTMAbortRatio, 0, 100);
 192 
 193 PRODUCT_FLAG(int,      RTMTotalCountIncrRate, 64, JVMFlag::EXPERIMENTAL | JVMFlag::RANGE | JVMFlag::CONSTRAINT,
 194                        "Increment total RTM attempted lock count once every n times");
 195    FLAG_RANGE(         RTMTotalCountIncrRate, 1, 32767);
 196    FLAG_CONSTRAINT(    RTMTotalCountIncrRate, (void*)RTMTotalCountIncrRateConstraintFunc, JVMFlag::AfterErgo);
 197 
 198 PRODUCT_FLAG(intx,     RTMLockingCalculationDelay, 0, JVMFlag::EXPERIMENTAL,
 199                        "Number of milliseconds to wait before start calculating aborts "
 200                        "for RTM locking");
 201 
 202 PRODUCT_FLAG(bool,     UseRTMXendForLockBusy, true, JVMFlag::EXPERIMENTAL,
 203                        "Use RTM Xend instead of Xabort when lock busy");
 204 #endif // CPU_PPC_GLOBALS_PPC_HPP