src/share/vm/runtime/vm_version.cpp

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 7598
ddce0b7cee93
parent 6876
710a3c8b516e
child 8856
ac27a9c85bea
permissions
-rw-r--r--

merge

aoqi@0 1 /*
dlong@7598 2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@1 25 /*
aoqi@1 26 * This file has been modified by Loongson Technology in 2015. These
aoqi@1 27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
aoqi@1 28 * available on the same license terms set forth above.
aoqi@1 29 */
aoqi@1 30
aoqi@0 31 #include "precompiled.hpp"
aoqi@0 32 #include "memory/universe.hpp"
aoqi@0 33 #include "oops/oop.inline.hpp"
aoqi@0 34 #include "runtime/arguments.hpp"
aoqi@0 35 #ifdef TARGET_ARCH_x86
aoqi@0 36 # include "vm_version_x86.hpp"
aoqi@0 37 #endif
aoqi@0 38 #ifdef TARGET_ARCH_sparc
aoqi@0 39 # include "vm_version_sparc.hpp"
aoqi@0 40 #endif
aoqi@0 41 #ifdef TARGET_ARCH_zero
aoqi@0 42 # include "vm_version_zero.hpp"
aoqi@0 43 #endif
aoqi@0 44 #ifdef TARGET_ARCH_arm
aoqi@0 45 # include "vm_version_arm.hpp"
aoqi@0 46 #endif
aoqi@0 47 #ifdef TARGET_ARCH_ppc
aoqi@0 48 # include "vm_version_ppc.hpp"
aoqi@0 49 #endif
aoqi@1 50 #ifdef TARGET_ARCH_mips
aoqi@1 51 # include "vm_version_mips.hpp"
aoqi@1 52 #endif
aoqi@0 53
aoqi@0 54 const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release();
aoqi@0 55 const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string();
aoqi@0 56 bool Abstract_VM_Version::_supports_cx8 = false;
aoqi@0 57 bool Abstract_VM_Version::_supports_atomic_getset4 = false;
aoqi@0 58 bool Abstract_VM_Version::_supports_atomic_getset8 = false;
aoqi@0 59 bool Abstract_VM_Version::_supports_atomic_getadd4 = false;
aoqi@0 60 bool Abstract_VM_Version::_supports_atomic_getadd8 = false;
aoqi@0 61 unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
aoqi@0 62 int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
aoqi@0 63
aoqi@0 64 #ifndef HOTSPOT_RELEASE_VERSION
aoqi@0 65 #error HOTSPOT_RELEASE_VERSION must be defined
aoqi@0 66 #endif
aoqi@0 67 #ifndef JRE_RELEASE_VERSION
aoqi@0 68 #error JRE_RELEASE_VERSION must be defined
aoqi@0 69 #endif
aoqi@0 70 #ifndef HOTSPOT_BUILD_TARGET
aoqi@0 71 #error HOTSPOT_BUILD_TARGET must be defined
aoqi@0 72 #endif
aoqi@0 73
aoqi@0 74 #ifdef PRODUCT
aoqi@0 75 #define VM_RELEASE HOTSPOT_RELEASE_VERSION
aoqi@0 76 #else
aoqi@0 77 #define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET
aoqi@0 78 #endif
aoqi@0 79
aoqi@0 80 // HOTSPOT_RELEASE_VERSION must follow the release version naming convention
aoqi@0 81 // <major_ver>.<minor_ver>-b<nn>[-<identifier>][-<debug_target>]
aoqi@0 82 int Abstract_VM_Version::_vm_major_version = 0;
aoqi@0 83 int Abstract_VM_Version::_vm_minor_version = 0;
aoqi@0 84 int Abstract_VM_Version::_vm_build_number = 0;
aoqi@0 85 bool Abstract_VM_Version::_initialized = false;
aoqi@0 86 int Abstract_VM_Version::_parallel_worker_threads = 0;
aoqi@0 87 bool Abstract_VM_Version::_parallel_worker_threads_initialized = false;
aoqi@0 88
aoqi@0 89 void Abstract_VM_Version::initialize() {
aoqi@0 90 if (_initialized) {
aoqi@0 91 return;
aoqi@0 92 }
aoqi@0 93 char* vm_version = os::strdup(HOTSPOT_RELEASE_VERSION);
aoqi@0 94
aoqi@0 95 // Expecting the next vm_version format:
aoqi@0 96 // <major_ver>.<minor_ver>-b<nn>[-<identifier>]
aoqi@0 97 char* vm_major_ver = vm_version;
aoqi@0 98 assert(isdigit(vm_major_ver[0]),"wrong vm major version number");
aoqi@0 99 char* vm_minor_ver = strchr(vm_major_ver, '.');
aoqi@0 100 assert(vm_minor_ver != NULL && isdigit(vm_minor_ver[1]),"wrong vm minor version number");
aoqi@0 101 vm_minor_ver[0] = '\0'; // terminate vm_major_ver
aoqi@0 102 vm_minor_ver += 1;
aoqi@0 103 char* vm_build_num = strchr(vm_minor_ver, '-');
aoqi@0 104 assert(vm_build_num != NULL && vm_build_num[1] == 'b' && isdigit(vm_build_num[2]),"wrong vm build number");
aoqi@0 105 vm_build_num[0] = '\0'; // terminate vm_minor_ver
aoqi@0 106 vm_build_num += 2;
aoqi@0 107
aoqi@0 108 _vm_major_version = atoi(vm_major_ver);
aoqi@0 109 _vm_minor_version = atoi(vm_minor_ver);
aoqi@0 110 _vm_build_number = atoi(vm_build_num);
aoqi@0 111
aoqi@0 112 os::free(vm_version);
aoqi@0 113 _initialized = true;
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 #if defined(_LP64)
aoqi@0 117 #define VMLP "64-Bit "
aoqi@0 118 #else
aoqi@0 119 #define VMLP ""
aoqi@0 120 #endif
aoqi@0 121
aoqi@0 122 #ifndef VMTYPE
aoqi@0 123 #ifdef TIERED
aoqi@0 124 #define VMTYPE "Server"
aoqi@0 125 #else // TIERED
aoqi@0 126 #ifdef ZERO
aoqi@0 127 #ifdef SHARK
aoqi@0 128 #define VMTYPE "Shark"
aoqi@0 129 #else // SHARK
aoqi@0 130 #define VMTYPE "Zero"
aoqi@0 131 #endif // SHARK
aoqi@0 132 #else // ZERO
aoqi@0 133 #define VMTYPE COMPILER1_PRESENT("Client") \
aoqi@0 134 COMPILER2_PRESENT("Server")
aoqi@0 135 #endif // ZERO
aoqi@0 136 #endif // TIERED
aoqi@0 137 #endif
aoqi@0 138
aoqi@0 139 #ifndef HOTSPOT_VM_DISTRO
aoqi@0 140 #error HOTSPOT_VM_DISTRO must be defined
aoqi@0 141 #endif
aoqi@0 142 #define VMNAME HOTSPOT_VM_DISTRO " " VMLP EMBEDDED_ONLY("Embedded ") VMTYPE " VM"
aoqi@0 143
aoqi@0 144 const char* Abstract_VM_Version::vm_name() {
aoqi@0 145 return VMNAME;
aoqi@0 146 }
aoqi@0 147
aoqi@0 148
aoqi@0 149 const char* Abstract_VM_Version::vm_vendor() {
aoqi@0 150 #ifdef VENDOR
aoqi@0 151 return XSTR(VENDOR);
aoqi@0 152 #else
aoqi@0 153 return JDK_Version::is_gte_jdk17x_version() ?
aoqi@0 154 "Oracle Corporation" : "Sun Microsystems Inc.";
aoqi@0 155 #endif
aoqi@0 156 }
aoqi@0 157
aoqi@0 158
aoqi@0 159 const char* Abstract_VM_Version::vm_info_string() {
aoqi@0 160 switch (Arguments::mode()) {
aoqi@0 161 case Arguments::_int:
aoqi@0 162 return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode";
aoqi@0 163 case Arguments::_mixed:
aoqi@0 164 return UseSharedSpaces ? "mixed mode, sharing" : "mixed mode";
aoqi@0 165 case Arguments::_comp:
aoqi@0 166 return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode";
aoqi@0 167 };
aoqi@0 168 ShouldNotReachHere();
aoqi@0 169 return "";
aoqi@0 170 }
aoqi@0 171
aoqi@0 172 // NOTE: do *not* use stringStream. this function is called by
aoqi@0 173 // fatal error handler. if the crash is in native thread,
aoqi@0 174 // stringStream cannot get resource allocated and will SEGV.
aoqi@0 175 const char* Abstract_VM_Version::vm_release() {
aoqi@0 176 return VM_RELEASE;
aoqi@0 177 }
aoqi@0 178
aoqi@0 179 // NOTE: do *not* use stringStream. this function is called by
aoqi@0 180 // fatal error handlers. if the crash is in native thread,
aoqi@0 181 // stringStream cannot get resource allocated and will SEGV.
aoqi@0 182 const char* Abstract_VM_Version::jre_release_version() {
aoqi@0 183 return JRE_RELEASE_VERSION;
aoqi@0 184 }
aoqi@0 185
aoqi@0 186 #define OS LINUX_ONLY("linux") \
aoqi@0 187 WINDOWS_ONLY("windows") \
aoqi@0 188 SOLARIS_ONLY("solaris") \
aoqi@0 189 AIX_ONLY("aix") \
aoqi@0 190 BSD_ONLY("bsd")
aoqi@0 191
dlong@7598 192 #ifndef CPU
aoqi@0 193 #ifdef ZERO
aoqi@0 194 #define CPU ZERO_LIBARCH
aoqi@0 195 #else
aoqi@0 196 #define CPU IA32_ONLY("x86") \
aoqi@0 197 IA64_ONLY("ia64") \
aoqi@0 198 AMD64_ONLY("amd64") \
aoqi@0 199 PPC64_ONLY("ppc64") \
aoqi@36 200 MIPS64_ONLY("mips64") \
aoqi@0 201 SPARC_ONLY("sparc")
aoqi@0 202 #endif // ZERO
dlong@7598 203 #endif
aoqi@0 204
aoqi@0 205 const char *Abstract_VM_Version::vm_platform_string() {
aoqi@0 206 return OS "-" CPU;
aoqi@0 207 }
aoqi@0 208
aoqi@0 209 const char* Abstract_VM_Version::internal_vm_info_string() {
aoqi@0 210 #ifndef HOTSPOT_BUILD_USER
aoqi@0 211 #define HOTSPOT_BUILD_USER unknown
aoqi@0 212 #endif
aoqi@0 213
aoqi@0 214 #ifndef HOTSPOT_BUILD_COMPILER
aoqi@0 215 #ifdef _MSC_VER
aoqi@0 216 #if _MSC_VER == 1100
aoqi@0 217 #define HOTSPOT_BUILD_COMPILER "MS VC++ 5.0"
aoqi@0 218 #elif _MSC_VER == 1200
aoqi@0 219 #define HOTSPOT_BUILD_COMPILER "MS VC++ 6.0"
aoqi@0 220 #elif _MSC_VER == 1310
aoqi@0 221 #define HOTSPOT_BUILD_COMPILER "MS VC++ 7.1 (VS2003)"
aoqi@0 222 #elif _MSC_VER == 1400
aoqi@0 223 #define HOTSPOT_BUILD_COMPILER "MS VC++ 8.0 (VS2005)"
aoqi@0 224 #elif _MSC_VER == 1500
aoqi@0 225 #define HOTSPOT_BUILD_COMPILER "MS VC++ 9.0 (VS2008)"
aoqi@0 226 #elif _MSC_VER == 1600
aoqi@0 227 #define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"
aoqi@0 228 #elif _MSC_VER == 1700
aoqi@0 229 #define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"
aoqi@0 230 #else
aoqi@0 231 #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
aoqi@0 232 #endif
aoqi@0 233 #elif defined(__SUNPRO_CC)
aoqi@0 234 #if __SUNPRO_CC == 0x420
aoqi@0 235 #define HOTSPOT_BUILD_COMPILER "Workshop 4.2"
aoqi@0 236 #elif __SUNPRO_CC == 0x500
aoqi@0 237 #define HOTSPOT_BUILD_COMPILER "Workshop 5.0 compat=" XSTR(__SUNPRO_CC_COMPAT)
aoqi@0 238 #elif __SUNPRO_CC == 0x520
aoqi@0 239 #define HOTSPOT_BUILD_COMPILER "Workshop 5.2 compat=" XSTR(__SUNPRO_CC_COMPAT)
aoqi@0 240 #elif __SUNPRO_CC == 0x580
aoqi@0 241 #define HOTSPOT_BUILD_COMPILER "Workshop 5.8"
aoqi@0 242 #elif __SUNPRO_CC == 0x590
aoqi@0 243 #define HOTSPOT_BUILD_COMPILER "Workshop 5.9"
aoqi@0 244 #elif __SUNPRO_CC == 0x5100
aoqi@0 245 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1"
aoqi@0 246 #elif __SUNPRO_CC == 0x5120
aoqi@0 247 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u3"
aoqi@0 248 #else
aoqi@0 249 #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC)
aoqi@0 250 #endif
aoqi@0 251 #elif defined(__GNUC__)
aoqi@0 252 #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__
aoqi@0 253 #elif defined(__IBMCPP__)
aoqi@0 254 #define HOTSPOT_BUILD_COMPILER "xlC " XSTR(__IBMCPP__)
aoqi@0 255
aoqi@0 256 #else
aoqi@0 257 #define HOTSPOT_BUILD_COMPILER "unknown compiler"
aoqi@0 258 #endif
aoqi@0 259 #endif
aoqi@0 260
aoqi@0 261 #ifndef FLOAT_ARCH
aoqi@0 262 #if defined(__SOFTFP__)
aoqi@0 263 #define FLOAT_ARCH_STR "-sflt"
aoqi@0 264 #else
aoqi@0 265 #define FLOAT_ARCH_STR ""
aoqi@0 266 #endif
aoqi@0 267 #else
aoqi@0 268 #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)
aoqi@0 269 #endif
aoqi@0 270
aoqi@0 271 return VMNAME " (" VM_RELEASE ") for " OS "-" CPU FLOAT_ARCH_STR
aoqi@0 272 " JRE (" JRE_RELEASE_VERSION "), built on " __DATE__ " " __TIME__
aoqi@0 273 " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER;
aoqi@0 274 }
aoqi@0 275
aoqi@0 276 const char *Abstract_VM_Version::vm_build_user() {
aoqi@0 277 return HOTSPOT_BUILD_USER;
aoqi@0 278 }
aoqi@0 279
aoqi@0 280 unsigned int Abstract_VM_Version::jvm_version() {
aoqi@0 281 return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |
aoqi@0 282 ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |
aoqi@0 283 (Abstract_VM_Version::vm_build_number() & 0xFF);
aoqi@0 284 }
aoqi@0 285
aoqi@0 286
aoqi@0 287 void VM_Version_init() {
aoqi@0 288 VM_Version::initialize();
aoqi@0 289
aoqi@0 290 #ifndef PRODUCT
aoqi@0 291 if (PrintMiscellaneous && Verbose) {
aoqi@0 292 os::print_cpu_info(tty);
aoqi@0 293 }
aoqi@0 294 #endif
aoqi@0 295 }
aoqi@0 296
aoqi@0 297 unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
aoqi@0 298 unsigned int num,
aoqi@0 299 unsigned int den,
aoqi@0 300 unsigned int switch_pt) {
aoqi@0 301 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
aoqi@0 302 assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
aoqi@0 303 // For very large machines, there are diminishing returns
aoqi@0 304 // for large numbers of worker threads. Instead of
aoqi@0 305 // hogging the whole system, use a fraction of the workers for every
aoqi@0 306 // processor after the first 8. For example, on a 72 cpu machine
aoqi@0 307 // and a chosen fraction of 5/8
aoqi@0 308 // use 8 + (72 - 8) * (5/8) == 48 worker threads.
aoqi@0 309 unsigned int ncpus = (unsigned int) os::active_processor_count();
aoqi@0 310 return (ncpus <= switch_pt) ?
aoqi@0 311 ncpus :
aoqi@0 312 (switch_pt + ((ncpus - switch_pt) * num) / den);
aoqi@0 313 } else {
aoqi@0 314 return ParallelGCThreads;
aoqi@0 315 }
aoqi@0 316 }
aoqi@0 317
aoqi@0 318 unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
aoqi@0 319 return nof_parallel_worker_threads(5, 8, 8);
aoqi@0 320 }
aoqi@0 321
aoqi@0 322
aoqi@0 323 // Does not set the _initialized flag since it is
aoqi@0 324 // a global flag.
aoqi@0 325 unsigned int Abstract_VM_Version::parallel_worker_threads() {
aoqi@0 326 if (!_parallel_worker_threads_initialized) {
aoqi@0 327 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
aoqi@0 328 _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
aoqi@0 329 } else {
aoqi@0 330 _parallel_worker_threads = ParallelGCThreads;
aoqi@0 331 }
aoqi@0 332 _parallel_worker_threads_initialized = true;
aoqi@0 333 }
aoqi@0 334 return _parallel_worker_threads;
aoqi@0 335 }

mercurial