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