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