src/share/vm/runtime/java.hpp

Tue, 05 Nov 2013 17:38:04 -0800

author
kvn
date
Tue, 05 Nov 2013 17:38:04 -0800
changeset 6472
2b8e28fdf503
parent 4232
a1b8cf9cf970
child 6876
710a3c8b516e
child 9915
26ffadc256e1
permissions
-rw-r--r--

Merge

duke@435 1 /*
mikael@4153 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_RUNTIME_JAVA_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_JAVA_HPP
stefank@2314 27
stefank@2314 28 #include "runtime/os.hpp"
stefank@2314 29
duke@435 30 // Register function to be called by before_exit
duke@435 31 extern "C" { void register_on_exit_function(void (*func)(void)) ;}
duke@435 32
duke@435 33 // Execute code before all handles are released and thread is killed; prologue to vm_exit
duke@435 34 extern void before_exit(JavaThread * thread);
duke@435 35
duke@435 36 // Forced VM exit (i.e, internal error or JVM_Exit)
duke@435 37 extern void vm_exit(int code);
duke@435 38
duke@435 39 // Wrapper for ::exit()
duke@435 40 extern void vm_direct_exit(int code);
duke@435 41
duke@435 42 // Shutdown the VM but do not exit the process
duke@435 43 extern void vm_shutdown();
duke@435 44 // Shutdown the VM and abort the process
poonam@662 45 extern void vm_abort(bool dump_core=true);
duke@435 46
duke@435 47 // Trigger any necessary notification of the VM being shutdown
duke@435 48 extern void notify_vm_shutdown();
duke@435 49
duke@435 50 // VM exit if error occurs during initialization of VM
duke@435 51 extern void vm_exit_during_initialization(Handle exception);
coleenp@2497 52 extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
duke@435 53 extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
duke@435 54 extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
duke@435 55
kamg@677 56 /**
kamg@677 57 * Discovering the JDK_Version during initialization is tricky when the
kamg@677 58 * running JDK is less than JDK6. For JDK6 and greater, a "GetVersion"
kamg@677 59 * function exists in libjava.so and we simply call it during the
kamg@677 60 * 'initialize()' call to find the version. For JDKs with version < 6, no
kamg@677 61 * such call exists and we have to probe the JDK in order to determine
kamg@677 62 * the exact version. This probing cannot happen during late in
kamg@677 63 * the VM initialization process so there's a period of time during
kamg@677 64 * initialization when we don't know anything about the JDK version other than
kamg@677 65 * that it less than version 6. This is the "partially initialized" time,
kamg@677 66 * when we can answer only certain version queries (such as, is the JDK
kamg@677 67 * version greater than 5? Answer: no). Once the JDK probing occurs, we
kamg@677 68 * know the version and are considered fully initialized.
kamg@677 69 */
kamg@677 70 class JDK_Version VALUE_OBJ_CLASS_SPEC {
duke@435 71 friend class VMStructs;
kamg@677 72 friend class Universe;
kamg@677 73 friend void JDK_Version_init();
duke@435 74 private:
kamg@677 75
kamg@677 76 static JDK_Version _current;
twisti@3884 77 static const char* _runtime_name;
sla@4232 78 static const char* _runtime_version;
kamg@677 79
kamg@677 80 // In this class, we promote the minor version of release to be the
kamg@677 81 // major version for releases >= 5 in anticipation of the JDK doing the
kamg@677 82 // same thing. For example, we represent "1.5.0" as major version 5 (we
kamg@677 83 // drop the leading 1 and use 5 as the 'major').
kamg@677 84
kamg@677 85 uint8_t _major;
kamg@677 86 uint8_t _minor;
kamg@677 87 uint8_t _micro;
kamg@677 88 uint8_t _update;
kamg@677 89 uint8_t _special;
kamg@677 90 uint8_t _build;
kamg@677 91
kamg@677 92 // If partially initialized, the above fields are invalid and we know
kamg@677 93 // that we're less than major version 6.
kamg@677 94 bool _partially_initialized;
kamg@677 95
kamg@677 96 bool _thread_park_blocker;
ysr@3117 97 bool _pending_list_uses_discovered_field;
kevinw@2449 98 bool _post_vm_init_hook_enabled;
kamg@677 99
kamg@677 100 bool is_valid() const {
kamg@677 101 return (_major != 0 || _partially_initialized);
kamg@677 102 }
kamg@677 103
kamg@677 104 // initializes or partially initializes the _current static field
kamg@677 105 static void initialize();
kamg@677 106
kamg@677 107 // Completes initialization for a pre-JDK6 version.
kamg@677 108 static void fully_initialize(uint8_t major, uint8_t minor = 0,
kamg@677 109 uint8_t micro = 0, uint8_t update = 0);
duke@435 110
duke@435 111 public:
duke@435 112
kamg@677 113 // Returns true if the the current version has only been partially initialized
kamg@677 114 static bool is_partially_initialized() {
kamg@677 115 return _current._partially_initialized;
kamg@677 116 }
kamg@611 117
kamg@677 118 JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),
kamg@677 119 _special(0), _build(0), _partially_initialized(false),
ysr@3117 120 _thread_park_blocker(false), _post_vm_init_hook_enabled(false),
ysr@3117 121 _pending_list_uses_discovered_field(false) {}
kamg@677 122
kamg@677 123 JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,
kamg@677 124 uint8_t update = 0, uint8_t special = 0, uint8_t build = 0,
ysr@3117 125 bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false,
ysr@3117 126 bool pending_list_uses_discovered_field = false) :
kamg@677 127 _major(major), _minor(minor), _micro(micro), _update(update),
kamg@677 128 _special(special), _build(build), _partially_initialized(false),
kevinw@2449 129 _thread_park_blocker(thread_park_blocker),
ysr@3117 130 _post_vm_init_hook_enabled(post_vm_init_hook_enabled),
ysr@3117 131 _pending_list_uses_discovered_field(pending_list_uses_discovered_field) {}
kamg@677 132
kamg@677 133 // Returns the current running JDK version
kamg@677 134 static JDK_Version current() { return _current; }
kamg@677 135
kamg@677 136 // Factory methods for convenience
kamg@677 137 static JDK_Version jdk(uint8_t m) {
kamg@677 138 return JDK_Version(m);
kamg@677 139 }
kamg@677 140
kamg@677 141 static JDK_Version jdk_update(uint8_t major, uint8_t update_number) {
kamg@677 142 return JDK_Version(major, 0, 0, update_number);
kamg@677 143 }
kamg@677 144
kamg@677 145 uint8_t major_version() const { return _major; }
kamg@677 146 uint8_t minor_version() const { return _minor; }
kamg@677 147 uint8_t micro_version() const { return _micro; }
kamg@677 148 uint8_t update_version() const { return _update; }
kamg@677 149 uint8_t special_update_version() const { return _special; }
kamg@677 150 uint8_t build_number() const { return _build; }
kamg@677 151
kamg@677 152 bool supports_thread_park_blocker() const {
kamg@677 153 return _thread_park_blocker;
kamg@677 154 }
kevinw@2449 155 bool post_vm_init_hook_enabled() const {
kevinw@2449 156 return _post_vm_init_hook_enabled;
kevinw@2449 157 }
ysr@3117 158 // For compatibility wrt pre-4965777 JDK's
ysr@3117 159 bool pending_list_uses_discovered_field() const {
ysr@3117 160 return _pending_list_uses_discovered_field;
ysr@3117 161 }
kamg@677 162
kamg@677 163 // Performs a full ordering comparison using all fields (update, build, etc.)
kamg@677 164 int compare(const JDK_Version& other) const;
kamg@677 165
kamg@677 166 /**
kamg@677 167 * Performs comparison using only the major version, returning negative
kamg@677 168 * if the major version of 'this' is less than the parameter, 0 if it is
kamg@677 169 * equal, and a positive value if it is greater.
kamg@677 170 */
kamg@677 171 int compare_major(int version) const {
kamg@677 172 if (_partially_initialized) {
kamg@677 173 if (version >= 6) {
kamg@677 174 return -1;
kamg@677 175 } else {
kamg@677 176 assert(false, "Can't make this comparison during init time");
kamg@677 177 return -1; // conservative
kamg@677 178 }
kamg@611 179 } else {
kamg@677 180 return major_version() - version;
kamg@611 181 }
kamg@611 182 }
kamg@611 183
kamg@677 184 void to_string(char* buffer, size_t buflen) const;
kamg@677 185
twisti@3884 186 static const char* runtime_name() {
twisti@3884 187 return _runtime_name;
twisti@3884 188 }
twisti@3884 189 static void set_runtime_name(const char* name) {
twisti@3884 190 _runtime_name = name;
twisti@3884 191 }
twisti@3884 192
sla@4232 193 static const char* runtime_version() {
sla@4232 194 return _runtime_version;
sla@4232 195 }
sla@4232 196 static void set_runtime_version(const char* version) {
sla@4232 197 _runtime_version = version;
sla@4232 198 }
sla@4232 199
kamg@677 200 // Convenience methods for queries on the current major/minor version
kamg@677 201 static bool is_jdk12x_version() {
kamg@677 202 return current().compare_major(2) == 0;
kamg@611 203 }
duke@435 204
kamg@677 205 static bool is_jdk13x_version() {
kamg@677 206 return current().compare_major(3) == 0;
kamg@677 207 }
kamg@677 208
kamg@677 209 static bool is_jdk14x_version() {
kamg@677 210 return current().compare_major(4) == 0;
kamg@677 211 }
kamg@677 212
kamg@677 213 static bool is_jdk15x_version() {
kamg@677 214 return current().compare_major(5) == 0;
kamg@677 215 }
kamg@677 216
kamg@677 217 static bool is_jdk16x_version() {
kamg@677 218 return current().compare_major(6) == 0;
kamg@677 219 }
kamg@677 220
kamg@677 221 static bool is_jdk17x_version() {
kamg@677 222 return current().compare_major(7) == 0;
kamg@677 223 }
kamg@677 224
brutisso@3767 225 static bool is_jdk18x_version() {
brutisso@3767 226 return current().compare_major(8) == 0;
brutisso@3767 227 }
brutisso@3767 228
kamg@677 229 static bool is_gte_jdk13x_version() {
kamg@677 230 return current().compare_major(3) >= 0;
kamg@677 231 }
duke@435 232
duke@435 233 static bool is_gte_jdk14x_version() {
kamg@677 234 return current().compare_major(4) >= 0;
duke@435 235 }
kamg@677 236
duke@435 237 static bool is_gte_jdk15x_version() {
kamg@677 238 return current().compare_major(5) >= 0;
duke@435 239 }
kamg@677 240
duke@435 241 static bool is_gte_jdk16x_version() {
kamg@677 242 return current().compare_major(6) >= 0;
duke@435 243 }
duke@435 244
duke@435 245 static bool is_gte_jdk17x_version() {
kamg@677 246 return current().compare_major(7) >= 0;
duke@435 247 }
brutisso@3767 248
brutisso@3767 249 static bool is_gte_jdk18x_version() {
brutisso@3767 250 return current().compare_major(8) >= 0;
brutisso@3767 251 }
duke@435 252 };
stefank@2314 253
stefank@2314 254 #endif // SHARE_VM_RUNTIME_JAVA_HPP

mercurial