annotate src/os/solaris/vm/os_solaris.hpp @ 1972:f95d63e2154a

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