Thu, 12 Mar 2009 10:37:46 -0700
6791178: Specialize for zero as the compressed oop vm heap base
Summary: Use zero based compressed oops if java heap is below 32gb and unscaled compressed oops if java heap is below 4gb.
Reviewed-by: never, twisti, jcoomes, coleenp
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1997-2006 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | // This is embedded via include into the class OSThread |
duke@435 | 26 | |
duke@435 | 27 | private: |
duke@435 | 28 | |
duke@435 | 29 | thread_t _thread_id; // Solaris thread id |
duke@435 | 30 | unsigned int _lwp_id; // lwp ID, only used with bound threads |
duke@435 | 31 | sigset_t _caller_sigmask; // Caller's signal mask |
duke@435 | 32 | bool _vm_created_thread; // true if the VM create this thread |
duke@435 | 33 | // false if primary thread or attached thread |
duke@435 | 34 | public: |
duke@435 | 35 | |
duke@435 | 36 | thread_t thread_id() const { return _thread_id; } |
duke@435 | 37 | |
duke@435 | 38 | unsigned int lwp_id() const { return _lwp_id; } |
duke@435 | 39 | |
duke@435 | 40 | // Set and get state of _vm_created_thread flag |
duke@435 | 41 | void set_vm_created() { _vm_created_thread = true; } |
duke@435 | 42 | bool is_vm_created() { return _vm_created_thread; } |
duke@435 | 43 | |
duke@435 | 44 | // Methods to save/restore caller's signal mask |
duke@435 | 45 | sigset_t caller_sigmask() const { return _caller_sigmask; } |
duke@435 | 46 | void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } |
duke@435 | 47 | |
duke@435 | 48 | #ifndef PRODUCT |
duke@435 | 49 | // Used for debugging, return a unique integer for each thread. |
duke@435 | 50 | int thread_identifier() const { return _thread_id; } |
duke@435 | 51 | #endif |
duke@435 | 52 | #ifdef ASSERT |
duke@435 | 53 | // On solaris reposition can fail in two ways: |
duke@435 | 54 | // 1: a mismatched pc, because signal is delivered too late, target thread |
duke@435 | 55 | // is resumed. |
duke@435 | 56 | // 2: on a timeout where signal is lost, target thread is resumed. |
duke@435 | 57 | bool valid_reposition_failure() { |
duke@435 | 58 | // only 1 and 2 can happen and we can handle both of them |
duke@435 | 59 | return true; |
duke@435 | 60 | } |
duke@435 | 61 | #endif |
duke@435 | 62 | void set_thread_id(thread_t id) { _thread_id = id; } |
duke@435 | 63 | void set_lwp_id(unsigned int id){ _lwp_id = id; } |
duke@435 | 64 | |
duke@435 | 65 | // *************************************************************** |
duke@435 | 66 | // interrupt support. interrupts (using signals) are used to get |
duke@435 | 67 | // the thread context (get_thread_pc), to set the thread context |
duke@435 | 68 | // (set_thread_pc), and to implement java.lang.Thread.interrupt. |
duke@435 | 69 | // *************************************************************** |
duke@435 | 70 | |
duke@435 | 71 | public: |
duke@435 | 72 | |
duke@435 | 73 | class InterruptArguments : StackObj { |
duke@435 | 74 | private: |
duke@435 | 75 | Thread* _thread; // the thread to signal was dispatched to |
duke@435 | 76 | ucontext_t* _ucontext; // the machine context at the time of the signal |
duke@435 | 77 | |
duke@435 | 78 | public: |
duke@435 | 79 | InterruptArguments(Thread* thread, ucontext_t* ucontext) { |
duke@435 | 80 | _thread = thread; |
duke@435 | 81 | _ucontext = ucontext; |
duke@435 | 82 | } |
duke@435 | 83 | |
duke@435 | 84 | Thread* thread() const { return _thread; } |
duke@435 | 85 | ucontext_t* ucontext() const { return _ucontext; } |
duke@435 | 86 | }; |
duke@435 | 87 | |
duke@435 | 88 | // There are currently no asynchronous callbacks - and we'd better not |
duke@435 | 89 | // support them in the future either, as they need to be deallocated from |
duke@435 | 90 | // the interrupt handler, which is not safe; they also require locks to |
duke@435 | 91 | // protect the callback queue. |
duke@435 | 92 | |
duke@435 | 93 | class Sync_Interrupt_Callback : private StackObj { |
duke@435 | 94 | protected: |
duke@435 | 95 | volatile bool _is_done; |
duke@435 | 96 | Monitor* _sync; |
duke@435 | 97 | Thread* _target; |
duke@435 | 98 | public: |
duke@435 | 99 | Sync_Interrupt_Callback(Monitor * sync) { |
duke@435 | 100 | _is_done = false; _target = NULL; _sync = sync; |
duke@435 | 101 | } |
duke@435 | 102 | |
duke@435 | 103 | bool is_done() const { return _is_done; } |
duke@435 | 104 | Thread* target() const { return _target; } |
duke@435 | 105 | |
duke@435 | 106 | int interrupt(Thread * target, int timeout); |
duke@435 | 107 | |
duke@435 | 108 | // override to implement the callback. |
duke@435 | 109 | virtual void execute(InterruptArguments *args) = 0; |
duke@435 | 110 | |
duke@435 | 111 | void leave_callback(); |
duke@435 | 112 | }; |
duke@435 | 113 | |
duke@435 | 114 | private: |
duke@435 | 115 | |
duke@435 | 116 | Sync_Interrupt_Callback * volatile _current_callback; |
duke@435 | 117 | enum { |
duke@435 | 118 | callback_in_progress = 1 |
duke@435 | 119 | }; |
duke@435 | 120 | Mutex * _current_callback_lock; // only used on v8 |
duke@435 | 121 | |
duke@435 | 122 | public: |
duke@435 | 123 | |
duke@435 | 124 | int set_interrupt_callback (Sync_Interrupt_Callback * cb); |
duke@435 | 125 | void remove_interrupt_callback(Sync_Interrupt_Callback * cb); |
duke@435 | 126 | void OSThread::do_interrupt_callbacks_at_interrupt(InterruptArguments *args); |
duke@435 | 127 | |
duke@435 | 128 | // *************************************************************** |
duke@435 | 129 | // java.lang.Thread.interrupt state. |
duke@435 | 130 | // *************************************************************** |
duke@435 | 131 | |
duke@435 | 132 | private: |
duke@435 | 133 | |
duke@435 | 134 | JavaThreadState _saved_interrupt_thread_state; // the thread state before a system call -- restored afterward |
duke@435 | 135 | |
duke@435 | 136 | public: |
duke@435 | 137 | |
duke@435 | 138 | |
duke@435 | 139 | JavaThreadState saved_interrupt_thread_state() { return _saved_interrupt_thread_state; } |
duke@435 | 140 | void set_saved_interrupt_thread_state(JavaThreadState state) { _saved_interrupt_thread_state = state; } |
duke@435 | 141 | |
duke@435 | 142 | static void handle_spinlock_contention(int tries); // Used for thread local eden locking |
duke@435 | 143 | |
duke@435 | 144 | // *************************************************************** |
duke@435 | 145 | // Platform dependent initialization and cleanup |
duke@435 | 146 | // *************************************************************** |
duke@435 | 147 | |
duke@435 | 148 | private: |
duke@435 | 149 | |
duke@435 | 150 | void pd_initialize(); |
duke@435 | 151 | void pd_destroy(); |