src/os/solaris/vm/os_solaris.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial