Thu, 04 Apr 2013 10:01:26 -0700
8003310: Enable -Wunused-function when compiling with gcc
Summary: Add the -Wunused-function flag and remove a number of unused functions.
Reviewed-by: dholmes, coleenp, kvn
duke@435 | 1 | /* |
phh@3481 | 2 | * Copyright (c) 1997, 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_SOLARIS_VM_OSTHREAD_SOLARIS_HPP |
stefank@2314 | 26 | #define OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP |
stefank@2314 | 27 | |
duke@435 | 28 | // This is embedded via include into the class OSThread |
rbackman@3796 | 29 | public: |
rbackman@3796 | 30 | typedef thread_t thread_id_t; |
duke@435 | 31 | |
duke@435 | 32 | private: |
phh@3481 | 33 | uint _lwp_id; // lwp ID, only used with bound threads |
phh@3481 | 34 | int _native_priority; // Saved native priority when starting |
phh@3481 | 35 | // a bound thread |
phh@3481 | 36 | sigset_t _caller_sigmask; // Caller's signal mask |
phh@3481 | 37 | bool _vm_created_thread; // true if the VM created this thread, |
phh@3481 | 38 | // false if primary thread or attached thread |
duke@435 | 39 | public: |
phh@3481 | 40 | uint lwp_id() const { return _lwp_id; } |
phh@3481 | 41 | int native_priority() const { return _native_priority; } |
duke@435 | 42 | |
duke@435 | 43 | // Set and get state of _vm_created_thread flag |
duke@435 | 44 | void set_vm_created() { _vm_created_thread = true; } |
duke@435 | 45 | bool is_vm_created() { return _vm_created_thread; } |
duke@435 | 46 | |
duke@435 | 47 | // Methods to save/restore caller's signal mask |
duke@435 | 48 | sigset_t caller_sigmask() const { return _caller_sigmask; } |
duke@435 | 49 | void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } |
duke@435 | 50 | |
duke@435 | 51 | #ifndef PRODUCT |
duke@435 | 52 | // Used for debugging, return a unique integer for each thread. |
duke@435 | 53 | int thread_identifier() const { return _thread_id; } |
duke@435 | 54 | #endif |
duke@435 | 55 | #ifdef ASSERT |
duke@435 | 56 | // On solaris reposition can fail in two ways: |
duke@435 | 57 | // 1: a mismatched pc, because signal is delivered too late, target thread |
duke@435 | 58 | // is resumed. |
duke@435 | 59 | // 2: on a timeout where signal is lost, target thread is resumed. |
duke@435 | 60 | bool valid_reposition_failure() { |
duke@435 | 61 | // only 1 and 2 can happen and we can handle both of them |
duke@435 | 62 | return true; |
duke@435 | 63 | } |
duke@435 | 64 | #endif |
phh@3481 | 65 | void set_lwp_id(uint id) { _lwp_id = id; } |
phh@3481 | 66 | void set_native_priority(int prio) { _native_priority = prio; } |
duke@435 | 67 | |
duke@435 | 68 | // *************************************************************** |
duke@435 | 69 | // interrupt support. interrupts (using signals) are used to get |
duke@435 | 70 | // the thread context (get_thread_pc), to set the thread context |
duke@435 | 71 | // (set_thread_pc), and to implement java.lang.Thread.interrupt. |
duke@435 | 72 | // *************************************************************** |
duke@435 | 73 | |
duke@435 | 74 | public: |
duke@435 | 75 | |
duke@435 | 76 | class InterruptArguments : StackObj { |
duke@435 | 77 | private: |
duke@435 | 78 | Thread* _thread; // the thread to signal was dispatched to |
duke@435 | 79 | ucontext_t* _ucontext; // the machine context at the time of the signal |
duke@435 | 80 | |
duke@435 | 81 | public: |
duke@435 | 82 | InterruptArguments(Thread* thread, ucontext_t* ucontext) { |
duke@435 | 83 | _thread = thread; |
duke@435 | 84 | _ucontext = ucontext; |
duke@435 | 85 | } |
duke@435 | 86 | |
duke@435 | 87 | Thread* thread() const { return _thread; } |
duke@435 | 88 | ucontext_t* ucontext() const { return _ucontext; } |
duke@435 | 89 | }; |
duke@435 | 90 | |
duke@435 | 91 | // There are currently no asynchronous callbacks - and we'd better not |
duke@435 | 92 | // support them in the future either, as they need to be deallocated from |
duke@435 | 93 | // the interrupt handler, which is not safe; they also require locks to |
duke@435 | 94 | // protect the callback queue. |
duke@435 | 95 | |
duke@435 | 96 | class Sync_Interrupt_Callback : private StackObj { |
duke@435 | 97 | protected: |
duke@435 | 98 | volatile bool _is_done; |
duke@435 | 99 | Monitor* _sync; |
duke@435 | 100 | Thread* _target; |
duke@435 | 101 | public: |
duke@435 | 102 | Sync_Interrupt_Callback(Monitor * sync) { |
duke@435 | 103 | _is_done = false; _target = NULL; _sync = sync; |
duke@435 | 104 | } |
duke@435 | 105 | |
duke@435 | 106 | bool is_done() const { return _is_done; } |
duke@435 | 107 | Thread* target() const { return _target; } |
duke@435 | 108 | |
duke@435 | 109 | int interrupt(Thread * target, int timeout); |
duke@435 | 110 | |
duke@435 | 111 | // override to implement the callback. |
duke@435 | 112 | virtual void execute(InterruptArguments *args) = 0; |
duke@435 | 113 | |
duke@435 | 114 | void leave_callback(); |
duke@435 | 115 | }; |
duke@435 | 116 | |
duke@435 | 117 | private: |
duke@435 | 118 | |
duke@435 | 119 | Sync_Interrupt_Callback * volatile _current_callback; |
duke@435 | 120 | enum { |
duke@435 | 121 | callback_in_progress = 1 |
duke@435 | 122 | }; |
duke@435 | 123 | Mutex * _current_callback_lock; // only used on v8 |
duke@435 | 124 | |
duke@435 | 125 | public: |
duke@435 | 126 | |
duke@435 | 127 | int set_interrupt_callback (Sync_Interrupt_Callback * cb); |
duke@435 | 128 | void remove_interrupt_callback(Sync_Interrupt_Callback * cb); |
zgu@1979 | 129 | void do_interrupt_callbacks_at_interrupt(InterruptArguments *args); |
duke@435 | 130 | |
duke@435 | 131 | // *************************************************************** |
duke@435 | 132 | // java.lang.Thread.interrupt state. |
duke@435 | 133 | // *************************************************************** |
duke@435 | 134 | |
duke@435 | 135 | private: |
duke@435 | 136 | |
duke@435 | 137 | JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward |
duke@435 | 138 | |
duke@435 | 139 | public: |
duke@435 | 140 | |
duke@435 | 141 | |
duke@435 | 142 | JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; } |
duke@435 | 143 | void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; } |
duke@435 | 144 | |
duke@435 | 145 | static void handle_spinlock_contention(int tries); // Used for thread local eden locking |
duke@435 | 146 | |
duke@435 | 147 | // *************************************************************** |
duke@435 | 148 | // Platform dependent initialization and cleanup |
duke@435 | 149 | // *************************************************************** |
duke@435 | 150 | |
duke@435 | 151 | private: |
duke@435 | 152 | |
duke@435 | 153 | void pd_initialize(); |
duke@435 | 154 | void pd_destroy(); |
stefank@2314 | 155 | |
stefank@2314 | 156 | #endif // OS_SOLARIS_VM_OSTHREAD_SOLARIS_HPP |