1 /*
   2  * Copyright (c) 2000, 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 #ifndef SHARE_JVMCI_JVMCI_GLOBALS_HPP
  26 #define SHARE_JVMCI_JVMCI_GLOBALS_HPP
  27 
  28 #include "utilities/ostream.hpp"
  29 
  30 //
  31 // Defines all global flags used by the JVMCI compiler. Only flags that need
  32 // to be accessible to the JVMCI C++ code should be defined here.
  33 //
  34 #define JVMCI_FLAGS(develop, \
  35                     develop_pd, \
  36                     product, \
  37                     product_pd, \
  38                     diagnostic, \
  39                     diagnostic_pd, \
  40                     experimental, \
  41                     notproduct, \
  42                     range, \
  43                     constraint, \
  44                     writeable) \
  45                                                                             \
  46   experimental(bool, EnableJVMCI, false,                                    \
  47           "Enable JVMCI")                                                   \
  48                                                                             \
  49   experimental(bool, UseJVMCICompiler, false,                               \
  50           "Use JVMCI as the default compiler")                              \
  51                                                                             \
  52   experimental(bool, JVMCIPrintProperties, false,                           \
  53           "Prints properties used by the JVMCI compiler and exits")         \
  54                                                                             \
  55   experimental(bool, BootstrapJVMCI, false,                                 \
  56           "Bootstrap JVMCI before running Java main method")                \
  57                                                                             \
  58   experimental(bool, EagerJVMCI, false,                                     \
  59           "Force eager JVMCI initialization")                               \
  60                                                                             \
  61   experimental(bool, PrintBootstrap, true,                                  \
  62           "Print JVMCI bootstrap progress and summary")                     \
  63                                                                             \
  64   experimental(intx, JVMCIThreads, 1,                                       \
  65           "Force number of JVMCI compiler threads to use. Ignored if "      \
  66           "UseJVMCICompiler is false.")                                     \
  67           range(1, max_jint)                                                \
  68                                                                             \
  69   experimental(intx, JVMCIHostThreads, 1,                                   \
  70           "Force number of C1 compiler threads. Ignored if "                \
  71           "UseJVMCICompiler is false.")                                     \
  72           range(1, max_jint)                                                \
  73                                                                             \
  74   NOT_COMPILER2(product(intx, MaxVectorSize, 64,                            \
  75           "Max vector size in bytes, "                                      \
  76           "actual size could be less depending on elements type"))          \
  77                                                                             \
  78   NOT_COMPILER2(product(bool, ReduceInitialCardMarks, true,                 \
  79           "Defer write barriers of young objects"))                         \
  80                                                                             \
  81   experimental(intx, JVMCITraceLevel, 0,                                    \
  82           "Trace level for JVMCI: "                                         \
  83           "1 means emit a message for each CompilerToVM call,"              \
  84           "levels greater than 1 provide progressively greater detail")     \
  85                                                                             \
  86   experimental(intx, JVMCICounterSize, 0,                                   \
  87           "Reserved size for benchmark counters")                           \
  88           range(0, max_jint)                                                \
  89                                                                             \
  90   experimental(bool, JVMCICountersExcludeCompiler, true,                    \
  91           "Exclude JVMCI compiler threads from benchmark counters")         \
  92                                                                             \
  93   develop(bool, JVMCIUseFastLocking, true,                                  \
  94           "Use fast inlined locking code")                                  \
  95                                                                             \
  96   experimental(intx, JVMCINMethodSizeLimit, (80*K)*wordSize,                \
  97           "Maximum size of a compiled method.")                             \
  98                                                                             \
  99   experimental(intx, MethodProfileWidth, 0,                                 \
 100           "Number of methods to record in call profile")                    \
 101                                                                             \
 102   experimental(ccstr, JVMCILibPath, NULL,                                   \
 103           "LD path for loading the JVMCI shared library")                   \
 104                                                                             \
 105   experimental(ccstr, JVMCILibDumpJNIConfig, NULL,                          \
 106           "Dumps to the given file a description of the classes, fields "   \
 107           "and methods the JVMCI shared library must provide")              \
 108                                                                             \
 109   experimental(bool, UseJVMCINativeLibrary, false,                          \
 110           "Execute JVMCI Java code from a shared library "                  \
 111           "instead of loading it from class files and executing it "        \
 112           "on the HotSpot heap")                                            \
 113                                                                             \
 114   NOT_COMPILER2(diagnostic(bool, UseMultiplyToLenIntrinsic, false,          \
 115           "Enables intrinsification of BigInteger.multiplyToLen()"))        \
 116                                                                             \
 117   NOT_COMPILER2(diagnostic(bool, UseSquareToLenIntrinsic, false,            \
 118           "Enables intrinsification of BigInteger.squareToLen()"))          \
 119                                                                             \
 120   NOT_COMPILER2(diagnostic(bool, UseMulAddIntrinsic, false,                 \
 121           "Enables intrinsification of BigInteger.mulAdd()"))               \
 122                                                                             \
 123   NOT_COMPILER2(diagnostic(bool, UseMontgomeryMultiplyIntrinsic, false,     \
 124           "Enables intrinsification of BigInteger.montgomeryMultiply()"))   \
 125                                                                             \
 126   NOT_COMPILER2(diagnostic(bool, UseMontgomerySquareIntrinsic, false,       \
 127           "Enables intrinsification of BigInteger.montgomerySquare()"))
 128 
 129 
 130 // Read default values for JVMCI globals
 131 
 132 JVMCI_FLAGS(DECLARE_DEVELOPER_FLAG, \
 133             DECLARE_PD_DEVELOPER_FLAG, \
 134             DECLARE_PRODUCT_FLAG, \
 135             DECLARE_PD_PRODUCT_FLAG, \
 136             DECLARE_DIAGNOSTIC_FLAG, \
 137             DECLARE_PD_DIAGNOSTIC_FLAG, \
 138             DECLARE_EXPERIMENTAL_FLAG, \
 139             DECLARE_NOTPRODUCT_FLAG, \
 140             IGNORE_RANGE, \
 141             IGNORE_CONSTRAINT, \
 142             IGNORE_WRITEABLE)
 143 
 144 // The base name for the shared library containing the JVMCI based compiler
 145 #define JVMCI_SHARED_LIBRARY_NAME "jvmcicompiler"
 146 
 147 class JVMCIGlobals {
 148  private:
 149   static fileStream* _jni_config_file;
 150  public:
 151 
 152   // Returns true if jvmci flags are consistent. If not consistent,
 153   // an error message describing the inconsistency is printed before
 154   // returning false.
 155   static bool check_jvmci_flags_are_consistent();
 156 
 157   // Check and exit VM with error if selected GC is not supported by JVMCI.
 158   static void check_jvmci_supported_gc();
 159 
 160   static fileStream* get_jni_config_file() { return _jni_config_file; }
 161 };
 162 #endif // SHARE_JVMCI_JVMCI_GLOBALS_HPP