hotspot/src/share/vm/runtime/java.hpp
author sbohne
Tue, 04 Mar 2008 09:44:24 -0500
changeset 231 3cfeeae32993
parent 1 489c9b5090e2
child 602 92e03692ddd6
permissions -rw-r--r--
6666698: EnableBiasedLocking with BiasedLockingStartupDelay can block Watcher thread Summary: Enqueue VM_EnableBiasedLocking operation asynchronously Reviewed-by: never, xlu, kbr, acorn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Register function to be called by before_exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
extern "C" { void register_on_exit_function(void (*func)(void)) ;}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// Execute code before all handles are released and thread is killed; prologue to vm_exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
extern void before_exit(JavaThread * thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Forced VM exit (i.e, internal error or JVM_Exit)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
extern void vm_exit(int code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// Wrapper for ::exit()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
extern void vm_direct_exit(int code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Shutdown the VM but do not exit the process
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
extern void vm_shutdown();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// Shutdown the VM and abort the process
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
extern void vm_abort();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// Trigger any necessary notification of the VM being shutdown
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
extern void notify_vm_shutdown();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// VM exit if error occurs during initialization of VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
extern void vm_exit_during_initialization(Handle exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class JDK_Version : AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  static jdk_version_info _version_info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  static bool             _pre_jdk16_version;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  static int              _jdk_version;  // JDK version number representing the release
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
                                         //  i.e. n in 1.n.x (= jdk_minor_version())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  static void initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  static int  jdk_major_version() { return JDK_VERSION_MAJOR(_version_info.jdk_version); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  static int  jdk_minor_version() { return JDK_VERSION_MINOR(_version_info.jdk_version); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  static int  jdk_micro_version() { return JDK_VERSION_MICRO(_version_info.jdk_version); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  static int  jdk_build_number()  { return JDK_VERSION_BUILD(_version_info.jdk_version); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  static bool is_pre_jdk16_version()        { return _pre_jdk16_version; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  static bool is_jdk12x_version()           { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 2; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  static bool is_jdk13x_version()           { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 3; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  static bool is_jdk14x_version()           { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 4; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  static bool is_jdk15x_version()           { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 5; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  static bool is_jdk16x_version()           { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 6; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  static bool is_jdk17x_version()           { assert(is_jdk_version_initialized(), "must have been initialized"); return _jdk_version == 7; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  static bool supports_thread_park_blocker() { return _version_info.thread_park_blocker; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  static bool is_gte_jdk14x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    // Keep the semantics of this that the version number is >= 1.4
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    assert(is_jdk_version_initialized(), "Not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    return _jdk_version >= 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  static bool is_gte_jdk15x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    // Keep the semantics of this that the version number is >= 1.5
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    assert(is_jdk_version_initialized(), "Not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    return _jdk_version >= 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  static bool is_gte_jdk16x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    // Keep the semantics of this that the version number is >= 1.6
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    assert(is_jdk_version_initialized(), "Not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    return _jdk_version >= 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  static bool is_gte_jdk17x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    // Keep the semantics of this that the version number is >= 1.7
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    assert(is_jdk_version_initialized(), "Not initialized");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    return _jdk_version >= 7;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  static bool is_jdk_version_initialized() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    return _jdk_version > 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // These methods are defined to deal with pre JDK 1.6 versions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  static void set_jdk12x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    _jdk_version = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    _version_info.jdk_version = (1 << 24) | (2 << 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  static void set_jdk13x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    _jdk_version = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    _version_info.jdk_version = (1 << 24) | (3 << 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  static void set_jdk14x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    _jdk_version = 4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    _version_info.jdk_version = (1 << 24) | (4 << 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  static void set_jdk15x_version() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    assert(_pre_jdk16_version && !is_jdk_version_initialized(), "must not initialize");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    _jdk_version = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    _version_info.jdk_version = (1 << 24) | (5 << 16);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
};