Thu, 04 Apr 2019 17:56:29 +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 XSTR(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 #else
203 #define CPU IA32_ONLY("x86") \
204 IA64_ONLY("ia64") \
205 AMD64_ONLY("amd64") \
206 MIPS64_ONLY("mips64") \
207 SPARC_ONLY("sparc")
208 #endif // ZERO
209 #endif
211 const char *Abstract_VM_Version::vm_platform_string() {
212 return OS "-" CPU;
213 }
215 const char* Abstract_VM_Version::internal_vm_info_string() {
216 #ifndef HOTSPOT_BUILD_USER
217 #define HOTSPOT_BUILD_USER unknown
218 #endif
220 #ifndef HOTSPOT_BUILD_COMPILER
221 #ifdef _MSC_VER
222 #if _MSC_VER == 1100
223 #define HOTSPOT_BUILD_COMPILER "MS VC++ 5.0"
224 #elif _MSC_VER == 1200
225 #define HOTSPOT_BUILD_COMPILER "MS VC++ 6.0"
226 #elif _MSC_VER == 1310
227 #define HOTSPOT_BUILD_COMPILER "MS VC++ 7.1 (VS2003)"
228 #elif _MSC_VER == 1400
229 #define HOTSPOT_BUILD_COMPILER "MS VC++ 8.0 (VS2005)"
230 #elif _MSC_VER == 1500
231 #define HOTSPOT_BUILD_COMPILER "MS VC++ 9.0 (VS2008)"
232 #elif _MSC_VER == 1600
233 #define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"
234 #elif _MSC_VER == 1700
235 #define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"
236 #elif _MSC_VER == 1800
237 #define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"
238 #elif _MSC_VER == 1900
239 #define HOTSPOT_BUILD_COMPILER "MS VC++ 14.0 (VS2015)"
240 #elif _MSC_VER == 1912
241 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"
242 #elif _MSC_VER == 1913
243 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"
244 #else
245 #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
246 #endif
247 #elif defined(__SUNPRO_CC)
248 #if __SUNPRO_CC == 0x420
249 #define HOTSPOT_BUILD_COMPILER "Workshop 4.2"
250 #elif __SUNPRO_CC == 0x500
251 #define HOTSPOT_BUILD_COMPILER "Workshop 5.0 compat=" XSTR(__SUNPRO_CC_COMPAT)
252 #elif __SUNPRO_CC == 0x520
253 #define HOTSPOT_BUILD_COMPILER "Workshop 5.2 compat=" XSTR(__SUNPRO_CC_COMPAT)
254 #elif __SUNPRO_CC == 0x580
255 #define HOTSPOT_BUILD_COMPILER "Workshop 5.8"
256 #elif __SUNPRO_CC == 0x590
257 #define HOTSPOT_BUILD_COMPILER "Workshop 5.9"
258 #elif __SUNPRO_CC == 0x5100
259 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u1"
260 #elif __SUNPRO_CC == 0x5120
261 #define HOTSPOT_BUILD_COMPILER "Sun Studio 12u3"
262 #else
263 #define HOTSPOT_BUILD_COMPILER "unknown Workshop:" XSTR(__SUNPRO_CC)
264 #endif
265 #elif defined(__GNUC__)
266 #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__
267 #elif defined(__IBMCPP__)
268 #define HOTSPOT_BUILD_COMPILER "xlC " XSTR(__IBMCPP__)
270 #else
271 #define HOTSPOT_BUILD_COMPILER "unknown compiler"
272 #endif
273 #endif
275 #ifndef FLOAT_ARCH
276 #if defined(__SOFTFP__)
277 #define FLOAT_ARCH_STR "-sflt"
278 #else
279 #define FLOAT_ARCH_STR ""
280 #endif
281 #else
282 #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)
283 #endif
285 return VMNAME " (" VM_RELEASE ") for " OS "-" CPU FLOAT_ARCH_STR
286 " JRE (" JRE_RELEASE_VERSION "), built on " __DATE__ " " __TIME__
287 " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER;
288 }
290 const char *Abstract_VM_Version::vm_build_user() {
291 return HOTSPOT_BUILD_USER;
292 }
294 unsigned int Abstract_VM_Version::jvm_version() {
295 return ((Abstract_VM_Version::vm_major_version() & 0xFF) << 24) |
296 ((Abstract_VM_Version::vm_minor_version() & 0xFF) << 16) |
297 (Abstract_VM_Version::vm_build_number() & 0xFF);
298 }
301 void VM_Version_init() {
302 VM_Version::initialize();
304 #ifndef PRODUCT
305 if (PrintMiscellaneous && Verbose) {
306 os::print_cpu_info(tty);
307 }
308 #endif
309 }
311 unsigned int Abstract_VM_Version::nof_parallel_worker_threads(
312 unsigned int num,
313 unsigned int den,
314 unsigned int switch_pt) {
315 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
316 assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
317 // For very large machines, there are diminishing returns
318 // for large numbers of worker threads. Instead of
319 // hogging the whole system, use a fraction of the workers for every
320 // processor after the first 8. For example, on a 72 cpu machine
321 // and a chosen fraction of 5/8
322 // use 8 + (72 - 8) * (5/8) == 48 worker threads.
323 unsigned int ncpus = (unsigned int) os::initial_active_processor_count();
324 return (ncpus <= switch_pt) ?
325 ncpus :
326 (switch_pt + ((ncpus - switch_pt) * num) / den);
327 } else {
328 return ParallelGCThreads;
329 }
330 }
332 unsigned int Abstract_VM_Version::calc_parallel_worker_threads() {
333 return nof_parallel_worker_threads(5, 8, 8);
334 }
337 // Does not set the _initialized flag since it is
338 // a global flag.
339 unsigned int Abstract_VM_Version::parallel_worker_threads() {
340 if (!_parallel_worker_threads_initialized) {
341 if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
342 _parallel_worker_threads = VM_Version::calc_parallel_worker_threads();
343 } else {
344 _parallel_worker_threads = ParallelGCThreads;
345 }
346 _parallel_worker_threads_initialized = true;
347 }
348 return _parallel_worker_threads;
349 }