Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/runtime/java.hpp
32285 views
/*1* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_RUNTIME_JAVA_HPP25#define SHARE_VM_RUNTIME_JAVA_HPP2627#include "runtime/os.hpp"2829// Register function to be called by before_exit30extern "C" { void register_on_exit_function(void (*func)(void)) ;}3132// Execute code before all handles are released and thread is killed; prologue to vm_exit33extern void before_exit(JavaThread * thread);3435// Forced VM exit (i.e, internal error or JVM_Exit)36extern void vm_exit(int code);3738// Wrapper for ::exit()39extern void vm_direct_exit(int code);4041// Shutdown the VM but do not exit the process42extern void vm_shutdown();43// Shutdown the VM and abort the process44extern void vm_abort(bool dump_core=true);4546// Trigger any necessary notification of the VM being shutdown47extern void notify_vm_shutdown();4849// VM exit if error occurs during initialization of VM50extern void vm_exit_during_initialization(Handle exception);51extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);52extern void vm_exit_during_initialization(const char* error, const char* message = NULL);53extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);5455/**56* Discovering the JDK_Version during initialization is tricky when the57* running JDK is less than JDK6. For JDK6 and greater, a "GetVersion"58* function exists in libjava.so and we simply call it during the59* 'initialize()' call to find the version. For JDKs with version < 6, no60* such call exists and we have to probe the JDK in order to determine61* the exact version. This probing cannot happen during late in62* the VM initialization process so there's a period of time during63* initialization when we don't know anything about the JDK version other than64* that it less than version 6. This is the "partially initialized" time,65* when we can answer only certain version queries (such as, is the JDK66* version greater than 5? Answer: no). Once the JDK probing occurs, we67* know the version and are considered fully initialized.68*/69class JDK_Version VALUE_OBJ_CLASS_SPEC {70friend class VMStructs;71friend class Universe;72friend void JDK_Version_init();73private:7475static JDK_Version _current;76static const char* _runtime_name;77static const char* _runtime_version;7879// In this class, we promote the minor version of release to be the80// major version for releases >= 5 in anticipation of the JDK doing the81// same thing. For example, we represent "1.5.0" as major version 5 (we82// drop the leading 1 and use 5 as the 'major').8384uint8_t _major;85uint8_t _minor;86uint8_t _micro;87uint16_t _update;88uint8_t _special;89uint8_t _build;9091// If partially initialized, the above fields are invalid and we know92// that we're less than major version 6.93bool _partially_initialized;9495bool _thread_park_blocker;96bool _pending_list_uses_discovered_field;97bool _post_vm_init_hook_enabled;9899bool is_valid() const {100return (_major != 0 || _partially_initialized);101}102103// initializes or partially initializes the _current static field104static void initialize();105106// Completes initialization for a pre-JDK6 version.107static void fully_initialize(uint8_t major, uint8_t minor = 0,108uint8_t micro = 0, uint8_t update = 0);109110public:111112// Returns true if the the current version has only been partially initialized113static bool is_partially_initialized() {114return _current._partially_initialized;115}116117JDK_Version() : _major(0), _minor(0), _micro(0), _update(0),118_special(0), _build(0), _partially_initialized(false),119_thread_park_blocker(false), _post_vm_init_hook_enabled(false),120_pending_list_uses_discovered_field(false) {}121122JDK_Version(uint8_t major, uint8_t minor = 0, uint8_t micro = 0,123uint16_t update = 0, uint8_t special = 0, uint8_t build = 0,124bool thread_park_blocker = false, bool post_vm_init_hook_enabled = false,125bool pending_list_uses_discovered_field = false) :126_major(major), _minor(minor), _micro(micro), _update(update),127_special(special), _build(build), _partially_initialized(false),128_thread_park_blocker(thread_park_blocker),129_post_vm_init_hook_enabled(post_vm_init_hook_enabled),130_pending_list_uses_discovered_field(pending_list_uses_discovered_field) {}131132// Returns the current running JDK version133static JDK_Version current() { return _current; }134135// Factory methods for convenience136static JDK_Version jdk(uint8_t m) {137return JDK_Version(m);138}139140static JDK_Version jdk_update(uint8_t major, uint16_t update_number) {141return JDK_Version(major, 0, 0, update_number);142}143144uint8_t major_version() const { return _major; }145uint8_t minor_version() const { return _minor; }146uint8_t micro_version() const { return _micro; }147uint16_t update_version() const { return _update; }148uint8_t special_update_version() const { return _special; }149uint8_t build_number() const { return _build; }150151bool supports_thread_park_blocker() const {152return _thread_park_blocker;153}154bool post_vm_init_hook_enabled() const {155return _post_vm_init_hook_enabled;156}157// For compatibility wrt pre-4965777 JDK's158bool pending_list_uses_discovered_field() const {159return _pending_list_uses_discovered_field;160}161162// Performs a full ordering comparison using all fields (update, build, etc.)163int compare(const JDK_Version& other) const;164165/**166* Performs comparison using only the major version, returning negative167* if the major version of 'this' is less than the parameter, 0 if it is168* equal, and a positive value if it is greater.169*/170int compare_major(int version) const {171if (_partially_initialized) {172if (version >= 6) {173return -1;174} else {175assert(false, "Can't make this comparison during init time");176return -1; // conservative177}178} else {179return major_version() - version;180}181}182183void to_string(char* buffer, size_t buflen) const;184185static const char* runtime_name() {186return _runtime_name;187}188static void set_runtime_name(const char* name) {189_runtime_name = name;190}191192static const char* runtime_version() {193return _runtime_version;194}195static void set_runtime_version(const char* version) {196_runtime_version = version;197}198199// Convenience methods for queries on the current major/minor version200static bool is_jdk12x_version() {201return current().compare_major(2) == 0;202}203204static bool is_jdk13x_version() {205return current().compare_major(3) == 0;206}207208static bool is_jdk14x_version() {209return current().compare_major(4) == 0;210}211212static bool is_jdk15x_version() {213return current().compare_major(5) == 0;214}215216static bool is_jdk16x_version() {217return current().compare_major(6) == 0;218}219220static bool is_jdk17x_version() {221return current().compare_major(7) == 0;222}223224static bool is_jdk18x_version() {225return current().compare_major(8) == 0;226}227228static bool is_gte_jdk13x_version() {229return current().compare_major(3) >= 0;230}231232static bool is_gte_jdk14x_version() {233return current().compare_major(4) >= 0;234}235236static bool is_gte_jdk15x_version() {237return current().compare_major(5) >= 0;238}239240static bool is_gte_jdk16x_version() {241return current().compare_major(6) >= 0;242}243244static bool is_gte_jdk17x_version() {245return current().compare_major(7) >= 0;246}247248static bool is_gte_jdk18x_version() {249return current().compare_major(8) >= 0;250}251};252253#endif // SHARE_VM_RUNTIME_JAVA_HPP254255256