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