author | pliden |
Fri, 11 Apr 2014 12:29:24 +0200 | |
changeset 24094 | 5dbf1f44de18 |
parent 14289 | aec758622b4b |
child 25057 | f38210f84f8c |
permissions | -rw-r--r-- |
1 | 1 |
/* |
13963
e5b53c306fb5
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
13106
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
950
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
950
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
950
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_RUNTIME_JAVA_HPP |
26 |
#define SHARE_VM_RUNTIME_JAVA_HPP |
|
27 |
||
28 |
#include "runtime/os.hpp" |
|
29 |
||
1 | 30 |
// Register function to be called by before_exit |
31 |
extern "C" { void register_on_exit_function(void (*func)(void)) ;} |
|
32 |
||
33 |
// Execute code before all handles are released and thread is killed; prologue to vm_exit |
|
34 |
extern void before_exit(JavaThread * thread); |
|
35 |
||
36 |
// Forced VM exit (i.e, internal error or JVM_Exit) |
|
37 |
extern void vm_exit(int code); |
|
38 |
||
39 |
// Wrapper for ::exit() |
|
40 |
extern void vm_direct_exit(int code); |
|
41 |
||
42 |
// Shutdown the VM but do not exit the process |
|
43 |
extern void vm_shutdown(); |
|
44 |
// Shutdown the VM and abort the process |
|
773
01daf7c809b1
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
602
diff
changeset
|
45 |
extern void vm_abort(bool dump_core=true); |
1 | 46 |
|
47 |
// Trigger any necessary notification of the VM being shutdown |
|
48 |
extern void notify_vm_shutdown(); |
|
49 |
||
50 |
// VM exit if error occurs during initialization of VM |
|
51 |
extern void vm_exit_during_initialization(Handle exception); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7900
diff
changeset
|
52 |
extern void vm_exit_during_initialization(Symbol* exception_name, const char* message); |
1 | 53 |
extern void vm_exit_during_initialization(const char* error, const char* message = NULL); |
54 |
extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL); |
|
55 |
||
950 | 56 |
/** |
57 |
* Discovering the JDK_Version during initialization is tricky when the |
|
58 |
* running JDK is less than JDK6. For JDK6 and greater, a "GetVersion" |
|
59 |
* function exists in libjava.so and we simply call it during the |
|
60 |
* 'initialize()' call to find the version. For JDKs with version < 6, no |
|
61 |
* such call exists and we have to probe the JDK in order to determine |
|
62 |
* the exact version. This probing cannot happen during late in |
|
63 |
* the VM initialization process so there's a period of time during |
|
64 |
* initialization when we don't know anything about the JDK version other than |
|
65 |
* that it less than version 6. This is the "partially initialized" time, |
|
66 |
* when we can answer only certain version queries (such as, is the JDK |
|
67 |
* version greater than 5? Answer: no). Once the JDK probing occurs, we |
|
68 |
* know the version and are considered fully initialized. |
|
69 |
*/ |
|
70 |
class JDK_Version VALUE_OBJ_CLASS_SPEC { |
|
1 | 71 |
friend class VMStructs; |
950 | 72 |
friend class Universe; |
73 |
friend void JDK_Version_init(); |
|
1 | 74 |
private: |
950 | 75 |
|
76 |
static JDK_Version _current; |
|
13106 | 77 |
static const char* _runtime_name; |
14289
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
78 |
static const char* _runtime_version; |
950 | 79 |
|
80 |
// In this class, we promote the minor version of release to be the |
|
81 |
// major version for releases >= 5 in anticipation of the JDK doing the |
|
82 |
// same thing. For example, we represent "1.5.0" as major version 5 (we |
|
83 |
// drop the leading 1 and use 5 as the 'major'). |
|
84 |
||
85 |
uint8_t _major; |
|
86 |
uint8_t _minor; |
|
87 |
uint8_t _micro; |
|
88 |
uint8_t _update; |
|
89 |
uint8_t _special; |
|
90 |
uint8_t _build; |
|
91 |
||
92 |
// If partially initialized, the above fields are invalid and we know |
|
93 |
// that we're less than major version 6. |
|
94 |
bool _partially_initialized; |
|
95 |
||
96 |
bool _thread_park_blocker; |
|
10526
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
97 |
bool _pending_list_uses_discovered_field; |
7900
4c7fc6332f7e
6994753: Implement optional hook to a Java method at VM startup.
kevinw
parents:
7397
diff
changeset
|
98 |
bool _post_vm_init_hook_enabled; |
950 | 99 |
|
100 |
bool is_valid() const { |
|
101 |
return (_major != 0 || _partially_initialized); |
|
102 |
} |
|
103 |
||
104 |
// initializes or partially initializes the _current static field |
|
105 |
static void initialize(); |
|
106 |
||
107 |
// Completes initialization for a pre-JDK6 version. |
|
108 |
static void fully_initialize(uint8_t major, uint8_t minor = 0, |
|
109 |
uint8_t micro = 0, uint8_t update = 0); |
|
1 | 110 |
|
111 |
public: |
|
950 | 112 |
|
113 |
// Returns true if the the current version has only been partially initialized |
|
114 |
static bool is_partially_initialized() { |
|
115 |
return _current._partially_initialized; |
|
116 |
} |
|
117 |
||
118 |
JDK_Version() : _major(0), _minor(0), _micro(0), _update(0), |
|
119 |
_special(0), _build(0), _partially_initialized(false), |
|
10526
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
120 |
_thread_park_blocker(false), _post_vm_init_hook_enabled(false), |
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
121 |
_pending_list_uses_discovered_field(false) {} |
1 | 122 |
|
950 | 123 |
JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0, |
124 |
uint8_t update = 0, uint8_t special = 0, uint8_t build = 0, |
|
10526
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
125 |
bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false, |
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
126 |
bool pending_list_uses_discovered_field = false) : |
950 | 127 |
_major(major), _minor(minor), _micro(micro), _update(update), |
128 |
_special(special), _build(build), _partially_initialized(false), |
|
7900
4c7fc6332f7e
6994753: Implement optional hook to a Java method at VM startup.
kevinw
parents:
7397
diff
changeset
|
129 |
_thread_park_blocker(thread_park_blocker), |
10526
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
130 |
_post_vm_init_hook_enabled(post_vm_init_hook_enabled), |
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
131 |
_pending_list_uses_discovered_field(pending_list_uses_discovered_field) {} |
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
132 |
|
950 | 133 |
// Returns the current running JDK version |
134 |
static JDK_Version current() { return _current; } |
|
135 |
||
136 |
// Factory methods for convenience |
|
137 |
static JDK_Version jdk(uint8_t m) { |
|
138 |
return JDK_Version(m); |
|
139 |
} |
|
140 |
||
141 |
static JDK_Version jdk_update(uint8_t major, uint8_t update_number) { |
|
142 |
return JDK_Version(major, 0, 0, update_number); |
|
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
143 |
} |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
144 |
|
950 | 145 |
uint8_t major_version() const { return _major; } |
146 |
uint8_t minor_version() const { return _minor; } |
|
147 |
uint8_t micro_version() const { return _micro; } |
|
148 |
uint8_t update_version() const { return _update; } |
|
149 |
uint8_t special_update_version() const { return _special; } |
|
150 |
uint8_t build_number() const { return _build; } |
|
151 |
||
152 |
bool supports_thread_park_blocker() const { |
|
153 |
return _thread_park_blocker; |
|
154 |
} |
|
7900
4c7fc6332f7e
6994753: Implement optional hook to a Java method at VM startup.
kevinw
parents:
7397
diff
changeset
|
155 |
bool post_vm_init_hook_enabled() const { |
4c7fc6332f7e
6994753: Implement optional hook to a Java method at VM startup.
kevinw
parents:
7397
diff
changeset
|
156 |
return _post_vm_init_hook_enabled; |
4c7fc6332f7e
6994753: Implement optional hook to a Java method at VM startup.
kevinw
parents:
7397
diff
changeset
|
157 |
} |
10526
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
158 |
// For compatibility wrt pre-4965777 JDK's |
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
159 |
bool pending_list_uses_discovered_field() const { |
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
160 |
return _pending_list_uses_discovered_field; |
3e92f211533f
4965777: GC changes to support use of discovered field for pending references
ysr
parents:
8076
diff
changeset
|
161 |
} |
950 | 162 |
|
163 |
// Performs a full ordering comparison using all fields (update, build, etc.) |
|
164 |
int compare(const JDK_Version& other) const; |
|
165 |
||
166 |
/** |
|
167 |
* Performs comparison using only the major version, returning negative |
|
168 |
* if the major version of 'this' is less than the parameter, 0 if it is |
|
169 |
* equal, and a positive value if it is greater. |
|
170 |
*/ |
|
171 |
int compare_major(int version) const { |
|
172 |
if (_partially_initialized) { |
|
173 |
if (version >= 6) { |
|
174 |
return -1; |
|
175 |
} else { |
|
176 |
assert(false, "Can't make this comparison during init time"); |
|
177 |
return -1; // conservative |
|
178 |
} |
|
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
179 |
} else { |
950 | 180 |
return major_version() - version; |
602
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
181 |
} |
92e03692ddd6
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
1
diff
changeset
|
182 |
} |
1 | 183 |
|
950 | 184 |
void to_string(char* buffer, size_t buflen) const; |
185 |
||
13106 | 186 |
static const char* runtime_name() { |
187 |
return _runtime_name; |
|
188 |
} |
|
189 |
static void set_runtime_name(const char* name) { |
|
190 |
_runtime_name = name; |
|
191 |
} |
|
192 |
||
14289
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
193 |
static const char* runtime_version() { |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
194 |
return _runtime_version; |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
195 |
} |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
196 |
static void set_runtime_version(const char* version) { |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
197 |
_runtime_version = version; |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
198 |
} |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13963
diff
changeset
|
199 |
|
950 | 200 |
// Convenience methods for queries on the current major/minor version |
201 |
static bool is_jdk12x_version() { |
|
202 |
return current().compare_major(2) == 0; |
|
203 |
} |
|
204 |
||
205 |
static bool is_jdk13x_version() { |
|
206 |
return current().compare_major(3) == 0; |
|
207 |
} |
|
208 |
||
209 |
static bool is_jdk14x_version() { |
|
210 |
return current().compare_major(4) == 0; |
|
211 |
} |
|
212 |
||
213 |
static bool is_jdk15x_version() { |
|
214 |
return current().compare_major(5) == 0; |
|
215 |
} |
|
216 |
||
217 |
static bool is_jdk16x_version() { |
|
218 |
return current().compare_major(6) == 0; |
|
219 |
} |
|
220 |
||
221 |
static bool is_jdk17x_version() { |
|
222 |
return current().compare_major(7) == 0; |
|
223 |
} |
|
224 |
||
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
225 |
static bool is_jdk18x_version() { |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
226 |
return current().compare_major(8) == 0; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
227 |
} |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
228 |
|
950 | 229 |
static bool is_gte_jdk13x_version() { |
230 |
return current().compare_major(3) >= 0; |
|
231 |
} |
|
1 | 232 |
|
233 |
static bool is_gte_jdk14x_version() { |
|
950 | 234 |
return current().compare_major(4) >= 0; |
1 | 235 |
} |
950 | 236 |
|
237 |
static bool is_gte_jdk15x_version() { |
|
238 |
return current().compare_major(5) >= 0; |
|
239 |
} |
|
240 |
||
1 | 241 |
static bool is_gte_jdk16x_version() { |
950 | 242 |
return current().compare_major(6) >= 0; |
1 | 243 |
} |
244 |
||
245 |
static bool is_gte_jdk17x_version() { |
|
950 | 246 |
return current().compare_major(7) >= 0; |
1 | 247 |
} |
12630
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
248 |
|
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
249 |
static bool is_gte_jdk18x_version() { |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
250 |
return current().compare_major(8) >= 0; |
ddf6ee008138
7166894: Add gc cause to GC logging for all collectors
brutisso
parents:
10526
diff
changeset
|
251 |
} |
1 | 252 |
}; |
7397 | 253 |
|
254 |
#endif // SHARE_VM_RUNTIME_JAVA_HPP |