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