Fri, 09 May 2008 08:55:13 -0700
6670684: 4/5 SA command universe did not print out CMS space information
Summary: Forward port of Yumin's fix for 6670684 from HSX-11; Yumin verified the port was correct.
Reviewed-by: dcubed
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 2001-2005 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 | class VoidClosure; |
duke@435 | 26 | |
duke@435 | 27 | // A SuspendibleThreadSet is (obviously) a set of threads that can be |
duke@435 | 28 | // suspended. A thread can join and later leave the set, and periodically |
duke@435 | 29 | // yield. If some thread (not in the set) requests, via suspend_all, that |
duke@435 | 30 | // the threads be suspended, then the requesting thread is blocked until |
duke@435 | 31 | // all the threads in the set have yielded or left the set. (Threads may |
duke@435 | 32 | // not enter the set when an attempted suspension is in progress.) The |
duke@435 | 33 | // suspending thread later calls resume_all, allowing the suspended threads |
duke@435 | 34 | // to continue. |
duke@435 | 35 | |
duke@435 | 36 | class SuspendibleThreadSet { |
duke@435 | 37 | Monitor* _m; |
duke@435 | 38 | int _async; |
duke@435 | 39 | bool _async_stop; |
duke@435 | 40 | int _async_stopped; |
duke@435 | 41 | bool _initialized; |
duke@435 | 42 | double _suspend_all_start; |
duke@435 | 43 | |
duke@435 | 44 | void initialize_work(); |
duke@435 | 45 | |
duke@435 | 46 | public: |
duke@435 | 47 | SuspendibleThreadSet() : _initialized(false) {} |
duke@435 | 48 | |
duke@435 | 49 | // Add the current thread to the set. May block if a suspension |
duke@435 | 50 | // is in progress. |
duke@435 | 51 | void join(); |
duke@435 | 52 | // Removes the current thread from the set. |
duke@435 | 53 | void leave(); |
duke@435 | 54 | // Returns "true" iff an suspension is in progress. |
duke@435 | 55 | bool should_yield() { return _async_stop; } |
duke@435 | 56 | // Suspends the current thread if a suspension is in progress (for |
duke@435 | 57 | // the duration of the suspension.) |
duke@435 | 58 | void yield(const char* id); |
duke@435 | 59 | // Return when all threads in the set are suspended. |
duke@435 | 60 | void suspend_all(); |
duke@435 | 61 | // Allow suspended threads to resume. |
duke@435 | 62 | void resume_all(); |
duke@435 | 63 | // Redundant initializations okay. |
duke@435 | 64 | void initialize() { |
duke@435 | 65 | // Double-check dirty read idiom. |
duke@435 | 66 | if (!_initialized) initialize_work(); |
duke@435 | 67 | } |
duke@435 | 68 | }; |
duke@435 | 69 | |
duke@435 | 70 | |
duke@435 | 71 | class ConcurrentGCThread: public NamedThread { |
duke@435 | 72 | friend class VMStructs; |
duke@435 | 73 | |
duke@435 | 74 | protected: |
duke@435 | 75 | static bool _should_terminate; |
duke@435 | 76 | static bool _has_terminated; |
duke@435 | 77 | |
duke@435 | 78 | enum CGC_flag_type { |
duke@435 | 79 | CGC_nil = 0x0, |
duke@435 | 80 | CGC_dont_suspend = 0x1, |
duke@435 | 81 | CGC_CGC_safepoint = 0x2, |
duke@435 | 82 | CGC_VM_safepoint = 0x4 |
duke@435 | 83 | }; |
duke@435 | 84 | |
duke@435 | 85 | static int _CGC_flag; |
duke@435 | 86 | |
duke@435 | 87 | static bool CGC_flag_is_set(int b) { return (_CGC_flag & b) != 0; } |
duke@435 | 88 | static int set_CGC_flag(int b) { return _CGC_flag |= b; } |
duke@435 | 89 | static int reset_CGC_flag(int b) { return _CGC_flag &= ~b; } |
duke@435 | 90 | |
duke@435 | 91 | void stopWorldAndDo(VoidClosure* op); |
duke@435 | 92 | |
duke@435 | 93 | // All instances share this one set. |
duke@435 | 94 | static SuspendibleThreadSet _sts; |
duke@435 | 95 | |
duke@435 | 96 | // Create and start the thread (setting it's priority high.) |
duke@435 | 97 | void create_and_start(); |
duke@435 | 98 | |
duke@435 | 99 | // Do initialization steps in the thread: record stack base and size, |
duke@435 | 100 | // init thread local storage, set JNI handle block. |
duke@435 | 101 | void initialize_in_thread(); |
duke@435 | 102 | |
duke@435 | 103 | // Wait until Universe::is_fully_initialized(); |
duke@435 | 104 | void wait_for_universe_init(); |
duke@435 | 105 | |
duke@435 | 106 | // Record that the current thread is terminating, and will do more |
duke@435 | 107 | // concurrent work. |
duke@435 | 108 | void terminate(); |
duke@435 | 109 | |
duke@435 | 110 | public: |
duke@435 | 111 | // Constructor |
duke@435 | 112 | |
duke@435 | 113 | ConcurrentGCThread(); |
duke@435 | 114 | ~ConcurrentGCThread() {} // Exists to call NamedThread destructor. |
duke@435 | 115 | |
duke@435 | 116 | // Tester |
duke@435 | 117 | bool is_ConcurrentGC_thread() const { return true; } |
duke@435 | 118 | |
duke@435 | 119 | static void safepoint_synchronize(); |
duke@435 | 120 | static void safepoint_desynchronize(); |
duke@435 | 121 | |
duke@435 | 122 | // All overridings should probably do _sts::yield, but we allow |
duke@435 | 123 | // overriding for distinguished debugging messages. Default is to do |
duke@435 | 124 | // nothing. |
duke@435 | 125 | virtual void yield() {} |
duke@435 | 126 | |
duke@435 | 127 | bool should_yield() { return _sts.should_yield(); } |
duke@435 | 128 | |
duke@435 | 129 | // they are prefixed by sts since there are already yield() and |
duke@435 | 130 | // should_yield() (non-static) methods in this class and it was an |
duke@435 | 131 | // easy way to differentiate them. |
duke@435 | 132 | static void stsYield(const char* id); |
duke@435 | 133 | static bool stsShouldYield(); |
duke@435 | 134 | static void stsJoin(); |
duke@435 | 135 | static void stsLeave(); |
duke@435 | 136 | |
duke@435 | 137 | }; |
duke@435 | 138 | |
duke@435 | 139 | // The SurrogateLockerThread is used by concurrent GC threads for |
duke@435 | 140 | // manipulating Java monitors, in particular, currently for |
duke@435 | 141 | // manipulating the pending_list_lock. XXX |
duke@435 | 142 | class SurrogateLockerThread: public JavaThread { |
duke@435 | 143 | friend class VMStructs; |
duke@435 | 144 | public: |
duke@435 | 145 | enum SLT_msg_type { |
duke@435 | 146 | empty = 0, // no message |
duke@435 | 147 | acquirePLL, // acquire pending list lock |
duke@435 | 148 | releaseAndNotifyPLL // notify and release pending list lock |
duke@435 | 149 | }; |
duke@435 | 150 | private: |
duke@435 | 151 | // the following are shared with the CMSThread |
duke@435 | 152 | SLT_msg_type _buffer; // communication buffer |
duke@435 | 153 | Monitor _monitor; // monitor controlling buffer |
duke@435 | 154 | BasicLock _basicLock; // used for PLL locking |
duke@435 | 155 | |
duke@435 | 156 | public: |
duke@435 | 157 | static SurrogateLockerThread* make(TRAPS); |
duke@435 | 158 | |
duke@435 | 159 | SurrogateLockerThread(); |
duke@435 | 160 | |
duke@435 | 161 | bool is_hidden_from_external_view() const { return true; } |
duke@435 | 162 | |
duke@435 | 163 | void loop(); // main method |
duke@435 | 164 | |
duke@435 | 165 | void manipulatePLL(SLT_msg_type msg); |
duke@435 | 166 | |
duke@435 | 167 | }; |