aoqi@0: /* dlong@7598: * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@1: /* aoqi@1: * This file has been modified by Loongson Technology in 2015. These aoqi@1: * modifications are Copyright (c) 2015 Loongson Technology, and are made aoqi@1: * available on the same license terms set forth above. aoqi@1: */ aoqi@1: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "memory/universe.hpp" aoqi@0: #include "oops/oop.inline.hpp" aoqi@0: #include "runtime/arguments.hpp" aoqi@0: #ifdef TARGET_ARCH_x86 aoqi@0: # include "vm_version_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_sparc aoqi@0: # include "vm_version_sparc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_zero aoqi@0: # include "vm_version_zero.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_arm aoqi@0: # include "vm_version_arm.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_ppc aoqi@0: # include "vm_version_ppc.hpp" aoqi@0: #endif aoqi@1: #ifdef TARGET_ARCH_mips aoqi@1: # include "vm_version_mips.hpp" aoqi@1: #endif aoqi@0: aoqi@0: const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release(); aoqi@0: const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string(); aoqi@0: bool Abstract_VM_Version::_supports_cx8 = false; aoqi@0: bool Abstract_VM_Version::_supports_atomic_getset4 = false; aoqi@0: bool Abstract_VM_Version::_supports_atomic_getset8 = false; aoqi@0: bool Abstract_VM_Version::_supports_atomic_getadd4 = false; aoqi@0: bool Abstract_VM_Version::_supports_atomic_getadd8 = false; aoqi@0: unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U; aoqi@0: int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0; aoqi@0: aoqi@0: #ifndef HOTSPOT_RELEASE_VERSION aoqi@0: #error HOTSPOT_RELEASE_VERSION must be defined aoqi@0: #endif aoqi@0: #ifndef JRE_RELEASE_VERSION aoqi@0: #error JRE_RELEASE_VERSION must be defined aoqi@0: #endif aoqi@0: #ifndef HOTSPOT_BUILD_TARGET aoqi@0: #error HOTSPOT_BUILD_TARGET must be defined aoqi@0: #endif aoqi@0: aoqi@0: #ifdef PRODUCT aoqi@0: #define VM_RELEASE HOTSPOT_RELEASE_VERSION aoqi@0: #else aoqi@0: #define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET aoqi@0: #endif aoqi@0: aoqi@0: // HOTSPOT_RELEASE_VERSION must follow the release version naming convention aoqi@0: // .-b[-][-] aoqi@0: int Abstract_VM_Version::_vm_major_version = 0; aoqi@0: int Abstract_VM_Version::_vm_minor_version = 0; aoqi@0: int Abstract_VM_Version::_vm_build_number = 0; aoqi@0: bool Abstract_VM_Version::_initialized = false; aoqi@0: int Abstract_VM_Version::_parallel_worker_threads = 0; aoqi@0: bool Abstract_VM_Version::_parallel_worker_threads_initialized = false; aoqi@0: aoqi@0: void Abstract_VM_Version::initialize() { aoqi@0: if (_initialized) { aoqi@0: return; aoqi@0: } aoqi@0: char* vm_version = os::strdup(HOTSPOT_RELEASE_VERSION); aoqi@0: aoqi@0: // Expecting the next vm_version format: aoqi@0: // .-b[-] aoqi@0: char* vm_major_ver = vm_version; aoqi@0: assert(isdigit(vm_major_ver[0]),"wrong vm major version number"); aoqi@0: char* vm_minor_ver = strchr(vm_major_ver, '.'); aoqi@0: assert(vm_minor_ver != NULL && isdigit(vm_minor_ver[1]),"wrong vm minor version number"); aoqi@0: vm_minor_ver[0] = '\0'; // terminate vm_major_ver aoqi@0: vm_minor_ver += 1; aoqi@0: char* vm_build_num = strchr(vm_minor_ver, '-'); aoqi@0: assert(vm_build_num != NULL && vm_build_num[1] == 'b' && isdigit(vm_build_num[2]),"wrong vm build number"); aoqi@0: vm_build_num[0] = '\0'; // terminate vm_minor_ver aoqi@0: vm_build_num += 2; aoqi@0: aoqi@0: _vm_major_version = atoi(vm_major_ver); aoqi@0: _vm_minor_version = atoi(vm_minor_ver); aoqi@0: _vm_build_number = atoi(vm_build_num); aoqi@0: aoqi@0: os::free(vm_version); aoqi@0: _initialized = true; aoqi@0: } aoqi@0: aoqi@0: #if defined(_LP64) aoqi@0: #define VMLP "64-Bit " aoqi@0: #else aoqi@0: #define VMLP "" aoqi@0: #endif aoqi@0: aoqi@0: #ifndef VMTYPE aoqi@0: #ifdef TIERED aoqi@0: #define VMTYPE "Server" aoqi@0: #else // TIERED aoqi@0: #ifdef ZERO aoqi@0: #ifdef SHARK aoqi@0: #define VMTYPE "Shark" aoqi@0: #else // SHARK aoqi@0: #define VMTYPE "Zero" aoqi@0: #endif // SHARK aoqi@0: #else // ZERO aoqi@0: #define VMTYPE COMPILER1_PRESENT("Client") \ aoqi@0: COMPILER2_PRESENT("Server") aoqi@0: #endif // ZERO aoqi@0: #endif // TIERED aoqi@0: #endif aoqi@0: aoqi@0: #ifndef HOTSPOT_VM_DISTRO aoqi@0: #error HOTSPOT_VM_DISTRO must be defined aoqi@0: #endif aoqi@0: #define VMNAME HOTSPOT_VM_DISTRO " " VMLP EMBEDDED_ONLY("Embedded ") VMTYPE " VM" aoqi@0: aoqi@0: const char* Abstract_VM_Version::vm_name() { aoqi@0: return VMNAME; aoqi@0: } aoqi@0: aoqi@0: aoqi@0: const char* Abstract_VM_Version::vm_vendor() { aoqi@0: #ifdef VENDOR aoqi@0: return XSTR(VENDOR); aoqi@0: #else aoqi@0: return JDK_Version::is_gte_jdk17x_version() ? aoqi@0: "Oracle Corporation" : "Sun Microsystems Inc."; aoqi@0: #endif aoqi@0: } aoqi@0: aoqi@0: aoqi@0: const char* Abstract_VM_Version::vm_info_string() { aoqi@0: switch (Arguments::mode()) { aoqi@0: case Arguments::_int: aoqi@0: return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode"; aoqi@0: case Arguments::_mixed: aoqi@0: return UseSharedSpaces ? "mixed mode, sharing" : "mixed mode"; aoqi@0: case Arguments::_comp: aoqi@0: return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode"; aoqi@0: }; aoqi@0: ShouldNotReachHere(); aoqi@0: return ""; aoqi@0: } aoqi@0: aoqi@0: // NOTE: do *not* use stringStream. this function is called by aoqi@0: // fatal error handler. if the crash is in native thread, aoqi@0: // stringStream cannot get resource allocated and will SEGV. aoqi@0: const char* Abstract_VM_Version::vm_release() { aoqi@0: return VM_RELEASE; aoqi@0: } aoqi@0: aoqi@0: // NOTE: do *not* use stringStream. this function is called by aoqi@0: // fatal error handlers. if the crash is in native thread, aoqi@0: // stringStream cannot get resource allocated and will SEGV. aoqi@0: const char* Abstract_VM_Version::jre_release_version() { aoqi@0: return JRE_RELEASE_VERSION; aoqi@0: } aoqi@0: aoqi@0: #define OS LINUX_ONLY("linux") \ aoqi@0: WINDOWS_ONLY("windows") \ aoqi@0: SOLARIS_ONLY("solaris") \ aoqi@0: AIX_ONLY("aix") \ aoqi@0: BSD_ONLY("bsd") aoqi@0: dlong@7598: #ifndef CPU aoqi@0: #ifdef ZERO aoqi@0: #define CPU ZERO_LIBARCH aoqi@0: #else aoqi@0: #define CPU IA32_ONLY("x86") \ aoqi@0: IA64_ONLY("ia64") \ aoqi@0: AMD64_ONLY("amd64") \ aoqi@0: PPC64_ONLY("ppc64") \ aoqi@36: MIPS64_ONLY("mips64") \ aoqi@0: SPARC_ONLY("sparc") aoqi@0: #endif // ZERO dlong@7598: #endif aoqi@0: aoqi@0: const char *Abstract_VM_Version::vm_platform_string() { aoqi@0: return OS "-" CPU; aoqi@0: } aoqi@0: aoqi@0: const char* Abstract_VM_Version::internal_vm_info_string() { aoqi@0: #ifndef HOTSPOT_BUILD_USER aoqi@0: #define HOTSPOT_BUILD_USER unknown aoqi@0: #endif aoqi@0: aoqi@0: #ifndef HOTSPOT_BUILD_COMPILER aoqi@0: #ifdef _MSC_VER aoqi@0: #if _MSC_VER == 1100 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 5.0" aoqi@0: #elif _MSC_VER == 1200 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 6.0" aoqi@0: #elif _MSC_VER == 1310 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 7.1 (VS2003)" aoqi@0: #elif _MSC_VER == 1400 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 8.0 (VS2005)" aoqi@0: #elif _MSC_VER == 1500 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 9.0 (VS2008)" aoqi@0: #elif _MSC_VER == 1600 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)" aoqi@0: #elif _MSC_VER == 1700 aoqi@0: #define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)" aoqi@0: #else aoqi@0: #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER) aoqi@0: #endif aoqi@0: #elif defined(__SUNPRO_CC) aoqi@0: #if __SUNPRO_CC == 0x420 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Workshop 4.2" aoqi@0: #elif __SUNPRO_CC == 0x500 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Workshop 5.0 compat=" XSTR(__SUNPRO_CC_COMPAT) aoqi@0: #elif __SUNPRO_CC == 0x520 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Workshop 5.2 compat=" XSTR(__SUNPRO_CC_COMPAT) aoqi@0: #elif __SUNPRO_CC == 0x580 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Workshop 5.8" aoqi@0: #elif __SUNPRO_CC == 0x590 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Workshop 5.9" aoqi@0: #elif __SUNPRO_CC == 0x5100 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1" aoqi@0: #elif __SUNPRO_CC == 0x5120 aoqi@0: #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u3" aoqi@0: #else aoqi@0: #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC) aoqi@0: #endif aoqi@0: #elif defined(__GNUC__) aoqi@0: #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__ aoqi@0: #elif defined(__IBMCPP__) aoqi@0: #define HOTSPOT_BUILD_COMPILER "xlC " XSTR(__IBMCPP__) aoqi@0: aoqi@0: #else aoqi@0: #define HOTSPOT_BUILD_COMPILER "unknown compiler" aoqi@0: #endif aoqi@0: #endif aoqi@0: aoqi@0: #ifndef FLOAT_ARCH aoqi@0: #if defined(__SOFTFP__) aoqi@0: #define FLOAT_ARCH_STR "-sflt" aoqi@0: #else aoqi@0: #define FLOAT_ARCH_STR "" aoqi@0: #endif aoqi@0: #else aoqi@0: #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH) aoqi@0: #endif aoqi@0: aoqi@0: return VMNAME " (" VM_RELEASE ") for " OS "-" CPU FLOAT_ARCH_STR aoqi@0: " JRE (" JRE_RELEASE_VERSION "), built on " __DATE__ " " __TIME__ aoqi@0: " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER; aoqi@0: } aoqi@0: aoqi@0: const char *Abstract_VM_Version::vm_build_user() { aoqi@0: return HOTSPOT_BUILD_USER; aoqi@0: } aoqi@0: aoqi@0: unsigned int Abstract_VM_Version::jvm_version() { aoqi@0: return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) | aoqi@0: ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) | aoqi@0: (Abstract_VM_Version::vm_build_number() & 0xFF); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void VM_Version_init() { aoqi@0: VM_Version::initialize(); aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: if (PrintMiscellaneous && Verbose) { aoqi@0: os::print_cpu_info(tty); aoqi@0: } aoqi@0: #endif aoqi@0: } aoqi@0: aoqi@0: unsigned int Abstract_VM_Version::nof_parallel_worker_threads( aoqi@0: unsigned int num, aoqi@0: unsigned int den, aoqi@0: unsigned int switch_pt) { aoqi@0: if (FLAG_IS_DEFAULT(ParallelGCThreads)) { aoqi@0: assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0"); aoqi@0: // For very large machines, there are diminishing returns aoqi@0: // for large numbers of worker threads. Instead of aoqi@0: // hogging the whole system, use a fraction of the workers for every aoqi@0: // processor after the first 8. For example, on a 72 cpu machine aoqi@0: // and a chosen fraction of 5/8 aoqi@0: // use 8 + (72 - 8) * (5/8) == 48 worker threads. aoqi@0: unsigned int ncpus = (unsigned int) os::active_processor_count(); aoqi@0: return (ncpus <= switch_pt) ? aoqi@0: ncpus : aoqi@0: (switch_pt + ((ncpus - switch_pt) * num) / den); aoqi@0: } else { aoqi@0: return ParallelGCThreads; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: unsigned int Abstract_VM_Version::calc_parallel_worker_threads() { aoqi@0: return nof_parallel_worker_threads(5, 8, 8); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: // Does not set the _initialized flag since it is aoqi@0: // a global flag. aoqi@0: unsigned int Abstract_VM_Version::parallel_worker_threads() { aoqi@0: if (!_parallel_worker_threads_initialized) { aoqi@0: if (FLAG_IS_DEFAULT(ParallelGCThreads)) { aoqi@0: _parallel_worker_threads = VM_Version::calc_parallel_worker_threads(); aoqi@0: } else { aoqi@0: _parallel_worker_threads = ParallelGCThreads; aoqi@0: } aoqi@0: _parallel_worker_threads_initialized = true; aoqi@0: } aoqi@0: return _parallel_worker_threads; aoqi@0: }