src/share/vm/runtime/vm_version.cpp

Thu, 24 May 2018 18:41:44 +0800

author
aoqi
date
Thu, 24 May 2018 18:41:44 +0800
changeset 8856
ac27a9c85bea
parent 8729
402618d5afc9
parent 7994
04ff2f6cd0eb
child 9448
73d689add964
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
tschatzl@8662 2 * Copyright (c) 1998, 2016, 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;
kevinw@8729 62 unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
aoqi@0 63 int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
aoqi@0 64
aoqi@0 65 #ifndef HOTSPOT_RELEASE_VERSION
aoqi@0 66 #error HOTSPOT_RELEASE_VERSION must be defined
aoqi@0 67 #endif
aoqi@0 68 #ifndef JRE_RELEASE_VERSION
aoqi@0 69 #error JRE_RELEASE_VERSION must be defined
aoqi@0 70 #endif
aoqi@0 71 #ifndef HOTSPOT_BUILD_TARGET
aoqi@0 72 #error HOTSPOT_BUILD_TARGET must be defined
aoqi@0 73 #endif
aoqi@0 74
aoqi@0 75 #ifdef PRODUCT
aoqi@0 76 #define VM_RELEASE HOTSPOT_RELEASE_VERSION
aoqi@0 77 #else
aoqi@0 78 #define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET
aoqi@0 79 #endif
aoqi@0 80
aoqi@0 81 // HOTSPOT_RELEASE_VERSION must follow the release version naming convention
aoqi@0 82 // <major_ver>.<minor_ver>-b<nn>[-<identifier>][-<debug_target>]
aoqi@0 83 int Abstract_VM_Version::_vm_major_version = 0;
aoqi@0 84 int Abstract_VM_Version::_vm_minor_version = 0;
aoqi@0 85 int Abstract_VM_Version::_vm_build_number = 0;
aoqi@0 86 bool Abstract_VM_Version::_initialized = false;
aoqi@0 87 int Abstract_VM_Version::_parallel_worker_threads = 0;
aoqi@0 88 bool Abstract_VM_Version::_parallel_worker_threads_initialized = false;
aoqi@0 89
aoqi@0 90 void Abstract_VM_Version::initialize() {
aoqi@0 91 if (_initialized) {
aoqi@0 92 return;
aoqi@0 93 }
aoqi@0 94 char* vm_version = os::strdup(HOTSPOT_RELEASE_VERSION);
aoqi@0 95
aoqi@0 96 // Expecting the next vm_version format:
aoqi@0 97 // <major_ver>.<minor_ver>-b<nn>[-<identifier>]
aoqi@0 98 char* vm_major_ver = vm_version;
aoqi@0 99 assert(isdigit(vm_major_ver[0]),"wrong vm major version number");
aoqi@0 100 char* vm_minor_ver = strchr(vm_major_ver, '.');
aoqi@0 101 assert(vm_minor_ver != NULL && isdigit(vm_minor_ver[1]),"wrong vm minor version number");
aoqi@0 102 vm_minor_ver[0] = '\0'; // terminate vm_major_ver
aoqi@0 103 vm_minor_ver += 1;
aoqi@0 104 char* vm_build_num = strchr(vm_minor_ver, '-');
aoqi@0 105 assert(vm_build_num != NULL && vm_build_num[1] == 'b' && isdigit(vm_build_num[2]),"wrong vm build number");
aoqi@0 106 vm_build_num[0] = '\0'; // terminate vm_minor_ver
aoqi@0 107 vm_build_num += 2;
aoqi@0 108
aoqi@0 109 _vm_major_version = atoi(vm_major_ver);
aoqi@0 110 _vm_minor_version = atoi(vm_minor_ver);
aoqi@0 111 _vm_build_number = atoi(vm_build_num);
aoqi@0 112
aoqi@0 113 os::free(vm_version);
aoqi@0 114 _initialized = true;
aoqi@0 115 }
aoqi@0 116
aoqi@0 117 #if defined(_LP64)
aoqi@0 118 #define VMLP "64-Bit "
aoqi@0 119 #else
aoqi@0 120 #define VMLP ""
aoqi@0 121 #endif
aoqi@0 122
aoqi@0 123 #ifndef VMTYPE
aoqi@0 124 #ifdef TIERED
aoqi@0 125 #define VMTYPE "Server"
aoqi@0 126 #else // TIERED
aoqi@0 127 #ifdef ZERO
aoqi@0 128 #ifdef SHARK
aoqi@0 129 #define VMTYPE "Shark"
aoqi@0 130 #else // SHARK
aoqi@0 131 #define VMTYPE "Zero"
aoqi@0 132 #endif // SHARK
aoqi@0 133 #else // ZERO
aoqi@0 134 #define VMTYPE COMPILER1_PRESENT("Client") \
aoqi@0 135 COMPILER2_PRESENT("Server")
aoqi@0 136 #endif // ZERO
aoqi@0 137 #endif // TIERED
aoqi@0 138 #endif
aoqi@0 139
aoqi@0 140 #ifndef HOTSPOT_VM_DISTRO
aoqi@0 141 #error HOTSPOT_VM_DISTRO must be defined
aoqi@0 142 #endif
aoqi@0 143 #define VMNAME HOTSPOT_VM_DISTRO " " VMLP EMBEDDED_ONLY("Embedded ") VMTYPE " VM"
aoqi@0 144
aoqi@0 145 const char* Abstract_VM_Version::vm_name() {
aoqi@0 146 return VMNAME;
aoqi@0 147 }
aoqi@0 148
aoqi@0 149
aoqi@0 150 const char* Abstract_VM_Version::vm_vendor() {
aoqi@0 151 #ifdef VENDOR
aoqi@0 152 return XSTR(VENDOR);
aoqi@0 153 #else
aoqi@0 154 return JDK_Version::is_gte_jdk17x_version() ?
aoqi@0 155 "Oracle Corporation" : "Sun Microsystems Inc.";
aoqi@0 156 #endif
aoqi@0 157 }
aoqi@0 158
aoqi@0 159
aoqi@0 160 const char* Abstract_VM_Version::vm_info_string() {
aoqi@0 161 switch (Arguments::mode()) {
aoqi@0 162 case Arguments::_int:
aoqi@0 163 return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode";
aoqi@0 164 case Arguments::_mixed:
aoqi@0 165 return UseSharedSpaces ? "mixed mode, sharing" : "mixed mode";
aoqi@0 166 case Arguments::_comp:
aoqi@0 167 return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode";
aoqi@0 168 };
aoqi@0 169 ShouldNotReachHere();
aoqi@0 170 return "";
aoqi@0 171 }
aoqi@0 172
aoqi@0 173 // NOTE: do *not* use stringStream. this function is called by
aoqi@0 174 // fatal error handler. if the crash is in native thread,
aoqi@0 175 // stringStream cannot get resource allocated and will SEGV.
aoqi@0 176 const char* Abstract_VM_Version::vm_release() {
aoqi@0 177 return VM_RELEASE;
aoqi@0 178 }
aoqi@0 179
aoqi@0 180 // NOTE: do *not* use stringStream. this function is called by
aoqi@0 181 // fatal error handlers. if the crash is in native thread,
aoqi@0 182 // stringStream cannot get resource allocated and will SEGV.
aoqi@0 183 const char* Abstract_VM_Version::jre_release_version() {
aoqi@0 184 return JRE_RELEASE_VERSION;
aoqi@0 185 }
aoqi@0 186
aoqi@0 187 #define OS LINUX_ONLY("linux") \
aoqi@0 188 WINDOWS_ONLY("windows") \
aoqi@0 189 SOLARIS_ONLY("solaris") \
aoqi@0 190 AIX_ONLY("aix") \
aoqi@0 191 BSD_ONLY("bsd")
aoqi@0 192
dlong@7598 193 #ifndef CPU
aoqi@0 194 #ifdef ZERO
aoqi@0 195 #define CPU ZERO_LIBARCH
aoqi@0 196 #else
aoqi@0 197 #define CPU IA32_ONLY("x86") \
aoqi@0 198 IA64_ONLY("ia64") \
aoqi@0 199 AMD64_ONLY("amd64") \
aoqi@0 200 PPC64_ONLY("ppc64") \
aoqi@36 201 MIPS64_ONLY("mips64") \
aoqi@0 202 SPARC_ONLY("sparc")
aoqi@0 203 #endif // ZERO
dlong@7598 204 #endif
aoqi@0 205
aoqi@0 206 const char *Abstract_VM_Version::vm_platform_string() {
aoqi@0 207 return OS "-" CPU;
aoqi@0 208 }
aoqi@0 209
aoqi@0 210 const char* Abstract_VM_Version::internal_vm_info_string() {
aoqi@0 211 #ifndef HOTSPOT_BUILD_USER
aoqi@0 212 #define HOTSPOT_BUILD_USER unknown
aoqi@0 213 #endif
aoqi@0 214
aoqi@0 215 #ifndef HOTSPOT_BUILD_COMPILER
aoqi@0 216 #ifdef _MSC_VER
aoqi@0 217 #if _MSC_VER == 1100
aoqi@0 218 #define HOTSPOT_BUILD_COMPILER "MS VC++ 5.0"
aoqi@0 219 #elif _MSC_VER == 1200
aoqi@0 220 #define HOTSPOT_BUILD_COMPILER "MS VC++ 6.0"
aoqi@0 221 #elif _MSC_VER == 1310
aoqi@0 222 #define HOTSPOT_BUILD_COMPILER "MS VC++ 7.1 (VS2003)"
aoqi@0 223 #elif _MSC_VER == 1400
aoqi@0 224 #define HOTSPOT_BUILD_COMPILER "MS VC++ 8.0 (VS2005)"
aoqi@0 225 #elif _MSC_VER == 1500
aoqi@0 226 #define HOTSPOT_BUILD_COMPILER "MS VC++ 9.0 (VS2008)"
aoqi@0 227 #elif _MSC_VER == 1600
aoqi@0 228 #define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"
aoqi@0 229 #elif _MSC_VER == 1700
aoqi@0 230 #define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"
aoqi@0 231 #else
aoqi@0 232 #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
aoqi@0 233 #endif
aoqi@0 234 #elif defined(__SUNPRO_CC)
aoqi@0 235 #if __SUNPRO_CC == 0x420
aoqi@0 236 #define HOTSPOT_BUILD_COMPILER "Workshop 4.2"
aoqi@0 237 #elif __SUNPRO_CC == 0x500
aoqi@0 238 #define HOTSPOT_BUILD_COMPILER "Workshop 5.0 compat=" XSTR(__SUNPRO_CC_COMPAT)
aoqi@0 239 #elif __SUNPRO_CC == 0x520
aoqi@0 240 #define HOTSPOT_BUILD_COMPILER "Workshop 5.2 compat=" XSTR(__SUNPRO_CC_COMPAT)
aoqi@0 241 #elif __SUNPRO_CC == 0x580
aoqi@0 242 #define HOTSPOT_BUILD_COMPILER "Workshop 5.8"
aoqi@0 243 #elif __SUNPRO_CC == 0x590
aoqi@0 244 #define HOTSPOT_BUILD_COMPILER "Workshop 5.9"
aoqi@0 245 #elif __SUNPRO_CC == 0x5100
aoqi@0 246 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1"
aoqi@0 247 #elif __SUNPRO_CC == 0x5120
aoqi@0 248 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u3"
aoqi@0 249 #else
aoqi@0 250 #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC)
aoqi@0 251 #endif
aoqi@0 252 #elif defined(__GNUC__)
aoqi@0 253 #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__
aoqi@0 254 #elif defined(__IBMCPP__)
aoqi@0 255 #define HOTSPOT_BUILD_COMPILER "xlC " XSTR(__IBMCPP__)
aoqi@0 256
aoqi@0 257 #else
aoqi@0 258 #define HOTSPOT_BUILD_COMPILER "unknown compiler"
aoqi@0 259 #endif
aoqi@0 260 #endif
aoqi@0 261
aoqi@0 262 #ifndef FLOAT_ARCH
aoqi@0 263 #if defined(__SOFTFP__)
aoqi@0 264 #define FLOAT_ARCH_STR "-sflt"
aoqi@0 265 #else
aoqi@0 266 #define FLOAT_ARCH_STR ""
aoqi@0 267 #endif
aoqi@0 268 #else
aoqi@0 269 #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)
aoqi@0 270 #endif
aoqi@0 271
aoqi@0 272 return VMNAME " (" VM_RELEASE ") for " OS "-" CPU FLOAT_ARCH_STR
aoqi@0 273 " JRE (" JRE_RELEASE_VERSION "), built on " __DATE__ " " __TIME__
aoqi@0 274 " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER;
aoqi@0 275 }
aoqi@0 276
aoqi@0 277 const char *Abstract_VM_Version::vm_build_user() {
aoqi@0 278 return HOTSPOT_BUILD_USER;
aoqi@0 279 }
aoqi@0 280
aoqi@0 281 unsigned int Abstract_VM_Version::jvm_version() {
aoqi@0 282 return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |
aoqi@0 283 ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |
aoqi@0 284 (Abstract_VM_Version::vm_build_number() & 0xFF);
aoqi@0 285 }
aoqi@0 286
aoqi@0 287
aoqi@0 288 void VM_Version_init() {
aoqi@0 289 VM_Version::initialize();
aoqi@0 290
aoqi@0 291 #ifndef PRODUCT
aoqi@0 292 if (PrintMiscellaneous && Verbose) {
aoqi@0 293 os::print_cpu_info(tty);
aoqi@0 294 }
aoqi@0 295 #endif
aoqi@0 296 }
aoqi@0 297
aoqi@0 298 unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
aoqi@0 299 unsigned int num,
aoqi@0 300 unsigned int den,
aoqi@0 301 unsigned int switch_pt) {
aoqi@0 302 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
aoqi@0 303 assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
aoqi@0 304 // For very large machines, there are diminishing returns
aoqi@0 305 // for large numbers of worker threads. Instead of
aoqi@0 306 // hogging the whole system, use a fraction of the workers for every
aoqi@0 307 // processor after the first 8. For example, on a 72 cpu machine
aoqi@0 308 // and a chosen fraction of 5/8
aoqi@0 309 // use 8 + (72 - 8) * (5/8) == 48 worker threads.
tschatzl@8662 310 unsigned int ncpus = (unsigned int) os::initial_active_processor_count();
aoqi@0 311 return (ncpus <= switch_pt) ?
aoqi@0 312 ncpus :
aoqi@0 313 (switch_pt + ((ncpus - switch_pt) * num) / den);
aoqi@0 314 } else {
aoqi@0 315 return ParallelGCThreads;
aoqi@0 316 }
aoqi@0 317 }
aoqi@0 318
aoqi@0 319 unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
aoqi@0 320 return nof_parallel_worker_threads(5, 8, 8);
aoqi@0 321 }
aoqi@0 322
aoqi@0 323
aoqi@0 324 // Does not set the _initialized flag since it is
aoqi@0 325 // a global flag.
aoqi@0 326 unsigned int Abstract_VM_Version::parallel_worker_threads() {
aoqi@0 327 if (!_parallel_worker_threads_initialized) {
aoqi@0 328 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
aoqi@0 329 _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
aoqi@0 330 } else {
aoqi@0 331 _parallel_worker_threads = ParallelGCThreads;
aoqi@0 332 }
aoqi@0 333 _parallel_worker_threads_initialized = true;
aoqi@0 334 }
aoqi@0 335 return _parallel_worker_threads;
aoqi@0 336 }

mercurial