Mon, 12 Mar 2012 14:59:00 -0700
7147724: G1: hang in SurrogateLockerThread::manipulatePLL
Summary: Attempting to initiate a marking cycle when allocating a humongous object can, if a marking cycle is successfully initiated by another thread, result in the allocating thread spinning until the marking cycle is complete. Eliminate a deadlock between the main ConcurrentMarkThread, the SurrogateLocker thread, the VM thread, and a mutator thread waiting on the SecondaryFreeList_lock (while free regions are going to become available) by not manipulating the pending list lock during the prologue and epilogue of the cleanup pause.
Reviewed-by: brutisso, jcoomes, tonyp
tonyp@2968 | 1 | /* |
tonyp@3416 | 2 | * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
tonyp@2968 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
tonyp@2968 | 4 | * |
tonyp@2968 | 5 | * This code is free software; you can redistribute it and/or modify it |
tonyp@2968 | 6 | * under the terms of the GNU General Public License version 2 only, as |
tonyp@2968 | 7 | * published by the Free Software Foundation. |
tonyp@2968 | 8 | * |
tonyp@2968 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
tonyp@2968 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
tonyp@2968 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
tonyp@2968 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
tonyp@2968 | 13 | * accompanied this code). |
tonyp@2968 | 14 | * |
tonyp@2968 | 15 | * You should have received a copy of the GNU General Public License version |
tonyp@2968 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
tonyp@2968 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
tonyp@2968 | 18 | * |
tonyp@2968 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
tonyp@2968 | 20 | * or visit www.oracle.com if you need additional information or have any |
tonyp@2968 | 21 | * questions. |
tonyp@2968 | 22 | * |
tonyp@2968 | 23 | */ |
tonyp@2968 | 24 | |
tonyp@2968 | 25 | #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_INLINE_HPP |
tonyp@2968 | 26 | #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_INLINE_HPP |
tonyp@2968 | 27 | |
tonyp@2968 | 28 | #include "gc_implementation/g1/concurrentMark.hpp" |
tonyp@2968 | 29 | #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" |
tonyp@2968 | 30 | |
johnc@3463 | 31 | // Returns the index in the liveness accounting card bitmap |
johnc@3463 | 32 | // for the given address |
johnc@3463 | 33 | inline BitMap::idx_t ConcurrentMark::card_bitmap_index_for(HeapWord* addr) { |
johnc@3463 | 34 | // Below, the term "card num" means the result of shifting an address |
johnc@3463 | 35 | // by the card shift -- address 0 corresponds to card number 0. One |
johnc@3463 | 36 | // must subtract the card num of the bottom of the heap to obtain a |
johnc@3463 | 37 | // card table index. |
johnc@3463 | 38 | |
johnc@3463 | 39 | intptr_t card_num = intptr_t(uintptr_t(addr) >> CardTableModRefBS::card_shift); |
johnc@3463 | 40 | return card_num - heap_bottom_card_num(); |
johnc@3463 | 41 | } |
johnc@3463 | 42 | |
johnc@3463 | 43 | // Counts the given memory region in the given task/worker |
johnc@3463 | 44 | // counting data structures. |
johnc@3463 | 45 | inline void ConcurrentMark::count_region(MemRegion mr, HeapRegion* hr, |
johnc@3463 | 46 | size_t* marked_bytes_array, |
johnc@3463 | 47 | BitMap* task_card_bm) { |
johnc@3463 | 48 | G1CollectedHeap* g1h = _g1h; |
johnc@3463 | 49 | HeapWord* start = mr.start(); |
johnc@3463 | 50 | HeapWord* last = mr.last(); |
johnc@3463 | 51 | size_t region_size_bytes = mr.byte_size(); |
johnc@3463 | 52 | size_t index = hr->hrs_index(); |
johnc@3463 | 53 | |
johnc@3463 | 54 | assert(!hr->continuesHumongous(), "should not be HC region"); |
johnc@3463 | 55 | assert(hr == g1h->heap_region_containing(start), "sanity"); |
johnc@3463 | 56 | assert(hr == g1h->heap_region_containing(mr.last()), "sanity"); |
johnc@3463 | 57 | assert(marked_bytes_array != NULL, "pre-condition"); |
johnc@3463 | 58 | assert(task_card_bm != NULL, "pre-condition"); |
johnc@3463 | 59 | |
johnc@3463 | 60 | // Add to the task local marked bytes for this region. |
johnc@3463 | 61 | marked_bytes_array[index] += region_size_bytes; |
johnc@3463 | 62 | |
johnc@3463 | 63 | BitMap::idx_t start_idx = card_bitmap_index_for(start); |
johnc@3463 | 64 | BitMap::idx_t last_idx = card_bitmap_index_for(last); |
johnc@3463 | 65 | |
johnc@3463 | 66 | // The card bitmap is task/worker specific => no need to use 'par' routines. |
johnc@3463 | 67 | // Set bits in the inclusive bit range [start_idx, last_idx]. |
johnc@3463 | 68 | // |
johnc@3463 | 69 | // For small ranges use a simple loop; otherwise use set_range |
johnc@3463 | 70 | // The range are the cards that are spanned by the object/region |
johnc@3463 | 71 | // so 8 cards will allow objects/regions up to 4K to be handled |
johnc@3463 | 72 | // using the loop. |
johnc@3463 | 73 | if ((last_idx - start_idx) <= 8) { |
johnc@3463 | 74 | for (BitMap::idx_t i = start_idx; i <= last_idx; i += 1) { |
johnc@3463 | 75 | task_card_bm->set_bit(i); |
johnc@3463 | 76 | } |
johnc@3463 | 77 | } else { |
johnc@3463 | 78 | assert(last_idx < task_card_bm->size(), "sanity"); |
johnc@3463 | 79 | // Note: BitMap::set_range() is exclusive. |
johnc@3463 | 80 | task_card_bm->set_range(start_idx, last_idx+1); |
johnc@3463 | 81 | } |
johnc@3463 | 82 | } |
johnc@3463 | 83 | |
tonyp@3464 | 84 | // Counts the given memory region in the task/worker counting |
tonyp@3464 | 85 | // data structures for the given worker id. |
tonyp@3464 | 86 | inline void ConcurrentMark::count_region(MemRegion mr, |
tonyp@3464 | 87 | HeapRegion* hr, |
tonyp@3464 | 88 | uint worker_id) { |
tonyp@3464 | 89 | size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); |
tonyp@3464 | 90 | BitMap* task_card_bm = count_card_bitmap_for(worker_id); |
tonyp@3464 | 91 | count_region(mr, hr, marked_bytes_array, task_card_bm); |
tonyp@3464 | 92 | } |
tonyp@3464 | 93 | |
johnc@3463 | 94 | // Counts the given memory region, which may be a single object, in the |
johnc@3463 | 95 | // task/worker counting data structures for the given worker id. |
johnc@3463 | 96 | inline void ConcurrentMark::count_region(MemRegion mr, uint worker_id) { |
johnc@3463 | 97 | HeapWord* addr = mr.start(); |
johnc@3463 | 98 | HeapRegion* hr = _g1h->heap_region_containing_raw(addr); |
tonyp@3464 | 99 | count_region(mr, hr, worker_id); |
johnc@3463 | 100 | } |
johnc@3463 | 101 | |
johnc@3463 | 102 | // Counts the given object in the given task/worker counting data structures. |
johnc@3463 | 103 | inline void ConcurrentMark::count_object(oop obj, |
johnc@3463 | 104 | HeapRegion* hr, |
johnc@3463 | 105 | size_t* marked_bytes_array, |
johnc@3463 | 106 | BitMap* task_card_bm) { |
johnc@3463 | 107 | MemRegion mr((HeapWord*)obj, obj->size()); |
johnc@3463 | 108 | count_region(mr, hr, marked_bytes_array, task_card_bm); |
johnc@3463 | 109 | } |
johnc@3463 | 110 | |
johnc@3463 | 111 | // Counts the given object in the task/worker counting data |
johnc@3463 | 112 | // structures for the given worker id. |
tonyp@3464 | 113 | inline void ConcurrentMark::count_object(oop obj, |
tonyp@3464 | 114 | HeapRegion* hr, |
tonyp@3464 | 115 | uint worker_id) { |
johnc@3463 | 116 | size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id); |
johnc@3463 | 117 | BitMap* task_card_bm = count_card_bitmap_for(worker_id); |
johnc@3463 | 118 | HeapWord* addr = (HeapWord*) obj; |
johnc@3463 | 119 | count_object(obj, hr, marked_bytes_array, task_card_bm); |
johnc@3463 | 120 | } |
johnc@3463 | 121 | |
johnc@3463 | 122 | // Attempts to mark the given object and, if successful, counts |
johnc@3463 | 123 | // the object in the given task/worker counting structures. |
johnc@3463 | 124 | inline bool ConcurrentMark::par_mark_and_count(oop obj, |
johnc@3463 | 125 | HeapRegion* hr, |
johnc@3463 | 126 | size_t* marked_bytes_array, |
johnc@3463 | 127 | BitMap* task_card_bm) { |
johnc@3463 | 128 | HeapWord* addr = (HeapWord*)obj; |
johnc@3463 | 129 | if (_nextMarkBitMap->parMark(addr)) { |
johnc@3463 | 130 | // Update the task specific count data for the object. |
johnc@3463 | 131 | count_object(obj, hr, marked_bytes_array, task_card_bm); |
johnc@3463 | 132 | return true; |
johnc@3463 | 133 | } |
johnc@3463 | 134 | return false; |
johnc@3463 | 135 | } |
johnc@3463 | 136 | |
johnc@3463 | 137 | // Attempts to mark the given object and, if successful, counts |
johnc@3463 | 138 | // the object in the task/worker counting structures for the |
johnc@3463 | 139 | // given worker id. |
johnc@3463 | 140 | inline bool ConcurrentMark::par_mark_and_count(oop obj, |
tonyp@3464 | 141 | size_t word_size, |
tonyp@3464 | 142 | HeapRegion* hr, |
tonyp@3464 | 143 | uint worker_id) { |
tonyp@3464 | 144 | HeapWord* addr = (HeapWord*)obj; |
tonyp@3464 | 145 | if (_nextMarkBitMap->parMark(addr)) { |
tonyp@3464 | 146 | MemRegion mr(addr, word_size); |
tonyp@3464 | 147 | count_region(mr, hr, worker_id); |
tonyp@3464 | 148 | return true; |
tonyp@3464 | 149 | } |
tonyp@3464 | 150 | return false; |
tonyp@3464 | 151 | } |
tonyp@3464 | 152 | |
tonyp@3464 | 153 | // Attempts to mark the given object and, if successful, counts |
tonyp@3464 | 154 | // the object in the task/worker counting structures for the |
tonyp@3464 | 155 | // given worker id. |
tonyp@3464 | 156 | inline bool ConcurrentMark::par_mark_and_count(oop obj, |
johnc@3463 | 157 | HeapRegion* hr, |
johnc@3463 | 158 | uint worker_id) { |
johnc@3463 | 159 | HeapWord* addr = (HeapWord*)obj; |
johnc@3463 | 160 | if (_nextMarkBitMap->parMark(addr)) { |
johnc@3463 | 161 | // Update the task specific count data for the object. |
johnc@3463 | 162 | count_object(obj, hr, worker_id); |
johnc@3463 | 163 | return true; |
johnc@3463 | 164 | } |
johnc@3463 | 165 | return false; |
johnc@3463 | 166 | } |
johnc@3463 | 167 | |
johnc@3463 | 168 | // As above - but we don't know the heap region containing the |
johnc@3463 | 169 | // object and so have to supply it. |
johnc@3463 | 170 | inline bool ConcurrentMark::par_mark_and_count(oop obj, uint worker_id) { |
johnc@3463 | 171 | HeapWord* addr = (HeapWord*)obj; |
johnc@3463 | 172 | HeapRegion* hr = _g1h->heap_region_containing_raw(addr); |
johnc@3463 | 173 | return par_mark_and_count(obj, hr, worker_id); |
johnc@3463 | 174 | } |
johnc@3463 | 175 | |
johnc@3463 | 176 | // Similar to the above routine but we already know the size, in words, of |
johnc@3463 | 177 | // the object that we wish to mark/count |
johnc@3463 | 178 | inline bool ConcurrentMark::par_mark_and_count(oop obj, |
johnc@3463 | 179 | size_t word_size, |
johnc@3463 | 180 | uint worker_id) { |
johnc@3463 | 181 | HeapWord* addr = (HeapWord*)obj; |
johnc@3463 | 182 | if (_nextMarkBitMap->parMark(addr)) { |
johnc@3463 | 183 | // Update the task specific count data for the object. |
johnc@3463 | 184 | MemRegion mr(addr, word_size); |
johnc@3463 | 185 | count_region(mr, worker_id); |
johnc@3463 | 186 | return true; |
johnc@3463 | 187 | } |
johnc@3463 | 188 | return false; |
johnc@3463 | 189 | } |
johnc@3463 | 190 | |
johnc@3463 | 191 | // Unconditionally mark the given object, and unconditinally count |
johnc@3463 | 192 | // the object in the counting structures for worker id 0. |
johnc@3463 | 193 | // Should *not* be called from parallel code. |
johnc@3463 | 194 | inline bool ConcurrentMark::mark_and_count(oop obj, HeapRegion* hr) { |
johnc@3463 | 195 | HeapWord* addr = (HeapWord*)obj; |
johnc@3463 | 196 | _nextMarkBitMap->mark(addr); |
johnc@3463 | 197 | // Update the task specific count data for the object. |
johnc@3463 | 198 | count_object(obj, hr, 0 /* worker_id */); |
johnc@3463 | 199 | return true; |
johnc@3463 | 200 | } |
johnc@3463 | 201 | |
johnc@3463 | 202 | // As above - but we don't have the heap region containing the |
johnc@3463 | 203 | // object, so we have to supply it. |
johnc@3463 | 204 | inline bool ConcurrentMark::mark_and_count(oop obj) { |
johnc@3463 | 205 | HeapWord* addr = (HeapWord*)obj; |
johnc@3463 | 206 | HeapRegion* hr = _g1h->heap_region_containing_raw(addr); |
johnc@3463 | 207 | return mark_and_count(obj, hr); |
johnc@3463 | 208 | } |
johnc@3463 | 209 | |
johnc@3454 | 210 | inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) { |
johnc@3454 | 211 | HeapWord* start_addr = MAX2(startWord(), mr.start()); |
johnc@3454 | 212 | HeapWord* end_addr = MIN2(endWord(), mr.end()); |
johnc@3454 | 213 | |
johnc@3454 | 214 | if (end_addr > start_addr) { |
johnc@3454 | 215 | // Right-open interval [start-offset, end-offset). |
johnc@3454 | 216 | BitMap::idx_t start_offset = heapWordToOffset(start_addr); |
johnc@3454 | 217 | BitMap::idx_t end_offset = heapWordToOffset(end_addr); |
johnc@3454 | 218 | |
johnc@3454 | 219 | start_offset = _bm.get_next_one_offset(start_offset, end_offset); |
johnc@3454 | 220 | while (start_offset < end_offset) { |
johnc@3454 | 221 | HeapWord* obj_addr = offsetToHeapWord(start_offset); |
johnc@3454 | 222 | oop obj = (oop) obj_addr; |
johnc@3454 | 223 | if (!cl->do_bit(start_offset)) { |
johnc@3454 | 224 | return false; |
johnc@3454 | 225 | } |
johnc@3454 | 226 | HeapWord* next_addr = MIN2(obj_addr + obj->size(), end_addr); |
johnc@3454 | 227 | BitMap::idx_t next_offset = heapWordToOffset(next_addr); |
johnc@3454 | 228 | start_offset = _bm.get_next_one_offset(next_offset, end_offset); |
johnc@3454 | 229 | } |
johnc@3454 | 230 | } |
johnc@3454 | 231 | return true; |
johnc@3454 | 232 | } |
johnc@3454 | 233 | |
johnc@3454 | 234 | inline bool CMBitMapRO::iterate(BitMapClosure* cl) { |
johnc@3454 | 235 | MemRegion mr(startWord(), sizeInWords()); |
johnc@3454 | 236 | return iterate(cl, mr); |
johnc@3454 | 237 | } |
johnc@3454 | 238 | |
tonyp@2968 | 239 | inline void CMTask::push(oop obj) { |
tonyp@2968 | 240 | HeapWord* objAddr = (HeapWord*) obj; |
tonyp@2968 | 241 | assert(_g1h->is_in_g1_reserved(objAddr), "invariant"); |
tonyp@2968 | 242 | assert(!_g1h->is_on_master_free_list( |
tonyp@2968 | 243 | _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant"); |
tonyp@2968 | 244 | assert(!_g1h->is_obj_ill(obj), "invariant"); |
tonyp@2968 | 245 | assert(_nextMarkBitMap->isMarked(objAddr), "invariant"); |
tonyp@2968 | 246 | |
tonyp@2968 | 247 | if (_cm->verbose_high()) { |
tonyp@2968 | 248 | gclog_or_tty->print_cr("[%d] pushing "PTR_FORMAT, _task_id, (void*) obj); |
tonyp@2968 | 249 | } |
tonyp@2968 | 250 | |
tonyp@2968 | 251 | if (!_task_queue->push(obj)) { |
tonyp@2968 | 252 | // The local task queue looks full. We need to push some entries |
tonyp@2968 | 253 | // to the global stack. |
tonyp@2968 | 254 | |
tonyp@2968 | 255 | if (_cm->verbose_medium()) { |
tonyp@2968 | 256 | gclog_or_tty->print_cr("[%d] task queue overflow, " |
tonyp@2968 | 257 | "moving entries to the global stack", |
tonyp@2968 | 258 | _task_id); |
tonyp@2968 | 259 | } |
tonyp@2968 | 260 | move_entries_to_global_stack(); |
tonyp@2968 | 261 | |
tonyp@2968 | 262 | // this should succeed since, even if we overflow the global |
tonyp@2968 | 263 | // stack, we should have definitely removed some entries from the |
tonyp@2968 | 264 | // local queue. So, there must be space on it. |
tonyp@2968 | 265 | bool success = _task_queue->push(obj); |
tonyp@2968 | 266 | assert(success, "invariant"); |
tonyp@2968 | 267 | } |
tonyp@2968 | 268 | |
tonyp@2968 | 269 | statsOnly( int tmp_size = _task_queue->size(); |
tonyp@2973 | 270 | if (tmp_size > _local_max_size) { |
tonyp@2968 | 271 | _local_max_size = tmp_size; |
tonyp@2973 | 272 | } |
tonyp@2968 | 273 | ++_local_pushes ); |
tonyp@2968 | 274 | } |
tonyp@2968 | 275 | |
tonyp@2968 | 276 | // This determines whether the method below will check both the local |
tonyp@2968 | 277 | // and global fingers when determining whether to push on the stack a |
tonyp@2968 | 278 | // gray object (value 1) or whether it will only check the global one |
tonyp@2968 | 279 | // (value 0). The tradeoffs are that the former will be a bit more |
tonyp@2968 | 280 | // accurate and possibly push less on the stack, but it might also be |
tonyp@2968 | 281 | // a little bit slower. |
tonyp@2968 | 282 | |
tonyp@2968 | 283 | #define _CHECK_BOTH_FINGERS_ 1 |
tonyp@2968 | 284 | |
tonyp@2968 | 285 | inline void CMTask::deal_with_reference(oop obj) { |
tonyp@2968 | 286 | if (_cm->verbose_high()) { |
tonyp@2968 | 287 | gclog_or_tty->print_cr("[%d] we're dealing with reference = "PTR_FORMAT, |
tonyp@2968 | 288 | _task_id, (void*) obj); |
tonyp@2968 | 289 | } |
tonyp@2968 | 290 | |
tonyp@2968 | 291 | ++_refs_reached; |
tonyp@2968 | 292 | |
tonyp@2968 | 293 | HeapWord* objAddr = (HeapWord*) obj; |
tonyp@2968 | 294 | assert(obj->is_oop_or_null(true /* ignore mark word */), "Error"); |
johnc@3463 | 295 | if (_g1h->is_in_g1_reserved(objAddr)) { |
tonyp@2968 | 296 | assert(obj != NULL, "null check is implicit"); |
tonyp@2968 | 297 | if (!_nextMarkBitMap->isMarked(objAddr)) { |
tonyp@2968 | 298 | // Only get the containing region if the object is not marked on the |
tonyp@2968 | 299 | // bitmap (otherwise, it's a waste of time since we won't do |
tonyp@2968 | 300 | // anything with it). |
tonyp@2968 | 301 | HeapRegion* hr = _g1h->heap_region_containing_raw(obj); |
tonyp@2968 | 302 | if (!hr->obj_allocated_since_next_marking(obj)) { |
tonyp@2968 | 303 | if (_cm->verbose_high()) { |
tonyp@2968 | 304 | gclog_or_tty->print_cr("[%d] "PTR_FORMAT" is not considered marked", |
tonyp@2968 | 305 | _task_id, (void*) obj); |
tonyp@2968 | 306 | } |
tonyp@2968 | 307 | |
tonyp@2968 | 308 | // we need to mark it first |
johnc@3463 | 309 | if (_cm->par_mark_and_count(obj, hr, _marked_bytes_array, _card_bm)) { |
tonyp@2968 | 310 | // No OrderAccess:store_load() is needed. It is implicit in the |
johnc@3463 | 311 | // CAS done in CMBitMap::parMark() call in the routine above. |
tonyp@2968 | 312 | HeapWord* global_finger = _cm->finger(); |
tonyp@2968 | 313 | |
tonyp@2968 | 314 | #if _CHECK_BOTH_FINGERS_ |
tonyp@2968 | 315 | // we will check both the local and global fingers |
tonyp@2968 | 316 | |
tonyp@2968 | 317 | if (_finger != NULL && objAddr < _finger) { |
tonyp@2968 | 318 | if (_cm->verbose_high()) { |
tonyp@2968 | 319 | gclog_or_tty->print_cr("[%d] below the local finger ("PTR_FORMAT"), " |
tonyp@2968 | 320 | "pushing it", _task_id, _finger); |
tonyp@2968 | 321 | } |
tonyp@2968 | 322 | push(obj); |
tonyp@2968 | 323 | } else if (_curr_region != NULL && objAddr < _region_limit) { |
tonyp@2968 | 324 | // do nothing |
tonyp@2968 | 325 | } else if (objAddr < global_finger) { |
tonyp@2968 | 326 | // Notice that the global finger might be moving forward |
tonyp@2968 | 327 | // concurrently. This is not a problem. In the worst case, we |
tonyp@2968 | 328 | // mark the object while it is above the global finger and, by |
tonyp@2968 | 329 | // the time we read the global finger, it has moved forward |
tonyp@2968 | 330 | // passed this object. In this case, the object will probably |
tonyp@2968 | 331 | // be visited when a task is scanning the region and will also |
tonyp@2968 | 332 | // be pushed on the stack. So, some duplicate work, but no |
tonyp@2968 | 333 | // correctness problems. |
tonyp@2968 | 334 | |
tonyp@2968 | 335 | if (_cm->verbose_high()) { |
tonyp@2968 | 336 | gclog_or_tty->print_cr("[%d] below the global finger " |
tonyp@2968 | 337 | "("PTR_FORMAT"), pushing it", |
tonyp@2968 | 338 | _task_id, global_finger); |
tonyp@2968 | 339 | } |
tonyp@2968 | 340 | push(obj); |
tonyp@2968 | 341 | } else { |
tonyp@2968 | 342 | // do nothing |
tonyp@2968 | 343 | } |
tonyp@2968 | 344 | #else // _CHECK_BOTH_FINGERS_ |
tonyp@2968 | 345 | // we will only check the global finger |
tonyp@2968 | 346 | |
tonyp@2968 | 347 | if (objAddr < global_finger) { |
tonyp@2968 | 348 | // see long comment above |
tonyp@2968 | 349 | |
tonyp@2968 | 350 | if (_cm->verbose_high()) { |
tonyp@2968 | 351 | gclog_or_tty->print_cr("[%d] below the global finger " |
tonyp@2968 | 352 | "("PTR_FORMAT"), pushing it", |
tonyp@2968 | 353 | _task_id, global_finger); |
tonyp@2968 | 354 | } |
tonyp@2968 | 355 | push(obj); |
tonyp@2968 | 356 | } |
tonyp@2968 | 357 | #endif // _CHECK_BOTH_FINGERS_ |
tonyp@2968 | 358 | } |
tonyp@2968 | 359 | } |
tonyp@2968 | 360 | } |
tonyp@2968 | 361 | } |
tonyp@2968 | 362 | } |
tonyp@2968 | 363 | |
tonyp@3416 | 364 | inline void ConcurrentMark::markPrev(oop p) { |
tonyp@3416 | 365 | assert(!_prevMarkBitMap->isMarked((HeapWord*) p), "sanity"); |
tonyp@3416 | 366 | // Note we are overriding the read-only view of the prev map here, via |
tonyp@3416 | 367 | // the cast. |
tonyp@3416 | 368 | ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p); |
tonyp@3416 | 369 | } |
tonyp@3416 | 370 | |
tonyp@3464 | 371 | inline void ConcurrentMark::grayRoot(oop obj, size_t word_size, |
tonyp@3464 | 372 | uint worker_id, HeapRegion* hr) { |
tonyp@3464 | 373 | assert(obj != NULL, "pre-condition"); |
tonyp@3416 | 374 | HeapWord* addr = (HeapWord*) obj; |
tonyp@3464 | 375 | if (hr == NULL) { |
tonyp@3464 | 376 | hr = _g1h->heap_region_containing_raw(addr); |
tonyp@3464 | 377 | } else { |
tonyp@3464 | 378 | assert(hr->is_in(addr), "pre-condition"); |
tonyp@3464 | 379 | } |
tonyp@3464 | 380 | assert(hr != NULL, "sanity"); |
tonyp@3464 | 381 | // Given that we're looking for a region that contains an object |
tonyp@3464 | 382 | // header it's impossible to get back a HC region. |
tonyp@3464 | 383 | assert(!hr->continuesHumongous(), "sanity"); |
tonyp@3416 | 384 | |
tonyp@3416 | 385 | // We cannot assert that word_size == obj->size() given that obj |
tonyp@3416 | 386 | // might not be in a consistent state (another thread might be in |
tonyp@3416 | 387 | // the process of copying it). So the best thing we can do is to |
tonyp@3416 | 388 | // assert that word_size is under an upper bound which is its |
tonyp@3416 | 389 | // containing region's capacity. |
tonyp@3416 | 390 | assert(word_size * HeapWordSize <= hr->capacity(), |
tonyp@3416 | 391 | err_msg("size: "SIZE_FORMAT" capacity: "SIZE_FORMAT" "HR_FORMAT, |
tonyp@3416 | 392 | word_size * HeapWordSize, hr->capacity(), |
tonyp@3416 | 393 | HR_FORMAT_PARAMS(hr))); |
tonyp@3416 | 394 | |
tonyp@3464 | 395 | if (addr < hr->next_top_at_mark_start()) { |
tonyp@3464 | 396 | if (!_nextMarkBitMap->isMarked(addr)) { |
tonyp@3464 | 397 | par_mark_and_count(obj, word_size, hr, worker_id); |
tonyp@3464 | 398 | } |
tonyp@3416 | 399 | } |
tonyp@3416 | 400 | } |
tonyp@3416 | 401 | |
tonyp@2968 | 402 | #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_INLINE_HPP |