Mon, 09 Jun 2008 07:18:59 -0700
6711930: NUMA allocator: ParOld can create a hole less than minimal object size in the lgrp chunk
Summary: The fix takes care of three issues that can create a hole less a minimal object in the lgrp chunk
Reviewed-by: ysr, apetrusenko
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1997-2007 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 ReferenceProcessor; |
duke@435 | 26 | |
duke@435 | 27 | // MarkSweep takes care of global mark-compact garbage collection for a |
duke@435 | 28 | // GenCollectedHeap using a four-phase pointer forwarding algorithm. All |
duke@435 | 29 | // generations are assumed to support marking; those that can also support |
duke@435 | 30 | // compaction. |
duke@435 | 31 | // |
duke@435 | 32 | // Class unloading will only occur when a full gc is invoked. |
duke@435 | 33 | |
duke@435 | 34 | // If VALIDATE_MARK_SWEEP is defined, the -XX:+ValidateMarkSweep flag will |
duke@435 | 35 | // be operational, and will provide slow but comprehensive self-checks within |
duke@435 | 36 | // the GC. This is not enabled by default in product or release builds, |
duke@435 | 37 | // since the extra call to track_adjusted_pointer() in _adjust_pointer() |
duke@435 | 38 | // would be too much overhead, and would disturb performance measurement. |
duke@435 | 39 | // However, debug builds are sometimes way too slow to run GC tests! |
duke@435 | 40 | #ifdef ASSERT |
duke@435 | 41 | #define VALIDATE_MARK_SWEEP 1 |
duke@435 | 42 | #endif |
duke@435 | 43 | #ifdef VALIDATE_MARK_SWEEP |
duke@435 | 44 | #define VALIDATE_MARK_SWEEP_ONLY(code) code |
duke@435 | 45 | #else |
duke@435 | 46 | #define VALIDATE_MARK_SWEEP_ONLY(code) |
duke@435 | 47 | #endif |
duke@435 | 48 | |
duke@435 | 49 | // declared at end |
duke@435 | 50 | class PreservedMark; |
duke@435 | 51 | |
duke@435 | 52 | class MarkSweep : AllStatic { |
duke@435 | 53 | // |
coleenp@548 | 54 | // Inline closure decls |
duke@435 | 55 | // |
coleenp@548 | 56 | class FollowRootClosure: public OopsInGenClosure { |
duke@435 | 57 | public: |
coleenp@548 | 58 | virtual void do_oop(oop* p); |
coleenp@548 | 59 | virtual void do_oop(narrowOop* p); |
duke@435 | 60 | virtual const bool do_nmethods() const { return true; } |
duke@435 | 61 | }; |
duke@435 | 62 | |
duke@435 | 63 | class MarkAndPushClosure: public OopClosure { |
duke@435 | 64 | public: |
coleenp@548 | 65 | virtual void do_oop(oop* p); |
coleenp@548 | 66 | virtual void do_oop(narrowOop* p); |
duke@435 | 67 | virtual const bool do_nmethods() const { return true; } |
duke@435 | 68 | }; |
duke@435 | 69 | |
duke@435 | 70 | class FollowStackClosure: public VoidClosure { |
duke@435 | 71 | public: |
coleenp@548 | 72 | virtual void do_void(); |
duke@435 | 73 | }; |
duke@435 | 74 | |
duke@435 | 75 | class AdjustPointerClosure: public OopsInGenClosure { |
coleenp@548 | 76 | private: |
duke@435 | 77 | bool _is_root; |
duke@435 | 78 | public: |
duke@435 | 79 | AdjustPointerClosure(bool is_root) : _is_root(is_root) {} |
coleenp@548 | 80 | virtual void do_oop(oop* p); |
coleenp@548 | 81 | virtual void do_oop(narrowOop* p); |
duke@435 | 82 | }; |
duke@435 | 83 | |
duke@435 | 84 | // Used for java/lang/ref handling |
duke@435 | 85 | class IsAliveClosure: public BoolObjectClosure { |
duke@435 | 86 | public: |
coleenp@548 | 87 | virtual void do_object(oop p); |
coleenp@548 | 88 | virtual bool do_object_b(oop p); |
duke@435 | 89 | }; |
duke@435 | 90 | |
duke@435 | 91 | class KeepAliveClosure: public OopClosure { |
coleenp@548 | 92 | protected: |
coleenp@548 | 93 | template <class T> void do_oop_work(T* p); |
duke@435 | 94 | public: |
coleenp@548 | 95 | virtual void do_oop(oop* p); |
coleenp@548 | 96 | virtual void do_oop(narrowOop* p); |
duke@435 | 97 | }; |
duke@435 | 98 | |
duke@435 | 99 | // |
duke@435 | 100 | // Friend decls |
duke@435 | 101 | // |
duke@435 | 102 | friend class AdjustPointerClosure; |
duke@435 | 103 | friend class KeepAliveClosure; |
duke@435 | 104 | friend class VM_MarkSweep; |
duke@435 | 105 | friend void marksweep_init(); |
duke@435 | 106 | |
duke@435 | 107 | // |
duke@435 | 108 | // Vars |
duke@435 | 109 | // |
duke@435 | 110 | protected: |
duke@435 | 111 | // Traversal stack used during phase1 |
duke@435 | 112 | static GrowableArray<oop>* _marking_stack; |
duke@435 | 113 | // Stack for live klasses to revisit at end of marking phase |
duke@435 | 114 | static GrowableArray<Klass*>* _revisit_klass_stack; |
duke@435 | 115 | |
duke@435 | 116 | // Space for storing/restoring mark word |
duke@435 | 117 | static GrowableArray<markOop>* _preserved_mark_stack; |
duke@435 | 118 | static GrowableArray<oop>* _preserved_oop_stack; |
duke@435 | 119 | static size_t _preserved_count; |
duke@435 | 120 | static size_t _preserved_count_max; |
duke@435 | 121 | static PreservedMark* _preserved_marks; |
duke@435 | 122 | |
duke@435 | 123 | // Reference processing (used in ...follow_contents) |
duke@435 | 124 | static ReferenceProcessor* _ref_processor; |
duke@435 | 125 | |
duke@435 | 126 | #ifdef VALIDATE_MARK_SWEEP |
coleenp@548 | 127 | static GrowableArray<void*>* _root_refs_stack; |
duke@435 | 128 | static GrowableArray<oop> * _live_oops; |
duke@435 | 129 | static GrowableArray<oop> * _live_oops_moved_to; |
duke@435 | 130 | static GrowableArray<size_t>* _live_oops_size; |
duke@435 | 131 | static size_t _live_oops_index; |
duke@435 | 132 | static size_t _live_oops_index_at_perm; |
coleenp@548 | 133 | static GrowableArray<void*>* _other_refs_stack; |
coleenp@548 | 134 | static GrowableArray<void*>* _adjusted_pointers; |
duke@435 | 135 | static bool _pointer_tracking; |
duke@435 | 136 | static bool _root_tracking; |
duke@435 | 137 | |
duke@435 | 138 | // The following arrays are saved since the time of the last GC and |
duke@435 | 139 | // assist in tracking down problems where someone has done an errant |
duke@435 | 140 | // store into the heap, usually to an oop that wasn't properly |
duke@435 | 141 | // handleized across a GC. If we crash or otherwise fail before the |
duke@435 | 142 | // next GC, we can query these arrays to find out the object we had |
duke@435 | 143 | // intended to do the store to (assuming it is still alive) and the |
duke@435 | 144 | // offset within that object. Covered under RecordMarkSweepCompaction. |
duke@435 | 145 | static GrowableArray<HeapWord*> * _cur_gc_live_oops; |
duke@435 | 146 | static GrowableArray<HeapWord*> * _cur_gc_live_oops_moved_to; |
duke@435 | 147 | static GrowableArray<size_t>* _cur_gc_live_oops_size; |
duke@435 | 148 | static GrowableArray<HeapWord*> * _last_gc_live_oops; |
duke@435 | 149 | static GrowableArray<HeapWord*> * _last_gc_live_oops_moved_to; |
duke@435 | 150 | static GrowableArray<size_t>* _last_gc_live_oops_size; |
duke@435 | 151 | #endif |
duke@435 | 152 | |
duke@435 | 153 | // Non public closures |
coleenp@548 | 154 | static IsAliveClosure is_alive; |
duke@435 | 155 | static KeepAliveClosure keep_alive; |
duke@435 | 156 | |
duke@435 | 157 | // Class unloading. Update subklass/sibling/implementor links at end of marking phase. |
duke@435 | 158 | static void follow_weak_klass_links(); |
duke@435 | 159 | |
duke@435 | 160 | // Debugging |
duke@435 | 161 | static void trace(const char* msg) PRODUCT_RETURN; |
duke@435 | 162 | |
duke@435 | 163 | public: |
duke@435 | 164 | // Public closures |
coleenp@548 | 165 | static FollowRootClosure follow_root_closure; |
coleenp@548 | 166 | static MarkAndPushClosure mark_and_push_closure; |
coleenp@548 | 167 | static FollowStackClosure follow_stack_closure; |
duke@435 | 168 | static AdjustPointerClosure adjust_root_pointer_closure; |
duke@435 | 169 | static AdjustPointerClosure adjust_pointer_closure; |
duke@435 | 170 | |
duke@435 | 171 | // Reference Processing |
duke@435 | 172 | static ReferenceProcessor* const ref_processor() { return _ref_processor; } |
duke@435 | 173 | |
duke@435 | 174 | // Call backs for marking |
duke@435 | 175 | static void mark_object(oop obj); |
coleenp@548 | 176 | // Mark pointer and follow contents. Empty marking stack afterwards. |
coleenp@548 | 177 | template <class T> static inline void follow_root(T* p); |
coleenp@548 | 178 | // Mark pointer and follow contents. |
coleenp@548 | 179 | template <class T> static inline void mark_and_follow(T* p); |
coleenp@548 | 180 | // Check mark and maybe push on marking stack |
coleenp@548 | 181 | template <class T> static inline void mark_and_push(T* p); |
duke@435 | 182 | |
coleenp@548 | 183 | static void follow_stack(); // Empty marking stack. |
duke@435 | 184 | |
coleenp@548 | 185 | static void preserve_mark(oop p, markOop mark); |
coleenp@548 | 186 | // Save the mark word so it can be restored later |
coleenp@548 | 187 | static void adjust_marks(); // Adjust the pointers in the preserved marks table |
coleenp@548 | 188 | static void restore_marks(); // Restore the marks that we saved in preserve_mark |
duke@435 | 189 | |
coleenp@548 | 190 | template <class T> static inline void adjust_pointer(T* p, bool isroot); |
duke@435 | 191 | |
coleenp@548 | 192 | static void adjust_root_pointer(oop* p) { adjust_pointer(p, true); } |
coleenp@548 | 193 | static void adjust_pointer(oop* p) { adjust_pointer(p, false); } |
coleenp@548 | 194 | static void adjust_pointer(narrowOop* p) { adjust_pointer(p, false); } |
duke@435 | 195 | |
duke@435 | 196 | #ifdef VALIDATE_MARK_SWEEP |
coleenp@548 | 197 | static void track_adjusted_pointer(void* p, bool isroot); |
coleenp@548 | 198 | static void check_adjust_pointer(void* p); |
duke@435 | 199 | static void track_interior_pointers(oop obj); |
duke@435 | 200 | static void check_interior_pointers(); |
duke@435 | 201 | |
duke@435 | 202 | static void reset_live_oop_tracking(bool at_perm); |
duke@435 | 203 | static void register_live_oop(oop p, size_t size); |
duke@435 | 204 | static void validate_live_oop(oop p, size_t size); |
duke@435 | 205 | static void live_oop_moved_to(HeapWord* q, size_t size, HeapWord* compaction_top); |
duke@435 | 206 | static void compaction_complete(); |
duke@435 | 207 | |
duke@435 | 208 | // Querying operation of RecordMarkSweepCompaction results. |
duke@435 | 209 | // Finds and prints the current base oop and offset for a word |
duke@435 | 210 | // within an oop that was live during the last GC. Helpful for |
duke@435 | 211 | // tracking down heap stomps. |
duke@435 | 212 | static void print_new_location_of_heap_address(HeapWord* q); |
duke@435 | 213 | #endif |
duke@435 | 214 | |
duke@435 | 215 | // Call backs for class unloading |
duke@435 | 216 | static void revisit_weak_klass_link(Klass* k); // Update subklass/sibling/implementor links at end of marking. |
duke@435 | 217 | }; |
duke@435 | 218 | |
duke@435 | 219 | class PreservedMark VALUE_OBJ_CLASS_SPEC { |
duke@435 | 220 | private: |
duke@435 | 221 | oop _obj; |
duke@435 | 222 | markOop _mark; |
duke@435 | 223 | |
duke@435 | 224 | public: |
duke@435 | 225 | void init(oop obj, markOop mark) { |
duke@435 | 226 | _obj = obj; |
duke@435 | 227 | _mark = mark; |
duke@435 | 228 | } |
duke@435 | 229 | |
duke@435 | 230 | void adjust_pointer() { |
duke@435 | 231 | MarkSweep::adjust_pointer(&_obj); |
duke@435 | 232 | } |
duke@435 | 233 | |
duke@435 | 234 | void restore() { |
duke@435 | 235 | _obj->set_mark(_mark); |
duke@435 | 236 | } |
duke@435 | 237 | }; |