Wed, 16 Nov 2011 20:38:24 -0500
7110017: is_headless_jre should be updated to reflect the new location of awt toolkit libraries
Reviewed-by: dholmes, dsamersoff
Contributed-by: Chris Hegarty <chris.hegarty@oracle.com>
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, 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 OS_SOLARIS_VM_OS_SOLARIS_HPP |
stefank@2314 | 26 | #define OS_SOLARIS_VM_OS_SOLARIS_HPP |
stefank@2314 | 27 | |
duke@435 | 28 | // Solaris_OS defines the interface to Solaris operating systems |
duke@435 | 29 | |
duke@435 | 30 | class Solaris { |
duke@435 | 31 | friend class os; |
duke@435 | 32 | |
duke@435 | 33 | private: |
duke@435 | 34 | |
duke@435 | 35 | // Support for "new" libthread APIs for getting & setting thread context (2.8) |
duke@435 | 36 | #define TRS_VALID 0 |
duke@435 | 37 | #define TRS_NONVOLATILE 1 |
duke@435 | 38 | #define TRS_LWPID 2 |
duke@435 | 39 | #define TRS_INVALID 3 |
duke@435 | 40 | |
duke@435 | 41 | // _T2_libthread is true if we believe we are running with the newer |
duke@435 | 42 | // SunSoft lib/lwp/libthread: default Solaris 9, available Solaris 8 |
duke@435 | 43 | // which is a lightweight libthread that also supports all T1 |
duke@435 | 44 | static bool _T2_libthread; |
duke@435 | 45 | // These refer to new libthread interface functions |
duke@435 | 46 | // They get intialized if we dynamically detect new libthread |
duke@435 | 47 | static int_fnP_thread_t_iP_uP_stack_tP_gregset_t _thr_getstate; |
duke@435 | 48 | static int_fnP_thread_t_i_gregset_t _thr_setstate; |
duke@435 | 49 | static int_fnP_thread_t_i _thr_setmutator; |
duke@435 | 50 | static int_fnP_thread_t _thr_suspend_mutator; |
duke@435 | 51 | static int_fnP_thread_t _thr_continue_mutator; |
duke@435 | 52 | // libthread_init sets the above, if the new functionality is detected |
duke@435 | 53 | |
duke@435 | 54 | // initialized to libthread or lwp synchronization primitives depending on UseLWPSychronization |
duke@435 | 55 | static int_fnP_mutex_tP _mutex_lock; |
duke@435 | 56 | static int_fnP_mutex_tP _mutex_trylock; |
duke@435 | 57 | static int_fnP_mutex_tP _mutex_unlock; |
duke@435 | 58 | static int_fnP_mutex_tP_i_vP _mutex_init; |
duke@435 | 59 | static int_fnP_mutex_tP _mutex_destroy; |
duke@435 | 60 | static int _mutex_scope; |
duke@435 | 61 | |
duke@435 | 62 | static int_fnP_cond_tP_mutex_tP_timestruc_tP _cond_timedwait; |
duke@435 | 63 | static int_fnP_cond_tP_mutex_tP _cond_wait; |
duke@435 | 64 | static int_fnP_cond_tP _cond_signal; |
duke@435 | 65 | static int_fnP_cond_tP _cond_broadcast; |
duke@435 | 66 | static int_fnP_cond_tP_i_vP _cond_init; |
duke@435 | 67 | static int_fnP_cond_tP _cond_destroy; |
duke@435 | 68 | static int _cond_scope; |
duke@435 | 69 | |
duke@435 | 70 | typedef uintptr_t lgrp_cookie_t; |
duke@435 | 71 | typedef id_t lgrp_id_t; |
iveresov@579 | 72 | typedef int lgrp_rsrc_t; |
duke@435 | 73 | typedef enum lgrp_view { |
duke@435 | 74 | LGRP_VIEW_CALLER, /* what's available to the caller */ |
duke@435 | 75 | LGRP_VIEW_OS /* what's available to operating system */ |
duke@435 | 76 | } lgrp_view_t; |
duke@435 | 77 | |
twisti@1076 | 78 | typedef uint_t (*getisax_func_t)(uint32_t* array, uint_t n); |
twisti@1076 | 79 | |
duke@435 | 80 | typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id); |
duke@435 | 81 | typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view); |
duke@435 | 82 | typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie); |
duke@435 | 83 | typedef lgrp_id_t (*lgrp_root_func_t)(lgrp_cookie_t cookie); |
duke@435 | 84 | typedef int (*lgrp_children_func_t)(lgrp_cookie_t cookie, lgrp_id_t parent, |
duke@435 | 85 | lgrp_id_t *lgrp_array, uint_t lgrp_array_size); |
iveresov@579 | 86 | typedef int (*lgrp_resources_func_t)(lgrp_cookie_t cookie, lgrp_id_t lgrp, |
iveresov@579 | 87 | lgrp_id_t *lgrp_array, uint_t lgrp_array_size, |
iveresov@579 | 88 | lgrp_rsrc_t type); |
duke@435 | 89 | typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie); |
duke@435 | 90 | typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie); |
duke@435 | 91 | typedef int (*meminfo_func_t)(const uint64_t inaddr[], int addr_count, |
duke@435 | 92 | const uint_t info_req[], int info_count, |
duke@435 | 93 | uint64_t outdata[], uint_t validity[]); |
duke@435 | 94 | |
twisti@1076 | 95 | static getisax_func_t _getisax; |
twisti@1076 | 96 | |
duke@435 | 97 | static lgrp_home_func_t _lgrp_home; |
duke@435 | 98 | static lgrp_init_func_t _lgrp_init; |
duke@435 | 99 | static lgrp_fini_func_t _lgrp_fini; |
duke@435 | 100 | static lgrp_root_func_t _lgrp_root; |
duke@435 | 101 | static lgrp_children_func_t _lgrp_children; |
iveresov@579 | 102 | static lgrp_resources_func_t _lgrp_resources; |
duke@435 | 103 | static lgrp_nlgrps_func_t _lgrp_nlgrps; |
duke@435 | 104 | static lgrp_cookie_stale_func_t _lgrp_cookie_stale; |
duke@435 | 105 | static lgrp_cookie_t _lgrp_cookie; |
duke@435 | 106 | |
duke@435 | 107 | static meminfo_func_t _meminfo; |
duke@435 | 108 | |
duke@435 | 109 | // Large Page Support--mpss. |
duke@435 | 110 | static bool set_mpss_range(caddr_t start, size_t bytes, size_t align); |
duke@435 | 111 | |
duke@435 | 112 | static void init_thread_fpu_state(void); |
duke@435 | 113 | |
duke@435 | 114 | static void try_enable_extended_io(); |
duke@435 | 115 | |
duke@435 | 116 | // For signal-chaining |
duke@435 | 117 | static unsigned long sigs; // mask of signals that have |
duke@435 | 118 | // preinstalled signal handlers |
duke@435 | 119 | static struct sigaction *(*get_signal_action)(int); |
duke@435 | 120 | static struct sigaction *get_preinstalled_handler(int); |
duke@435 | 121 | static int (*get_libjsig_version)(); |
duke@435 | 122 | static void save_preinstalled_handler(int, struct sigaction&); |
duke@435 | 123 | static void check_signal_handler(int sig); |
duke@435 | 124 | // For overridable signals |
duke@435 | 125 | static int _SIGinterrupt; // user-overridable INTERRUPT_SIGNAL |
duke@435 | 126 | static int _SIGasync; // user-overridable ASYNC_SIGNAL |
duke@435 | 127 | static void set_SIGinterrupt(int newsig) { _SIGinterrupt = newsig; } |
duke@435 | 128 | static void set_SIGasync(int newsig) { _SIGasync = newsig; } |
duke@435 | 129 | |
duke@435 | 130 | |
duke@435 | 131 | public: |
duke@435 | 132 | // Large Page Support--ISM. |
duke@435 | 133 | static bool largepage_range(char* addr, size_t size); |
duke@435 | 134 | |
duke@435 | 135 | static int SIGinterrupt() { return _SIGinterrupt; } |
duke@435 | 136 | static int SIGasync() { return _SIGasync; } |
duke@435 | 137 | static address handler_start, handler_end; // start and end pc of thr_sighndlrinfo |
duke@435 | 138 | |
duke@435 | 139 | static bool valid_stack_address(Thread* thread, address sp); |
duke@435 | 140 | static bool valid_ucontext(Thread* thread, ucontext_t* valid, ucontext_t* suspect); |
duke@435 | 141 | static ucontext_t* get_valid_uc_in_signal_handler(Thread* thread, |
duke@435 | 142 | ucontext_t* uc); |
duke@435 | 143 | |
duke@435 | 144 | static ExtendedPC ucontext_get_ExtendedPC(ucontext_t* uc); |
duke@435 | 145 | static intptr_t* ucontext_get_sp(ucontext_t* uc); |
duke@435 | 146 | // ucontext_get_fp() is only used by Solaris X86 (see note below) |
duke@435 | 147 | static intptr_t* ucontext_get_fp(ucontext_t* uc); |
duke@435 | 148 | |
duke@435 | 149 | // For Analyzer Forte AsyncGetCallTrace profiling support: |
duke@435 | 150 | // Parameter ret_fp is only used by Solaris X86. |
duke@435 | 151 | // |
duke@435 | 152 | // We should have different declarations of this interface in |
duke@435 | 153 | // os_solaris_i486.hpp and os_solaris_sparc.hpp, but that file |
duke@435 | 154 | // provides extensions to the os class and not the Solaris class. |
duke@435 | 155 | static ExtendedPC fetch_frame_from_ucontext(Thread* thread, ucontext_t* uc, |
duke@435 | 156 | intptr_t** ret_sp, intptr_t** ret_fp); |
duke@435 | 157 | |
duke@435 | 158 | static void hotspot_sigmask(Thread* thread); |
duke@435 | 159 | |
duke@435 | 160 | protected: |
duke@435 | 161 | // Solaris-specific interface goes here |
duke@435 | 162 | static julong available_memory(); |
duke@435 | 163 | static julong physical_memory() { return _physical_memory; } |
duke@435 | 164 | static julong _physical_memory; |
duke@435 | 165 | static void initialize_system_info(); |
duke@435 | 166 | static int _dev_zero_fd; |
duke@435 | 167 | static int get_dev_zero_fd() { return _dev_zero_fd; } |
duke@435 | 168 | static void set_dev_zero_fd(int fd) { _dev_zero_fd = fd; } |
duke@435 | 169 | static char* mmap_chunk(char *addr, size_t size, int flags, int prot); |
sbohne@495 | 170 | static char* anon_mmap(char* requested_addr, size_t bytes, size_t alignment_hint, bool fixed); |
duke@435 | 171 | static bool mpss_sanity_check(bool warn, size_t * page_size); |
duke@435 | 172 | static bool ism_sanity_check (bool warn, size_t * page_size); |
duke@435 | 173 | |
duke@435 | 174 | // Workaround for 4352906. thr_stksegment sometimes returns |
duke@435 | 175 | // a bad value for the primordial thread's stack base when |
duke@435 | 176 | // it is called more than one time. |
duke@435 | 177 | // Workaround is to cache the initial value to avoid further |
duke@435 | 178 | // calls to thr_stksegment. |
duke@435 | 179 | // It appears that someone (Hotspot?) is trashing the user's |
duke@435 | 180 | // proc_t structure (note that this is a system struct). |
duke@435 | 181 | static address _main_stack_base; |
duke@435 | 182 | |
duke@435 | 183 | public: |
duke@435 | 184 | static void libthread_init(); |
duke@435 | 185 | static void synchronization_init(); |
iveresov@897 | 186 | static bool liblgrp_init(); |
duke@435 | 187 | // Load miscellaneous symbols. |
duke@435 | 188 | static void misc_sym_init(); |
duke@435 | 189 | // This boolean allows users to forward their own non-matching signals |
duke@435 | 190 | // to JVM_handle_solaris_signal, harmlessly. |
duke@435 | 191 | static bool signal_handlers_are_installed; |
duke@435 | 192 | |
duke@435 | 193 | static void signal_sets_init(); |
duke@435 | 194 | static void install_signal_handlers(); |
duke@435 | 195 | static void set_signal_handler(int sig, bool set_installed, bool oktochain); |
duke@435 | 196 | static void init_signal_mem(); |
duke@435 | 197 | static bool is_sig_ignored(int sig); |
duke@435 | 198 | static void set_our_sigflags(int, int); |
duke@435 | 199 | static int get_our_sigflags(int); |
duke@435 | 200 | |
duke@435 | 201 | // For signal-chaining |
duke@435 | 202 | static bool libjsig_is_loaded; // libjsig that interposes sigaction(), |
duke@435 | 203 | // signal(), sigset() is loaded |
duke@435 | 204 | static struct sigaction *get_chained_signal_action(int sig); |
duke@435 | 205 | static bool chained_handler(int sig, siginfo_t *siginfo, void *context); |
duke@435 | 206 | |
duke@435 | 207 | // The following allow us to link against both the old and new libthread (2.8) |
duke@435 | 208 | // and exploit the new libthread functionality if available. |
duke@435 | 209 | |
duke@435 | 210 | static bool T2_libthread() { return _T2_libthread; } |
duke@435 | 211 | static void set_T2_libthread(bool T2_libthread) { _T2_libthread = T2_libthread; } |
duke@435 | 212 | |
duke@435 | 213 | static int thr_getstate(thread_t tid, int *flag, unsigned *lwp, stack_t *ss, gregset_t rs) |
duke@435 | 214 | { return _thr_getstate(tid, flag, lwp, ss, rs); } |
duke@435 | 215 | static void set_thr_getstate(int_fnP_thread_t_iP_uP_stack_tP_gregset_t func) |
duke@435 | 216 | { _thr_getstate = func; } |
duke@435 | 217 | |
duke@435 | 218 | static int thr_setstate(thread_t tid, int flag, gregset_t rs) { return _thr_setstate(tid, flag, rs); } |
duke@435 | 219 | static void set_thr_setstate(int_fnP_thread_t_i_gregset_t func) { _thr_setstate = func; } |
duke@435 | 220 | |
duke@435 | 221 | static int thr_setmutator(thread_t tid, int enabled) { return _thr_setmutator(tid, enabled); } |
duke@435 | 222 | static void set_thr_setmutator(int_fnP_thread_t_i func) { _thr_setmutator = func; } |
duke@435 | 223 | |
duke@435 | 224 | static int thr_suspend_mutator(thread_t tid) { return _thr_suspend_mutator(tid); } |
duke@435 | 225 | static void set_thr_suspend_mutator(int_fnP_thread_t func) { _thr_suspend_mutator = func; } |
duke@435 | 226 | |
duke@435 | 227 | static int thr_continue_mutator(thread_t tid) { return _thr_continue_mutator(tid); } |
duke@435 | 228 | static void set_thr_continue_mutator(int_fnP_thread_t func) { _thr_continue_mutator = func; } |
duke@435 | 229 | |
duke@435 | 230 | // Allows us to switch between lwp and thread -based synchronization |
duke@435 | 231 | static int mutex_lock(mutex_t *mx) { return _mutex_lock(mx); } |
duke@435 | 232 | static int mutex_trylock(mutex_t *mx) { return _mutex_trylock(mx); } |
duke@435 | 233 | static int mutex_unlock(mutex_t *mx) { return _mutex_unlock(mx); } |
duke@435 | 234 | static int mutex_init(mutex_t *mx) { return _mutex_init(mx, os::Solaris::mutex_scope(), NULL); } |
duke@435 | 235 | static int mutex_destroy(mutex_t *mx) { return _mutex_destroy(mx); } |
duke@435 | 236 | static int mutex_scope() { return _mutex_scope; } |
duke@435 | 237 | |
duke@435 | 238 | static void set_mutex_lock(int_fnP_mutex_tP func) { _mutex_lock = func; } |
duke@435 | 239 | static void set_mutex_trylock(int_fnP_mutex_tP func) { _mutex_trylock = func; } |
duke@435 | 240 | static void set_mutex_unlock(int_fnP_mutex_tP func) { _mutex_unlock = func; } |
duke@435 | 241 | static void set_mutex_init(int_fnP_mutex_tP_i_vP func) { _mutex_init = func; } |
duke@435 | 242 | static void set_mutex_destroy(int_fnP_mutex_tP func) { _mutex_destroy = func; } |
duke@435 | 243 | static void set_mutex_scope(int scope) { _mutex_scope = scope; } |
duke@435 | 244 | |
duke@435 | 245 | static int cond_timedwait(cond_t *cv, mutex_t *mx, timestruc_t *abst) |
duke@435 | 246 | { return _cond_timedwait(cv, mx, abst); } |
duke@435 | 247 | static int cond_wait(cond_t *cv, mutex_t *mx) { return _cond_wait(cv, mx); } |
duke@435 | 248 | static int cond_signal(cond_t *cv) { return _cond_signal(cv); } |
duke@435 | 249 | static int cond_broadcast(cond_t *cv) { return _cond_broadcast(cv); } |
duke@435 | 250 | static int cond_init(cond_t *cv) { return _cond_init(cv, os::Solaris::cond_scope(), NULL); } |
duke@435 | 251 | static int cond_destroy(cond_t *cv) { return _cond_destroy(cv); } |
duke@435 | 252 | static int cond_scope() { return _cond_scope; } |
duke@435 | 253 | |
duke@435 | 254 | static void set_cond_timedwait(int_fnP_cond_tP_mutex_tP_timestruc_tP func) |
duke@435 | 255 | { _cond_timedwait = func; } |
duke@435 | 256 | static void set_cond_wait(int_fnP_cond_tP_mutex_tP func) { _cond_wait = func; } |
duke@435 | 257 | static void set_cond_signal(int_fnP_cond_tP func) { _cond_signal = func; } |
duke@435 | 258 | static void set_cond_broadcast(int_fnP_cond_tP func) { _cond_broadcast = func; } |
duke@435 | 259 | static void set_cond_init(int_fnP_cond_tP_i_vP func) { _cond_init = func; } |
duke@435 | 260 | static void set_cond_destroy(int_fnP_cond_tP func) { _cond_destroy = func; } |
duke@435 | 261 | static void set_cond_scope(int scope) { _cond_scope = scope; } |
duke@435 | 262 | |
duke@435 | 263 | static void set_lgrp_home(lgrp_home_func_t func) { _lgrp_home = func; } |
duke@435 | 264 | static void set_lgrp_init(lgrp_init_func_t func) { _lgrp_init = func; } |
duke@435 | 265 | static void set_lgrp_fini(lgrp_fini_func_t func) { _lgrp_fini = func; } |
duke@435 | 266 | static void set_lgrp_root(lgrp_root_func_t func) { _lgrp_root = func; } |
iveresov@579 | 267 | static void set_lgrp_children(lgrp_children_func_t func) { _lgrp_children = func; } |
iveresov@579 | 268 | static void set_lgrp_resources(lgrp_resources_func_t func) { _lgrp_resources = func; } |
iveresov@579 | 269 | static void set_lgrp_nlgrps(lgrp_nlgrps_func_t func) { _lgrp_nlgrps = func; } |
duke@435 | 270 | static void set_lgrp_cookie_stale(lgrp_cookie_stale_func_t func) { _lgrp_cookie_stale = func; } |
duke@435 | 271 | static void set_lgrp_cookie(lgrp_cookie_t cookie) { _lgrp_cookie = cookie; } |
duke@435 | 272 | |
duke@435 | 273 | static id_t lgrp_home(idtype_t type, id_t id) { return _lgrp_home != NULL ? _lgrp_home(type, id) : -1; } |
duke@435 | 274 | static lgrp_cookie_t lgrp_init(lgrp_view_t view) { return _lgrp_init != NULL ? _lgrp_init(view) : 0; } |
duke@435 | 275 | static int lgrp_fini(lgrp_cookie_t cookie) { return _lgrp_fini != NULL ? _lgrp_fini(cookie) : -1; } |
duke@435 | 276 | static lgrp_id_t lgrp_root(lgrp_cookie_t cookie) { return _lgrp_root != NULL ? _lgrp_root(cookie) : -1; }; |
duke@435 | 277 | static int lgrp_children(lgrp_cookie_t cookie, lgrp_id_t parent, |
duke@435 | 278 | lgrp_id_t *lgrp_array, uint_t lgrp_array_size) { |
duke@435 | 279 | return _lgrp_children != NULL ? _lgrp_children(cookie, parent, lgrp_array, lgrp_array_size) : -1; |
duke@435 | 280 | } |
iveresov@579 | 281 | static int lgrp_resources(lgrp_cookie_t cookie, lgrp_id_t lgrp, |
iveresov@579 | 282 | lgrp_id_t *lgrp_array, uint_t lgrp_array_size, |
iveresov@579 | 283 | lgrp_rsrc_t type) { |
iveresov@579 | 284 | return _lgrp_resources != NULL ? _lgrp_resources(cookie, lgrp, lgrp_array, lgrp_array_size, type) : -1; |
iveresov@579 | 285 | } |
iveresov@579 | 286 | |
duke@435 | 287 | static int lgrp_nlgrps(lgrp_cookie_t cookie) { return _lgrp_nlgrps != NULL ? _lgrp_nlgrps(cookie) : -1; } |
duke@435 | 288 | static int lgrp_cookie_stale(lgrp_cookie_t cookie) { |
duke@435 | 289 | return _lgrp_cookie_stale != NULL ? _lgrp_cookie_stale(cookie) : -1; |
duke@435 | 290 | } |
duke@435 | 291 | static lgrp_cookie_t lgrp_cookie() { return _lgrp_cookie; } |
duke@435 | 292 | |
twisti@1076 | 293 | static bool supports_getisax() { return _getisax != NULL; } |
twisti@1076 | 294 | static uint_t getisax(uint32_t* array, uint_t n); |
twisti@1076 | 295 | |
duke@435 | 296 | static void set_meminfo(meminfo_func_t func) { _meminfo = func; } |
duke@435 | 297 | static int meminfo (const uint64_t inaddr[], int addr_count, |
duke@435 | 298 | const uint_t info_req[], int info_count, |
duke@435 | 299 | uint64_t outdata[], uint_t validity[]) { |
duke@435 | 300 | return _meminfo != NULL ? _meminfo(inaddr, addr_count, info_req, info_count, |
duke@435 | 301 | outdata, validity) : -1; |
duke@435 | 302 | } |
duke@435 | 303 | |
duke@435 | 304 | enum { |
duke@435 | 305 | clear_interrupted = true |
duke@435 | 306 | }; |
duke@435 | 307 | static void setup_interruptible(JavaThread* thread); |
duke@435 | 308 | static void setup_interruptible_already_blocked(JavaThread* thread); |
duke@435 | 309 | static JavaThread* setup_interruptible(); |
duke@435 | 310 | static void cleanup_interruptible(JavaThread* thread); |
duke@435 | 311 | |
duke@435 | 312 | // perf counter incrementers used by _INTERRUPTIBLE |
duke@435 | 313 | |
duke@435 | 314 | static void bump_interrupted_before_count(); |
duke@435 | 315 | static void bump_interrupted_during_count(); |
duke@435 | 316 | |
duke@435 | 317 | #ifdef ASSERT |
duke@435 | 318 | static JavaThread* setup_interruptible_native(); |
duke@435 | 319 | static void cleanup_interruptible_native(JavaThread* thread); |
duke@435 | 320 | #endif |
duke@435 | 321 | |
duke@435 | 322 | static sigset_t* unblocked_signals(); |
duke@435 | 323 | static sigset_t* vm_signals(); |
duke@435 | 324 | static sigset_t* allowdebug_blocked_signals(); |
duke@435 | 325 | |
duke@435 | 326 | // %%% Following should be promoted to os.hpp: |
duke@435 | 327 | // Trace number of created threads |
duke@435 | 328 | static jint _os_thread_limit; |
duke@435 | 329 | static volatile jint _os_thread_count; |
duke@435 | 330 | |
duke@435 | 331 | // Minimum stack size a thread can be created with (allowing |
duke@435 | 332 | // the VM to completely create the thread and enter user code) |
duke@435 | 333 | |
duke@435 | 334 | static size_t min_stack_allowed; |
duke@435 | 335 | |
duke@435 | 336 | // Stack overflow handling |
duke@435 | 337 | |
duke@435 | 338 | static int max_register_window_saves_before_flushing(); |
duke@435 | 339 | |
duke@435 | 340 | // Stack repair handling |
duke@435 | 341 | |
duke@435 | 342 | // none present |
duke@435 | 343 | |
duke@435 | 344 | }; |
duke@435 | 345 | |
duke@435 | 346 | class PlatformEvent : public CHeapObj { |
duke@435 | 347 | private: |
duke@435 | 348 | double CachePad [4] ; // increase odds that _mutex is sole occupant of cache line |
duke@435 | 349 | volatile int _Event ; |
duke@435 | 350 | int _nParked ; |
duke@435 | 351 | int _pipev [2] ; |
duke@435 | 352 | mutex_t _mutex [1] ; |
duke@435 | 353 | cond_t _cond [1] ; |
duke@435 | 354 | double PostPad [2] ; |
duke@435 | 355 | |
duke@435 | 356 | protected: |
duke@435 | 357 | // Defining a protected ctor effectively gives us an abstract base class. |
duke@435 | 358 | // That is, a PlatformEvent can never be instantiated "naked" but only |
duke@435 | 359 | // as a part of a ParkEvent (recall that ParkEvent extends PlatformEvent). |
duke@435 | 360 | // TODO-FIXME: make dtor private |
duke@435 | 361 | ~PlatformEvent() { guarantee (0, "invariant") ; } |
duke@435 | 362 | PlatformEvent() { |
duke@435 | 363 | int status; |
duke@435 | 364 | status = os::Solaris::cond_init(_cond); |
duke@435 | 365 | assert_status(status == 0, status, "cond_init"); |
duke@435 | 366 | status = os::Solaris::mutex_init(_mutex); |
duke@435 | 367 | assert_status(status == 0, status, "mutex_init"); |
duke@435 | 368 | _Event = 0 ; |
duke@435 | 369 | _nParked = 0 ; |
duke@435 | 370 | _pipev[0] = _pipev[1] = -1 ; |
duke@435 | 371 | } |
duke@435 | 372 | |
duke@435 | 373 | public: |
duke@435 | 374 | // Exercise caution using reset() and fired() -- they may require MEMBARs |
duke@435 | 375 | void reset() { _Event = 0 ; } |
duke@435 | 376 | int fired() { return _Event; } |
duke@435 | 377 | void park () ; |
duke@435 | 378 | int park (jlong millis) ; |
duke@435 | 379 | int TryPark () ; |
duke@435 | 380 | void unpark () ; |
duke@435 | 381 | } ; |
duke@435 | 382 | |
duke@435 | 383 | class PlatformParker : public CHeapObj { |
duke@435 | 384 | protected: |
duke@435 | 385 | mutex_t _mutex [1] ; |
duke@435 | 386 | cond_t _cond [1] ; |
duke@435 | 387 | |
duke@435 | 388 | public: // TODO-FIXME: make dtor private |
duke@435 | 389 | ~PlatformParker() { guarantee (0, "invariant") ; } |
duke@435 | 390 | |
duke@435 | 391 | public: |
duke@435 | 392 | PlatformParker() { |
duke@435 | 393 | int status; |
duke@435 | 394 | status = os::Solaris::cond_init(_cond); |
duke@435 | 395 | assert_status(status == 0, status, "cond_init"); |
duke@435 | 396 | status = os::Solaris::mutex_init(_mutex); |
duke@435 | 397 | assert_status(status == 0, status, "mutex_init"); |
duke@435 | 398 | } |
duke@435 | 399 | } ; |
stefank@2314 | 400 | |
stefank@2314 | 401 | #endif // OS_SOLARIS_VM_OS_SOLARIS_HPP |