1 /*
2 * Copyright (c) 1998, 2020, 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 */
24
25 #include "precompiled.hpp"
26 #include "compiler/compilerDefinitions.hpp"
27 #include "runtime/arguments.hpp"
28 #include "runtime/vm_version.hpp"
29 #include "utilities/globalDefinitions.hpp"
30
31 const char* Abstract_VM_Version::_s_vm_release = Abstract_VM_Version::vm_release();
32 const char* Abstract_VM_Version::_s_internal_vm_info_string = Abstract_VM_Version::internal_vm_info_string();
33
34 uint64_t Abstract_VM_Version::_features = 0;
35 const char* Abstract_VM_Version::_features_string = "";
36
37 bool Abstract_VM_Version::_supports_cx8 = false;
38 bool Abstract_VM_Version::_supports_atomic_getset4 = false;
39 bool Abstract_VM_Version::_supports_atomic_getset8 = false;
40 bool Abstract_VM_Version::_supports_atomic_getadd4 = false;
41 bool Abstract_VM_Version::_supports_atomic_getadd8 = false;
42 unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U;
43 unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0;
44 unsigned int Abstract_VM_Version::_data_cache_line_flush_size = 0;
45
46 VirtualizationType Abstract_VM_Version::_detected_virtualization = NoDetectedVirtualization;
47
48 #ifndef HOTSPOT_VERSION_STRING
49 #error HOTSPOT_VERSION_STRING must be defined
50 #endif
51
52 #ifndef VERSION_FEATURE
53 #error VERSION_FEATURE must be defined
54 #endif
55 #ifndef VERSION_INTERIM
56 #error VERSION_INTERIM must be defined
57 #endif
58 #ifndef VERSION_UPDATE
59 #error VERSION_UPDATE must be defined
60 #endif
61 #ifndef VERSION_PATCH
62 #error VERSION_PATCH must be defined
63 #endif
64 #ifndef VERSION_BUILD
65 #error VERSION_BUILD must be defined
66 #endif
67
68 #ifndef VERSION_STRING
69 #error VERSION_STRING must be defined
70 #endif
71
72 #ifndef DEBUG_LEVEL
73 #error DEBUG_LEVEL must be defined
74 #endif
75
76 #define VM_RELEASE HOTSPOT_VERSION_STRING
77
78 // HOTSPOT_VERSION_STRING equals the JDK VERSION_STRING (unless overridden
79 // in a standalone build).
80 int Abstract_VM_Version::_vm_major_version = VERSION_FEATURE;
81 int Abstract_VM_Version::_vm_minor_version = VERSION_INTERIM;
82 int Abstract_VM_Version::_vm_security_version = VERSION_UPDATE;
83 int Abstract_VM_Version::_vm_patch_version = VERSION_PATCH;
84 int Abstract_VM_Version::_vm_build_number = VERSION_BUILD;
85
86 #if defined(_LP64)
87 #define VMLP "64-Bit "
88 #else
89 #define VMLP ""
90 #endif
91
92 #ifndef VMTYPE
93 #ifdef TIERED
94 #define VMTYPE "Server"
95 #else // TIERED
96 #ifdef ZERO
97 #define VMTYPE "Zero"
98 #else // ZERO
99 #define VMTYPE COMPILER1_PRESENT("Client") \
100 COMPILER2_PRESENT("Server")
101 #endif // ZERO
102 #endif // TIERED
103 #endif
104
105 #ifndef HOTSPOT_VM_DISTRO
106 #error HOTSPOT_VM_DISTRO must be defined
107 #endif
108 #define VMNAME HOTSPOT_VM_DISTRO " " VMLP VMTYPE " VM"
109
vm_name()110 const char* Abstract_VM_Version::vm_name() {
111 return VMNAME;
112 }
113
114
vm_vendor()115 const char* Abstract_VM_Version::vm_vendor() {
116 #ifdef VENDOR
117 return VENDOR;
118 #else
119 return "Oracle Corporation";
120 #endif
121 }
122
123
vm_info_string()124 const char* Abstract_VM_Version::vm_info_string() {
125 switch (Arguments::mode()) {
126 case Arguments::_int:
127 return UseSharedSpaces ? "interpreted mode, sharing" : "interpreted mode";
128 case Arguments::_mixed:
129 if (UseSharedSpaces) {
130 if (UseAOT) {
131 return "mixed mode, aot, sharing";
132 #ifdef TIERED
133 } else if(is_client_compilation_mode_vm()) {
134 return "mixed mode, emulated-client, sharing";
135 #endif
136 } else {
137 return "mixed mode, sharing";
138 }
139 } else {
140 if (UseAOT) {
141 return "mixed mode, aot";
142 #ifdef TIERED
143 } else if(is_client_compilation_mode_vm()) {
144 return "mixed mode, emulated-client";
145 #endif
146 } else {
147 return "mixed mode";
148 }
149 }
150 case Arguments::_comp:
151 #ifdef TIERED
152 if (is_client_compilation_mode_vm()) {
153 return UseSharedSpaces ? "compiled mode, emulated-client, sharing" : "compiled mode, emulated-client";
154 }
155 #endif
156 return UseSharedSpaces ? "compiled mode, sharing" : "compiled mode";
157 };
158 ShouldNotReachHere();
159 return "";
160 }
161
162 // NOTE: do *not* use stringStream. this function is called by
163 // fatal error handler. if the crash is in native thread,
164 // stringStream cannot get resource allocated and will SEGV.
vm_release()165 const char* Abstract_VM_Version::vm_release() {
166 return VM_RELEASE;
167 }
168
169 // NOTE: do *not* use stringStream. this function is called by
170 // fatal error handlers. if the crash is in native thread,
171 // stringStream cannot get resource allocated and will SEGV.
jre_release_version()172 const char* Abstract_VM_Version::jre_release_version() {
173 return VERSION_STRING;
174 }
175
176 #define OS LINUX_ONLY("linux") \
177 WINDOWS_ONLY("windows") \
178 AIX_ONLY("aix") \
179 BSD_ONLY("bsd")
180
181 #ifndef CPU
182 #ifdef ZERO
183 #define CPU ZERO_LIBARCH
184 #elif defined(PPC64)
185 #if defined(VM_LITTLE_ENDIAN)
186 #define CPU "ppc64le"
187 #else
188 #define CPU "ppc64"
189 #endif // PPC64
190 #else
191 #define CPU AARCH64_ONLY("aarch64") \
192 AMD64_ONLY("amd64") \
193 IA32_ONLY("x86") \
194 IA64_ONLY("ia64") \
195 S390_ONLY("s390")
196 #endif // !ZERO
197 #endif // !CPU
198
vm_platform_string()199 const char *Abstract_VM_Version::vm_platform_string() {
200 return OS "-" CPU;
201 }
202
internal_vm_info_string()203 const char* Abstract_VM_Version::internal_vm_info_string() {
204 #ifndef HOTSPOT_BUILD_USER
205 #define HOTSPOT_BUILD_USER unknown
206 #endif
207
208 #ifndef HOTSPOT_BUILD_COMPILER
209 #ifdef _MSC_VER
210 #if _MSC_VER == 1600
211 #define HOTSPOT_BUILD_COMPILER "MS VC++ 10.0 (VS2010)"
212 #elif _MSC_VER == 1700
213 #define HOTSPOT_BUILD_COMPILER "MS VC++ 11.0 (VS2012)"
214 #elif _MSC_VER == 1800
215 #define HOTSPOT_BUILD_COMPILER "MS VC++ 12.0 (VS2013)"
216 #elif _MSC_VER == 1900
217 #define HOTSPOT_BUILD_COMPILER "MS VC++ 14.0 (VS2015)"
218 #elif _MSC_VER == 1911
219 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.3 (VS2017)"
220 #elif _MSC_VER == 1912
221 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.5 (VS2017)"
222 #elif _MSC_VER == 1913
223 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.6 (VS2017)"
224 #elif _MSC_VER == 1914
225 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.7 (VS2017)"
226 #elif _MSC_VER == 1915
227 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.8 (VS2017)"
228 #elif _MSC_VER == 1916
229 #define HOTSPOT_BUILD_COMPILER "MS VC++ 15.9 (VS2017)"
230 #elif _MSC_VER == 1920
231 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.0 (VS2019)"
232 #elif _MSC_VER == 1921
233 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.1 (VS2019)"
234 #elif _MSC_VER == 1922
235 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.2 (VS2019)"
236 #elif _MSC_VER == 1923
237 #define HOTSPOT_BUILD_COMPILER "MS VC++ 16.3 (VS2019)"
238 #else
239 #define HOTSPOT_BUILD_COMPILER "unknown MS VC++:" XSTR(_MSC_VER)
240 #endif
241 #elif defined(__clang_version__)
242 #define HOTSPOT_BUILD_COMPILER "clang " __VERSION__
243 #elif defined(__GNUC__)
244 #define HOTSPOT_BUILD_COMPILER "gcc " __VERSION__
245 #else
246 #define HOTSPOT_BUILD_COMPILER "unknown compiler"
247 #endif
248 #endif
249
250 #ifndef FLOAT_ARCH
251 #if defined(__SOFTFP__)
252 #define FLOAT_ARCH_STR "-sflt"
253 #else
254 #define FLOAT_ARCH_STR ""
255 #endif
256 #else
257 #define FLOAT_ARCH_STR XSTR(FLOAT_ARCH)
258 #endif
259
260 #ifndef HOTSPOT_BUILD_TIME
261 #define HOTSPOT_BUILD_TIME __DATE__ " " __TIME__
262 #endif
263
264 #define INTERNAL_VERSION_SUFFIX VM_RELEASE ")" \
265 " for " OS "-" CPU FLOAT_ARCH_STR \
266 " JRE (" VERSION_STRING "), built on " HOTSPOT_BUILD_TIME \
267 " by " XSTR(HOTSPOT_BUILD_USER) " with " HOTSPOT_BUILD_COMPILER
268
269 return strcmp(DEBUG_LEVEL, "release") == 0
270 ? VMNAME " (" INTERNAL_VERSION_SUFFIX
271 : VMNAME " (" DEBUG_LEVEL " " INTERNAL_VERSION_SUFFIX;
272 }
273
vm_build_user()274 const char *Abstract_VM_Version::vm_build_user() {
275 return HOTSPOT_BUILD_USER;
276 }
277
jdk_debug_level()278 const char *Abstract_VM_Version::jdk_debug_level() {
279 return DEBUG_LEVEL;
280 }
281
printable_jdk_debug_level()282 const char *Abstract_VM_Version::printable_jdk_debug_level() {
283 // Debug level is not printed for "release" builds
284 return strcmp(DEBUG_LEVEL, "release") == 0 ? "" : DEBUG_LEVEL " ";
285 }
286
jvm_version()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_security_version() & 0xFF) << 8) |
291 (Abstract_VM_Version::vm_build_number() & 0xFF);
292 }
293
print_matching_lines_from_file(const char * filename,outputStream * st,const char * keywords_to_match[])294 bool Abstract_VM_Version::print_matching_lines_from_file(const char* filename, outputStream* st, const char* keywords_to_match[]) {
295 char line[500];
296 FILE* fp = fopen(filename, "r");
297 if (fp == NULL) {
298 return false;
299 }
300
301 st->print_cr("Virtualization information:");
302 while (fgets(line, sizeof(line), fp) != NULL) {
303 int i = 0;
304 while (keywords_to_match[i] != NULL) {
305 if (strncmp(line, keywords_to_match[i], strlen(keywords_to_match[i])) == 0) {
306 st->print("%s", line);
307 break;
308 }
309 i++;
310 }
311 }
312 fclose(fp);
313 return true;
314 }
315