Path: blob/master/src/hotspot/share/runtime/abstract_vm_version.cpp
64440 views
/*1* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "jvm_io.h"26#include "compiler/compilerDefinitions.hpp"27#include "runtime/arguments.hpp"28#include "runtime/vm_version.hpp"29#include "utilities/globalDefinitions.hpp"3031const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release();32const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string();3334uint64_t Abstract_VM_Version::_features = 0;35const char* Abstract_VM_Version::_features_string = "";3637bool Abstract_VM_Version::_supports_cx8 = false;38bool Abstract_VM_Version::_supports_atomic_getset4 = false;39bool Abstract_VM_Version::_supports_atomic_getset8 = false;40bool Abstract_VM_Version::_supports_atomic_getadd4 = false;41bool Abstract_VM_Version::_supports_atomic_getadd8 = false;42unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;43unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;44unsigned int Abstract_VM_Version::_data_cache_line_flush_size = 0;4546VirtualizationType Abstract_VM_Version::_detected_virtualization = NoDetectedVirtualization;4748#ifndef HOTSPOT_VERSION_STRING49#error HOTSPOT_VERSION_STRING must be defined50#endif5152#ifndef VERSION_FEATURE53#error VERSION_FEATURE must be defined54#endif55#ifndef VERSION_INTERIM56#error VERSION_INTERIM must be defined57#endif58#ifndef VERSION_UPDATE59#error VERSION_UPDATE must be defined60#endif61#ifndef VERSION_PATCH62#error VERSION_PATCH must be defined63#endif64#ifndef VERSION_BUILD65#error VERSION_BUILD must be defined66#endif6768#ifndef VERSION_STRING69#error VERSION_STRING must be defined70#endif7172#ifndef DEBUG_LEVEL73#error DEBUG_LEVEL must be defined74#endif7576#define VM_RELEASE HOTSPOT_VERSION_STRING7778// HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden79// in a standalone build).80int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE;81int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM;82int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE;83int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;84int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;8586#if defined(_LP64)87#define VMLP "64-Bit "88#else89#define VMLP ""90#endif9192#ifndef VMTYPE93#if COMPILER1_AND_COMPILER294#define VMTYPE "Server"95#else // COMPILER1_AND_COMPILER296#ifdef ZERO97#define VMTYPE "Zero"98#else // ZERO99#define VMTYPE COMPILER1_PRESENT("Client") \100COMPILER2_PRESENT("Server")101#endif // ZERO102#endif // COMPILER1_AND_COMPILER2103#endif104105#ifndef HOTSPOT_VM_DISTRO106#error HOTSPOT_VM_DISTRO must be defined107#endif108#define VMNAME HOTSPOT_VM_DISTRO " " VMLP VMTYPE " VM"109110const char* Abstract_VM_Version::vm_name() {111return VMNAME;112}113114115const char* Abstract_VM_Version::vm_vendor() {116#ifdef VENDOR117return VENDOR;118#else119return "Oracle Corporation";120#endif121}122123124const char* Abstract_VM_Version::vm_info_string() {125switch (Arguments::mode()) {126case Arguments::_int:127return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode";128case Arguments::_mixed:129if (UseSharedSpaces) {130if (CompilationModeFlag::quick_only()) {131return "mixed mode, emulated-client, sharing";132} else {133return "mixed mode, sharing";134}135} else {136if (CompilationModeFlag::quick_only()) {137return "mixed mode, emulated-client";138} else {139return "mixed mode";140}141}142case Arguments::_comp:143if (CompilationModeFlag::quick_only()) {144return UseSharedSpaces ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client";145}146return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode";147}148ShouldNotReachHere();149return "";150}151152// NOTE: do *not* use stringStream. this function is called by153// fatal error handler. if the crash is in native thread,154// stringStream cannot get resource allocated and will SEGV.155const char* Abstract_VM_Version::vm_release() {156return VM_RELEASE;157}158159// NOTE: do *not* use stringStream. this function is called by160// fatal error handlers. if the crash is in native thread,161// stringStream cannot get resource allocated and will SEGV.162const char* Abstract_VM_Version::jre_release_version() {163return VERSION_STRING;164}165166#define OS LINUX_ONLY("linux") \167WINDOWS_ONLY("windows") \168AIX_ONLY("aix") \169BSD_ONLY("bsd")170171#ifndef CPU172#ifdef ZERO173#define CPU ZERO_LIBARCH174#elif defined(PPC64)175#if defined(VM_LITTLE_ENDIAN)176#define CPU "ppc64le"177#else178#define CPU "ppc64"179#endif // PPC64180#else181#define CPU AARCH64_ONLY("aarch64") \182AMD64_ONLY("amd64") \183IA32_ONLY("x86") \184IA64_ONLY("ia64") \185S390_ONLY("s390")186#endif // !ZERO187#endif // !CPU188189const char *Abstract_VM_Version::vm_platform_string() {190return OS "-" CPU;191}192193const char* Abstract_VM_Version::internal_vm_info_string() {194#ifndef HOTSPOT_BUILD_USER195#define HOTSPOT_BUILD_USER unknown196#endif197198#ifndef HOTSPOT_BUILD_COMPILER199#ifdef _MSC_VER200#if _MSC_VER == 1800201#define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"202#elif _MSC_VER == 1900203#define HOTSPOT_BUILD_COMPILER "MS VC++ 14.0 (VS2015)"204#elif _MSC_VER == 1911205#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.3 (VS2017)"206#elif _MSC_VER == 1912207#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"208#elif _MSC_VER == 1913209#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"210#elif _MSC_VER == 1914211#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.7 (VS2017)"212#elif _MSC_VER == 1915213#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.8 (VS2017)"214#elif _MSC_VER == 1916215#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.9 (VS2017)"216#elif _MSC_VER == 1920217#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.0 (VS2019)"218#elif _MSC_VER == 1921219#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.1 (VS2019)"220#elif _MSC_VER == 1922221#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.2 (VS2019)"222#elif _MSC_VER == 1923223#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.3 (VS2019)"224#elif _MSC_VER == 1924225#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.4 (VS2019)"226#elif _MSC_VER == 1925227#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.5 (VS2019)"228#elif _MSC_VER == 1926229#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.6 (VS2019)"230#elif _MSC_VER == 1927231#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.7 (VS2019)"232#elif _MSC_VER == 1928233#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.8 / 16.9 (VS2019)"234#elif _MSC_VER == 1929235#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.10 / 16.11 (VS2019)"236#elif _MSC_VER == 1930237#define HOTSPOT_BUILD_COMPILER "MS VC++ 17.0 (VS2022)"238#elif _MSC_VER == 1931239#define HOTSPOT_BUILD_COMPILER "MS VC++ 17.1 (VS2022)"240#else241#define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)242#endif243#elif defined(__clang_version__)244#define HOTSPOT_BUILD_COMPILER "clang " __VERSION__245#elif defined(__GNUC__)246#define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__247#else248#define HOTSPOT_BUILD_COMPILER "unknown compiler"249#endif250#endif251252#ifndef FLOAT_ARCH253#if defined(__SOFTFP__)254#define FLOAT_ARCH_STR "-sflt"255#else256#define FLOAT_ARCH_STR ""257#endif258#else259#define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)260#endif261262#ifdef MUSL_LIBC263#define LIBC_STR "-" XSTR(LIBC)264#else265#define LIBC_STR ""266#endif267268#ifndef HOTSPOT_BUILD_TIME269#define HOTSPOT_BUILD_TIME __DATE__ " " __TIME__270#endif271272#define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \273" for " OS "-" CPU FLOAT_ARCH_STR LIBC_STR \274" JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \275" by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER276277return strcmp(DEBUG_LEVEL, "release") == 0278? VMNAME " (" INTERNAL_VERSION_SUFFIX279: VMNAME " (" DEBUG_LEVEL " " INTERNAL_VERSION_SUFFIX;280}281282const char *Abstract_VM_Version::vm_build_user() {283return HOTSPOT_BUILD_USER;284}285286const char *Abstract_VM_Version::jdk_debug_level() {287return DEBUG_LEVEL;288}289290const char *Abstract_VM_Version::printable_jdk_debug_level() {291// Debug level is not printed for "release" builds292return strcmp(DEBUG_LEVEL, "release") == 0 ? "" : DEBUG_LEVEL " ";293}294295unsigned int Abstract_VM_Version::jvm_version() {296return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |297((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |298((Abstract_VM_Version::vm_security_version() & 0xFF) << 8) |299(Abstract_VM_Version::vm_build_number() & 0xFF);300}301302void Abstract_VM_Version::insert_features_names(char* buf, size_t buflen, const char* features_names[]) {303uint64_t features = _features;304uint features_names_index = 0;305306while (features != 0) {307if (features & 1) {308int res = jio_snprintf(buf, buflen, ", %s", features_names[features_names_index]);309assert(res > 0, "not enough temporary space allocated");310buf += res;311buflen -= res;312}313features >>= 1;314++features_names_index;315}316}317318bool Abstract_VM_Version::print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) {319char line[500];320FILE* fp = fopen(filename, "r");321if (fp == NULL) {322return false;323}324325st->print_cr("Virtualization information:");326while (fgets(line, sizeof(line), fp) != NULL) {327int i = 0;328while (keywords_to_match[i] != NULL) {329if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) {330st->print("%s", line);331break;332}333i++;334}335}336fclose(fp);337return true;338}339340341