Path: blob/master/src/hotspot/share/runtime/abstract_vm_version.cpp
40951 views
/*1* Copyright (c) 1998, 2021, 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 == 1600201#define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"202#elif _MSC_VER == 1700203#define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"204#elif _MSC_VER == 1800205#define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"206#elif _MSC_VER == 1900207#define HOTSPOT_BUILD_COMPILER "MS VC++ 14.0 (VS2015)"208#elif _MSC_VER == 1911209#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.3 (VS2017)"210#elif _MSC_VER == 1912211#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"212#elif _MSC_VER == 1913213#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"214#elif _MSC_VER == 1914215#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.7 (VS2017)"216#elif _MSC_VER == 1915217#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.8 (VS2017)"218#elif _MSC_VER == 1916219#define HOTSPOT_BUILD_COMPILER "MS VC++ 15.9 (VS2017)"220#elif _MSC_VER == 1920221#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.0 (VS2019)"222#elif _MSC_VER == 1921223#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.1 (VS2019)"224#elif _MSC_VER == 1922225#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.2 (VS2019)"226#elif _MSC_VER == 1923227#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.3 (VS2019)"228#elif _MSC_VER == 1924229#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.4 (VS2019)"230#elif _MSC_VER == 1925231#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.5 (VS2019)"232#elif _MSC_VER == 1926233#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.6 (VS2019)"234#elif _MSC_VER == 1927235#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.7 (VS2019)"236#elif _MSC_VER == 1928237#define HOTSPOT_BUILD_COMPILER "MS VC++ 16.8 (VS2019)"238#else239#define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)240#endif241#elif defined(__clang_version__)242#define HOTSPOT_BUILD_COMPILER "clang " __VERSION__243#elif defined(__GNUC__)244#define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__245#else246#define HOTSPOT_BUILD_COMPILER "unknown compiler"247#endif248#endif249250#ifndef FLOAT_ARCH251#if defined(__SOFTFP__)252#define FLOAT_ARCH_STR "-sflt"253#else254#define FLOAT_ARCH_STR ""255#endif256#else257#define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)258#endif259260#ifdef MUSL_LIBC261#define LIBC_STR "-" XSTR(LIBC)262#else263#define LIBC_STR ""264#endif265266#ifndef HOTSPOT_BUILD_TIME267#define HOTSPOT_BUILD_TIME __DATE__ " " __TIME__268#endif269270#define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \271" for " OS "-" CPU FLOAT_ARCH_STR LIBC_STR \272" JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \273" by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER274275return strcmp(DEBUG_LEVEL, "release") == 0276? VMNAME " (" INTERNAL_VERSION_SUFFIX277: VMNAME " (" DEBUG_LEVEL " " INTERNAL_VERSION_SUFFIX;278}279280const char *Abstract_VM_Version::vm_build_user() {281return HOTSPOT_BUILD_USER;282}283284const char *Abstract_VM_Version::jdk_debug_level() {285return DEBUG_LEVEL;286}287288const char *Abstract_VM_Version::printable_jdk_debug_level() {289// Debug level is not printed for "release" builds290return strcmp(DEBUG_LEVEL, "release") == 0 ? "" : DEBUG_LEVEL " ";291}292293unsigned int Abstract_VM_Version::jvm_version() {294return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |295((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |296((Abstract_VM_Version::vm_security_version() & 0xFF) << 8) |297(Abstract_VM_Version::vm_build_number() & 0xFF);298}299300void Abstract_VM_Version::insert_features_names(char* buf, size_t buflen, const char* features_names[]) {301uint64_t features = _features;302uint features_names_index = 0;303304while (features != 0) {305if (features & 1) {306int res = jio_snprintf(buf, buflen, ", %s", features_names[features_names_index]);307assert(res > 0, "not enough temporary space allocated");308buf += res;309buflen -= res;310}311features >>= 1;312++features_names_index;313}314}315316bool Abstract_VM_Version::print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) {317char line[500];318FILE* fp = fopen(filename, "r");319if (fp == NULL) {320return false;321}322323st->print_cr("Virtualization information:");324while (fgets(line, sizeof(line), fp) != NULL) {325int i = 0;326while (keywords_to_match[i] != NULL) {327if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) {328st->print("%s", line);329break;330}331i++;332}333}334fclose(fp);335return true;336}337338339