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