Mercurial > hg > truffle
annotate src/share/vm/runtime/java.hpp @ 1162:d749b1813f40
Merge
author | trims |
---|---|
date | Fri, 15 Jan 2010 14:25:44 -0800 |
parents | d95b224e9f17 |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // Register function to be called by before_exit | |
26 extern "C" { void register_on_exit_function(void (*func)(void)) ;} | |
27 | |
28 // Execute code before all handles are released and thread is killed; prologue to vm_exit | |
29 extern void before_exit(JavaThread * thread); | |
30 | |
31 // Forced VM exit (i.e, internal error or JVM_Exit) | |
32 extern void vm_exit(int code); | |
33 | |
34 // Wrapper for ::exit() | |
35 extern void vm_direct_exit(int code); | |
36 | |
37 // Shutdown the VM but do not exit the process | |
38 extern void vm_shutdown(); | |
39 // Shutdown the VM and abort the process | |
227
8d852b81e775
6694099: Hotspot vm_exit_out_of_memory should dump core
poonam
parents:
176
diff
changeset
|
40 extern void vm_abort(bool dump_core=true); |
0 | 41 |
42 // Trigger any necessary notification of the VM being shutdown | |
43 extern void notify_vm_shutdown(); | |
44 | |
45 // VM exit if error occurs during initialization of VM | |
46 extern void vm_exit_during_initialization(Handle exception); | |
47 extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message); | |
48 extern void vm_exit_during_initialization(const char* error, const char* message = NULL); | |
49 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL); | |
50 | |
242 | 51 /** |
52 * Discovering the JDK_Version during initialization is tricky when the | |
53 * running JDK is less than JDK6. For JDK6 and greater, a "GetVersion" | |
54 * function exists in libjava.so and we simply call it during the | |
55 * 'initialize()' call to find the version. For JDKs with version < 6, no | |
56 * such call exists and we have to probe the JDK in order to determine | |
57 * the exact version. This probing cannot happen during late in | |
58 * the VM initialization process so there's a period of time during | |
59 * initialization when we don't know anything about the JDK version other than | |
60 * that it less than version 6. This is the "partially initialized" time, | |
61 * when we can answer only certain version queries (such as, is the JDK | |
62 * version greater than 5? Answer: no). Once the JDK probing occurs, we | |
63 * know the version and are considered fully initialized. | |
64 */ | |
65 class JDK_Version VALUE_OBJ_CLASS_SPEC { | |
0 | 66 friend class VMStructs; |
242 | 67 friend class Universe; |
68 friend void JDK_Version_init(); | |
0 | 69 private: |
242 | 70 |
71 static JDK_Version _current; | |
72 | |
73 // In this class, we promote the minor version of release to be the | |
74 // major version for releases >= 5 in anticipation of the JDK doing the | |
75 // same thing. For example, we represent "1.5.0" as major version 5 (we | |
76 // drop the leading 1 and use 5 as the 'major'). | |
77 | |
78 uint8_t _major; | |
79 uint8_t _minor; | |
80 uint8_t _micro; | |
81 uint8_t _update; | |
82 uint8_t _special; | |
83 uint8_t _build; | |
84 | |
85 // If partially initialized, the above fields are invalid and we know | |
86 // that we're less than major version 6. | |
87 bool _partially_initialized; | |
88 | |
89 bool _thread_park_blocker; | |
90 | |
91 bool is_valid() const { | |
92 return (_major != 0 || _partially_initialized); | |
93 } | |
94 | |
95 // initializes or partially initializes the _current static field | |
96 static void initialize(); | |
97 | |
98 // Completes initialization for a pre-JDK6 version. | |
99 static void fully_initialize(uint8_t major, uint8_t minor = 0, | |
100 uint8_t micro = 0, uint8_t update = 0); | |
0 | 101 |
102 public: | |
242 | 103 |
104 // Returns true if the the current version has only been partially initialized | |
105 static bool is_partially_initialized() { | |
106 return _current._partially_initialized; | |
107 } | |
108 | |
109 JDK_Version() : _major(0), _minor(0), _micro(0), _update(0), | |
110 _special(0), _build(0), _partially_initialized(false), | |
111 _thread_park_blocker(false) {} | |
0 | 112 |
242 | 113 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0, |
114 uint8_t update = 0, uint8_t special = 0, uint8_t build = 0, | |
115 bool thread_park_blocker = false) : | |
116 _major(major), _minor(minor), _micro(micro), _update(update), | |
117 _special(special), _build(build), _partially_initialized(false), | |
118 _thread_park_blocker(thread_park_blocker) {} | |
176
6b648fefb395
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
0
diff
changeset
|
119 |
242 | 120 // Returns the current running JDK version |
121 static JDK_Version current() { return _current; } | |
122 | |
123 // Factory methods for convenience | |
124 static JDK_Version jdk(uint8_t m) { | |
125 return JDK_Version(m); | |
126 } | |
127 | |
128 static JDK_Version jdk_update(uint8_t major, uint8_t update_number) { | |
129 return JDK_Version(major, 0, 0, update_number); | |
176
6b648fefb395
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
0
diff
changeset
|
130 } |
6b648fefb395
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
0
diff
changeset
|
131 |
242 | 132 uint8_t major_version() const { return _major; } |
133 uint8_t minor_version() const { return _minor; } | |
134 uint8_t micro_version() const { return _micro; } | |
135 uint8_t update_version() const { return _update; } | |
136 uint8_t special_update_version() const { return _special; } | |
137 uint8_t build_number() const { return _build; } | |
138 | |
139 bool supports_thread_park_blocker() const { | |
140 return _thread_park_blocker; | |
141 } | |
142 | |
143 // Performs a full ordering comparison using all fields (update, build, etc.) | |
144 int compare(const JDK_Version& other) const; | |
145 | |
146 /** | |
147 * Performs comparison using only the major version, returning negative | |
148 * if the major version of 'this' is less than the parameter, 0 if it is | |
149 * equal, and a positive value if it is greater. | |
150 */ | |
151 int compare_major(int version) const { | |
152 if (_partially_initialized) { | |
153 if (version >= 6) { | |
154 return -1; | |
155 } else { | |
156 assert(false, "Can't make this comparison during init time"); | |
157 return -1; // conservative | |
158 } | |
176
6b648fefb395
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
0
diff
changeset
|
159 } else { |
242 | 160 return major_version() - version; |
176
6b648fefb395
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
0
diff
changeset
|
161 } |
6b648fefb395
6705523: Fix for 6695506 will violate spec when used in JDK6
kamg
parents:
0
diff
changeset
|
162 } |
0 | 163 |
242 | 164 void to_string(char* buffer, size_t buflen) const; |
165 | |
166 // Convenience methods for queries on the current major/minor version | |
167 static bool is_jdk12x_version() { | |
168 return current().compare_major(2) == 0; | |
169 } | |
170 | |
171 static bool is_jdk13x_version() { | |
172 return current().compare_major(3) == 0; | |
173 } | |
174 | |
175 static bool is_jdk14x_version() { | |
176 return current().compare_major(4) == 0; | |
177 } | |
178 | |
179 static bool is_jdk15x_version() { | |
180 return current().compare_major(5) == 0; | |
181 } | |
182 | |
183 static bool is_jdk16x_version() { | |
184 return current().compare_major(6) == 0; | |
185 } | |
186 | |
187 static bool is_jdk17x_version() { | |
188 return current().compare_major(7) == 0; | |
189 } | |
190 | |
191 static bool is_gte_jdk13x_version() { | |
192 return current().compare_major(3) >= 0; | |
193 } | |
0 | 194 |
195 static bool is_gte_jdk14x_version() { | |
242 | 196 return current().compare_major(4) >= 0; |
0 | 197 } |
242 | 198 |
199 static bool is_gte_jdk15x_version() { | |
200 return current().compare_major(5) >= 0; | |
201 } | |
202 | |
0 | 203 static bool is_gte_jdk16x_version() { |
242 | 204 return current().compare_major(6) >= 0; |
0 | 205 } |
206 | |
207 static bool is_gte_jdk17x_version() { | |
242 | 208 return current().compare_major(7) >= 0; |
0 | 209 } |
210 }; |