1 /* 2 * Copyright (c) 1998, 2020, 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 #elif _MSC_VER == 1916 231 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.9 (VS2017)" 232 #elif _MSC_VER == 1920 233 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.0 (VS2019)" 234 #elif _MSC_VER == 1921 235 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.1 (VS2019)" 236 #elif _MSC_VER == 1922 237 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.2 (VS2019)" 238 #elif _MSC_VER == 1923 239 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.3 (VS2019)" 240 #else 241 #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER) 242 #endif 243 #elif defined(__SUNPRO_CC) 244 #if __SUNPRO_CC == 0x580 245 #define HOTSPOT_BUILD_COMPILER "Workshop 5.8" 246 #elif __SUNPRO_CC == 0x590 247 #define HOTSPOT_BUILD_COMPILER "Workshop 5.9" 248 #elif __SUNPRO_CC == 0x5100 249 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1" 250 #elif __SUNPRO_CC == 0x5120 251 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u3" 252 #elif __SUNPRO_CC == 0x5130 253 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u4" 254 #else 255 #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC) 256 #endif 257 #elif defined(__clang_version__) 258 #define HOTSPOT_BUILD_COMPILER "clang " __VERSION__ 259 #elif defined(__GNUC__) 260 #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__ 261 #else 262 #define HOTSPOT_BUILD_COMPILER "unknown compiler" 263 #endif 264 #endif 265 266 #ifndef FLOAT_ARCH 267 #if defined(__SOFTFP__) 268 #define FLOAT_ARCH_STR "-sflt" 269 #else 270 #define FLOAT_ARCH_STR "" 271 #endif 272 #else 273 #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH) 274 #endif 275 276 #ifndef HOTSPOT_BUILD_TIME 277 #define HOTSPOT_BUILD_TIME __DATE__ " " __TIME__ 278 #endif 279 280 #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \ 281 " for " OS "-" CPU FLOAT_ARCH_STR \ 282 " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \ 283 " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER 284 285 return strcmp(DEBUG_LEVEL, "release") == 0 286 ? VMNAME " (" INTERNAL_VERSION_SUFFIX 287 : VMNAME " (" DEBUG_LEVEL " " INTERNAL_VERSION_SUFFIX; 288 } 289 290 const char *Abstract_VM_Version::vm_build_user() { 291 return HOTSPOT_BUILD_USER; 292 } 293 294 const char *Abstract_VM_Version::jdk_debug_level() { 295 return DEBUG_LEVEL; 296 } 297 298 const char *Abstract_VM_Version::printable_jdk_debug_level() { 299 // Debug level is not printed for "release" builds 300 return strcmp(DEBUG_LEVEL, "release") == 0 ? "" : DEBUG_LEVEL " "; 301 } 302 303 unsigned int Abstract_VM_Version::jvm_version() { 304 return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) | 305 ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) | 306 ((Abstract_VM_Version::vm_security_version() & 0xFF) << 8) | 307 (Abstract_VM_Version::vm_build_number() & 0xFF); 308 } 309 310 bool Abstract_VM_Version::print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) { 311 char line[500]; 312 FILE* fp = fopen(filename, "r"); 313 if (fp == NULL) { 314 return false; 315 } 316 317 st->print_cr("Virtualization information:"); 318 while (fgets(line, sizeof(line), fp) != NULL) { 319 int i = 0; 320 while (keywords_to_match[i] != NULL) { 321 if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) { 322 st->print("%s", line); 323 break; 324 } 325 i++; 326 } 327 } 328 fclose(fp); 329 return true; 330 }