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