src/hotspot/share/runtime/abstract_vm_version.cpp
changeset 59122 5d73255c2d52
equal deleted inserted replaced
59121:7cbffba2156b 59122:5d73255c2d52
       
     1 /*
       
     2  * Copyright (c) 1998, 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 #include "precompiled.hpp"
       
    26 #include "compiler/compilerDefinitions.hpp"
       
    27 #include "runtime/arguments.hpp"
       
    28 #include "runtime/vm_version.hpp"
       
    29 #include "utilities/globalDefinitions.hpp"
       
    30 
       
    31 const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release();
       
    32 const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string();
       
    33 
       
    34 uint64_t Abstract_VM_Version::_features = 0;
       
    35 const char* Abstract_VM_Version::_features_string = "";
       
    36 
       
    37 bool Abstract_VM_Version::_supports_cx8 = false;
       
    38 bool Abstract_VM_Version::_supports_atomic_getset4 = false;
       
    39 bool Abstract_VM_Version::_supports_atomic_getset8 = false;
       
    40 bool Abstract_VM_Version::_supports_atomic_getadd4 = false;
       
    41 bool Abstract_VM_Version::_supports_atomic_getadd8 = false;
       
    42 unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
       
    43 unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
       
    44 unsigned int Abstract_VM_Version::_data_cache_line_flush_size = 0;
       
    45 
       
    46 VirtualizationType Abstract_VM_Version::_detected_virtualization = NoDetectedVirtualization;
       
    47 
       
    48 #ifndef HOTSPOT_VERSION_STRING
       
    49   #error HOTSPOT_VERSION_STRING must be defined
       
    50 #endif
       
    51 
       
    52 #ifndef VERSION_FEATURE
       
    53   #error VERSION_FEATURE must be defined
       
    54 #endif
       
    55 #ifndef VERSION_INTERIM
       
    56   #error VERSION_INTERIM must be defined
       
    57 #endif
       
    58 #ifndef VERSION_UPDATE
       
    59   #error VERSION_UPDATE must be defined
       
    60 #endif
       
    61 #ifndef VERSION_PATCH
       
    62   #error VERSION_PATCH must be defined
       
    63 #endif
       
    64 #ifndef VERSION_BUILD
       
    65   #error VERSION_BUILD must be defined
       
    66 #endif
       
    67 
       
    68 #ifndef VERSION_STRING
       
    69   #error VERSION_STRING must be defined
       
    70 #endif
       
    71 
       
    72 #ifndef DEBUG_LEVEL
       
    73   #error DEBUG_LEVEL must be defined
       
    74 #endif
       
    75 
       
    76 #define VM_RELEASE HOTSPOT_VERSION_STRING
       
    77 
       
    78 // HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden
       
    79 // in a standalone build).
       
    80 int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE;
       
    81 int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM;
       
    82 int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE;
       
    83 int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;
       
    84 int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;
       
    85 
       
    86 #if defined(_LP64)
       
    87   #define VMLP "64-Bit "
       
    88 #else
       
    89   #define VMLP ""
       
    90 #endif
       
    91 
       
    92 #ifndef VMTYPE
       
    93   #ifdef TIERED
       
    94     #define VMTYPE "Server"
       
    95   #else // TIERED
       
    96   #ifdef ZERO
       
    97     #define VMTYPE "Zero"
       
    98   #else // ZERO
       
    99      #define VMTYPE COMPILER1_PRESENT("Client")   \
       
   100                     COMPILER2_PRESENT("Server")
       
   101   #endif // ZERO
       
   102   #endif // TIERED
       
   103 #endif
       
   104 
       
   105 #ifndef HOTSPOT_VM_DISTRO
       
   106   #error HOTSPOT_VM_DISTRO must be defined
       
   107 #endif
       
   108 #define VMNAME HOTSPOT_VM_DISTRO " " VMLP VMTYPE " VM"
       
   109 
       
   110 const char* Abstract_VM_Version::vm_name() {
       
   111   return VMNAME;
       
   112 }
       
   113 
       
   114 
       
   115 const char* Abstract_VM_Version::vm_vendor() {
       
   116 #ifdef VENDOR
       
   117   return VENDOR;
       
   118 #else
       
   119   return "Oracle Corporation";
       
   120 #endif
       
   121 }
       
   122 
       
   123 
       
   124 const char* Abstract_VM_Version::vm_info_string() {
       
   125   switch (Arguments::mode()) {
       
   126     case Arguments::_int:
       
   127       return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode";
       
   128     case Arguments::_mixed:
       
   129       if (UseSharedSpaces) {
       
   130         if (UseAOT) {
       
   131           return "mixed mode, aot, sharing";
       
   132 #ifdef TIERED
       
   133         } else if(is_client_compilation_mode_vm()) {
       
   134           return "mixed mode, emulated-client, sharing";
       
   135 #endif
       
   136         } else {
       
   137           return "mixed mode, sharing";
       
   138          }
       
   139       } else {
       
   140         if (UseAOT) {
       
   141           return "mixed mode, aot";
       
   142 #ifdef TIERED
       
   143         } else if(is_client_compilation_mode_vm()) {
       
   144           return "mixed mode, emulated-client";
       
   145 #endif
       
   146         } else {
       
   147           return "mixed mode";
       
   148         }
       
   149       }
       
   150     case Arguments::_comp:
       
   151 #ifdef TIERED
       
   152       if (is_client_compilation_mode_vm()) {
       
   153          return UseSharedSpaces ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client";
       
   154       }
       
   155 #endif
       
   156       return UseSharedSpaces ? "compiled mode, sharing"    : "compiled mode";
       
   157   };
       
   158   ShouldNotReachHere();
       
   159   return "";
       
   160 }
       
   161 
       
   162 // NOTE: do *not* use stringStream. this function is called by
       
   163 //       fatal error handler. if the crash is in native thread,
       
   164 //       stringStream cannot get resource allocated and will SEGV.
       
   165 const char* Abstract_VM_Version::vm_release() {
       
   166   return VM_RELEASE;
       
   167 }
       
   168 
       
   169 // NOTE: do *not* use stringStream. this function is called by
       
   170 //       fatal error handlers. if the crash is in native thread,
       
   171 //       stringStream cannot get resource allocated and will SEGV.
       
   172 const char* Abstract_VM_Version::jre_release_version() {
       
   173   return VERSION_STRING;
       
   174 }
       
   175 
       
   176 #define OS       LINUX_ONLY("linux")             \
       
   177                  WINDOWS_ONLY("windows")         \
       
   178                  SOLARIS_ONLY("solaris")         \
       
   179                  AIX_ONLY("aix")                 \
       
   180                  BSD_ONLY("bsd")
       
   181 
       
   182 #ifndef CPU
       
   183 #ifdef ZERO
       
   184 #define CPU      ZERO_LIBARCH
       
   185 #elif defined(PPC64)
       
   186 #if defined(VM_LITTLE_ENDIAN)
       
   187 #define CPU      "ppc64le"
       
   188 #else
       
   189 #define CPU      "ppc64"
       
   190 #endif // PPC64
       
   191 #else
       
   192 #define CPU      AARCH64_ONLY("aarch64")         \
       
   193                  AMD64_ONLY("amd64")             \
       
   194                  IA32_ONLY("x86")                \
       
   195                  IA64_ONLY("ia64")               \
       
   196                  S390_ONLY("s390")               \
       
   197                  SPARC_ONLY("sparc")
       
   198 #endif // !ZERO
       
   199 #endif // !CPU
       
   200 
       
   201 const char *Abstract_VM_Version::vm_platform_string() {
       
   202   return OS "-" CPU;
       
   203 }
       
   204 
       
   205 const char* Abstract_VM_Version::internal_vm_info_string() {
       
   206   #ifndef HOTSPOT_BUILD_USER
       
   207     #define HOTSPOT_BUILD_USER unknown
       
   208   #endif
       
   209 
       
   210   #ifndef HOTSPOT_BUILD_COMPILER
       
   211     #ifdef _MSC_VER
       
   212       #if _MSC_VER == 1600
       
   213         #define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"
       
   214       #elif _MSC_VER == 1700
       
   215         #define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"
       
   216       #elif _MSC_VER == 1800
       
   217         #define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"
       
   218       #elif _MSC_VER == 1900
       
   219         #define HOTSPOT_BUILD_COMPILER "MS VC++ 14.0 (VS2015)"
       
   220       #elif _MSC_VER == 1911
       
   221         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.3 (VS2017)"
       
   222       #elif _MSC_VER == 1912
       
   223         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"
       
   224       #elif _MSC_VER == 1913
       
   225         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"
       
   226       #elif _MSC_VER == 1914
       
   227         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.7 (VS2017)"
       
   228       #elif _MSC_VER == 1915
       
   229         #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.8 (VS2017)"
       
   230       #else
       
   231         #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
       
   232       #endif
       
   233     #elif defined(__SUNPRO_CC)
       
   234       #if __SUNPRO_CC == 0x580
       
   235         #define HOTSPOT_BUILD_COMPILER "Workshop 5.8"
       
   236       #elif __SUNPRO_CC == 0x590
       
   237         #define HOTSPOT_BUILD_COMPILER "Workshop 5.9"
       
   238       #elif __SUNPRO_CC == 0x5100
       
   239         #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1"
       
   240       #elif __SUNPRO_CC == 0x5120
       
   241         #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u3"
       
   242       #elif __SUNPRO_CC == 0x5130
       
   243         #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u4"
       
   244       #else
       
   245         #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC)
       
   246       #endif
       
   247     #elif defined(__clang_version__)
       
   248         #define HOTSPOT_BUILD_COMPILER "clang " __VERSION__
       
   249     #elif defined(__GNUC__)
       
   250         #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__
       
   251     #else
       
   252       #define HOTSPOT_BUILD_COMPILER "unknown compiler"
       
   253     #endif
       
   254   #endif
       
   255 
       
   256   #ifndef FLOAT_ARCH
       
   257     #if defined(__SOFTFP__)
       
   258       #define FLOAT_ARCH_STR "-sflt"
       
   259     #else
       
   260       #define FLOAT_ARCH_STR ""
       
   261     #endif
       
   262   #else
       
   263     #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)
       
   264   #endif
       
   265 
       
   266   #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
       
   267          " for " OS "-" CPU FLOAT_ARCH_STR \
       
   268          " JRE (" VERSION_STRING "), built on " __DATE__ " " __TIME__ \
       
   269          " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
       
   270 
       
   271   return strcmp(DEBUG_LEVEL, "release") == 0
       
   272       ? VMNAME " (" INTERNAL_VERSION_SUFFIX
       
   273       : VMNAME " (" DEBUG_LEVEL " " INTERNAL_VERSION_SUFFIX;
       
   274 }
       
   275 
       
   276 const char *Abstract_VM_Version::vm_build_user() {
       
   277   return HOTSPOT_BUILD_USER;
       
   278 }
       
   279 
       
   280 const char *Abstract_VM_Version::jdk_debug_level() {
       
   281   return DEBUG_LEVEL;
       
   282 }
       
   283 
       
   284 const char *Abstract_VM_Version::printable_jdk_debug_level() {
       
   285   // Debug level is not printed for "release" builds
       
   286   return strcmp(DEBUG_LEVEL, "release") == 0 ? "" : DEBUG_LEVEL " ";
       
   287 }
       
   288 
       
   289 unsigned int Abstract_VM_Version::jvm_version() {
       
   290   return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |
       
   291          ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |
       
   292          ((Abstract_VM_Version::vm_security_version() & 0xFF) << 8) |
       
   293          (Abstract_VM_Version::vm_build_number() & 0xFF);
       
   294 }
       
   295 
       
   296 bool Abstract_VM_Version::print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) {
       
   297   char line[500];
       
   298   FILE* fp = fopen(filename, "r");
       
   299   if (fp == NULL) {
       
   300     return false;
       
   301   }
       
   302 
       
   303   st->print_cr("Virtualization information:");
       
   304   while (fgets(line, sizeof(line), fp) != NULL) {
       
   305     int i = 0;
       
   306     while (keywords_to_match[i] != NULL) {
       
   307       if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) {
       
   308         st->print("%s", line);
       
   309         break;
       
   310       }
       
   311       i++;
       
   312     }
       
   313   }
       
   314   fclose(fp);
       
   315   return true;
       
   316 }