src/share/vm/runtime/java.hpp

Fri, 24 Jun 2016 17:12:13 +0800

author
aoqi<aoqi@loongson.cn>
date
Fri, 24 Jun 2016 17:12:13 +0800
changeset 25
873fd82b133d
parent 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

[Code Reorganization] Removed GC related modifications made by Loongson, for example, UseOldNUMA.

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

mercurial