annotate src/os/linux/vm/osThread_linux.hpp @ 6006:0105f367a14c

7160570: Intrinsification support for tracing framework Reviewed-by: sla, never
author rbackman
date Tue, 06 Mar 2012 12:36:59 +0100
parents f95d63e2154a
children 960a442eae91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 1972
diff changeset
2 * Copyright (c) 1999, 2012, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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_LINUX_VM_OSTHREAD_LINUX_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define OS_LINUX_VM_OSTHREAD_LINUX_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
29 int _thread_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 int thread_type() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 return _thread_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 }
a61af66fc99e Initial load
duke
parents:
diff changeset
36 void set_thread_type(int type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _thread_type = type;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // thread has a unique thread_id (LinuxThreads or NPTL). It can be used
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // to access /proc.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 pid_t _thread_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // _pthread_id is the pthread id, which is used by library calls
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // (e.g. pthread_kill).
a61af66fc99e Initial load
duke
parents:
diff changeset
49 pthread_t _pthread_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 sigset_t _caller_sigmask; // Caller's signal mask
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Methods to save/restore caller's signal mask
a61af66fc99e Initial load
duke
parents:
diff changeset
56 sigset_t caller_sigmask() const { return _caller_sigmask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
6006
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 1972
diff changeset
59 static size_t thread_id_size() { return sizeof(pid_t); }
0105f367a14c 7160570: Intrinsification support for tracing framework
rbackman
parents: 1972
diff changeset
60
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 pid_t thread_id() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 return _thread_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Used for debugging, return a unique integer for each thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 int thread_identifier() const { return _thread_id; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // We expect no reposition failures so kill vm if we get one.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //
a61af66fc99e Initial load
duke
parents:
diff changeset
71 bool valid_reposition_failure() {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void set_thread_id(pid_t id) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _thread_id = id;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 pthread_t pthread_id() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 return _pthread_id;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void set_pthread_id(pthread_t tid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 _pthread_id = tid;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // suspension support.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // flags that support signal based suspend/resume on Linux are in a
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // separate class to avoid confusion with many flags in OSThread that
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // are used by VM level suspend/resume.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 os::Linux::SuspendResume sr;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // _ucontext and _siginfo are used by SR_handler() to save thread context,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // and they will later be used to walk the stack or reposition thread PC.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // If the thread is not suspended in SR_handler() (e.g. self suspend),
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // the value in _ucontext is meaningless, so we must use the last Java
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // frame information as the frame. This will mean that for threads
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // that are parked on a mutex the profiler (and safepoint mechanism)
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // will see the thread as if it were still in the Java frame. This
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // not a problem for the profiler since the Java frame is a close
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // enough result. For the safepoint mechanism when the give it the
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Java frame we are not at a point where the safepoint needs the
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // frame to that accurate (like for a compiled safepoint) since we
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // should be in a place where we are native and will block ourselves
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // if we transition.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
109 void* _siginfo;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 ucontext_t* _ucontext;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int _expanding_stack; /* non zero if manually expanding stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
112 address _alt_sig_stack; /* address of base of alternate signal stack */
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void* siginfo() const { return _siginfo; }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void set_siginfo(void* ptr) { _siginfo = ptr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 ucontext_t* ucontext() const { return _ucontext; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void set_expanding_stack(void) { _expanding_stack = 1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void clear_expanding_stack(void) { _expanding_stack = 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int expanding_stack(void) { return _expanding_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 void set_alt_sig_stack(address val) { _alt_sig_stack = val; }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 address alt_sig_stack(void) { return _alt_sig_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 Monitor* _startThread_lock; // sync parent and child in thread creation
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 Monitor* startThread_lock() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return _startThread_lock;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Platform dependent initialization and cleanup
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // ***************************************************************
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 void pd_initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void pd_destroy();
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Reconciliation History
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // osThread_solaris.hpp 1.24 99/08/27 13:11:54
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // End
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
147
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
148 #endif // OS_LINUX_VM_OSTHREAD_LINUX_HPP