src/share/vm/gc_implementation/g1/concurrentMark.inline.hpp

Thu, 21 Aug 2014 16:44:41 +0200

author
tschatzl
date
Thu, 21 Aug 2014 16:44:41 +0200
changeset 7071
4bfc44ba0d19
parent 7051
1f1d373cd044
child 7091
a8ea2f110d87
permissions
-rw-r--r--

8055098: WB API should be extended to provide information about size and age of object.
Summary: Extend the WhiteBox API to provide information about the size and age of objects. Further add a mechanism to trigger a young GC.
Reviewed-by: tschatzl, sjohanss
Contributed-by: Leonid Mesnik <leonid.mesnik@oracle.com>

tonyp@2968 1 /*
drchase@6680 2 * Copyright (c) 2001, 2014, 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@4123 31 // Utility routine to set an exclusive range of cards on the given
johnc@4123 32 // card liveness bitmap
johnc@4123 33 inline void ConcurrentMark::set_card_bitmap_range(BitMap* card_bm,
johnc@4123 34 BitMap::idx_t start_idx,
johnc@4123 35 BitMap::idx_t end_idx,
johnc@4123 36 bool is_par) {
johnc@4123 37
johnc@4123 38 // Set the exclusive bit range [start_idx, end_idx).
johnc@4123 39 assert((end_idx - start_idx) > 0, "at least one card");
johnc@4123 40 assert(end_idx <= card_bm->size(), "sanity");
johnc@4123 41
johnc@4123 42 // Silently clip the end index
johnc@4123 43 end_idx = MIN2(end_idx, card_bm->size());
johnc@4123 44
johnc@4123 45 // For small ranges use a simple loop; otherwise use set_range or
johnc@4123 46 // use par_at_put_range (if parallel). The range is made up of the
johnc@4123 47 // cards that are spanned by an object/mem region so 8 cards will
johnc@4123 48 // allow up to object sizes up to 4K to be handled using the loop.
johnc@4123 49 if ((end_idx - start_idx) <= 8) {
johnc@4123 50 for (BitMap::idx_t i = start_idx; i < end_idx; i += 1) {
johnc@4123 51 if (is_par) {
johnc@4123 52 card_bm->par_set_bit(i);
johnc@4123 53 } else {
johnc@4123 54 card_bm->set_bit(i);
johnc@4123 55 }
johnc@4123 56 }
johnc@4123 57 } else {
johnc@4123 58 // Note BitMap::par_at_put_range() and BitMap::set_range() are exclusive.
johnc@4123 59 if (is_par) {
johnc@4123 60 card_bm->par_at_put_range(start_idx, end_idx, true);
johnc@4123 61 } else {
johnc@4123 62 card_bm->set_range(start_idx, end_idx);
johnc@4123 63 }
johnc@4123 64 }
johnc@4123 65 }
johnc@4123 66
johnc@3463 67 // Returns the index in the liveness accounting card bitmap
johnc@3463 68 // for the given address
johnc@3463 69 inline BitMap::idx_t ConcurrentMark::card_bitmap_index_for(HeapWord* addr) {
johnc@3463 70 // Below, the term "card num" means the result of shifting an address
johnc@3463 71 // by the card shift -- address 0 corresponds to card number 0. One
johnc@3463 72 // must subtract the card num of the bottom of the heap to obtain a
johnc@3463 73 // card table index.
johnc@3463 74 intptr_t card_num = intptr_t(uintptr_t(addr) >> CardTableModRefBS::card_shift);
johnc@3463 75 return card_num - heap_bottom_card_num();
johnc@3463 76 }
johnc@3463 77
johnc@3463 78 // Counts the given memory region in the given task/worker
johnc@3463 79 // counting data structures.
johnc@3463 80 inline void ConcurrentMark::count_region(MemRegion mr, HeapRegion* hr,
johnc@3463 81 size_t* marked_bytes_array,
johnc@3463 82 BitMap* task_card_bm) {
johnc@3463 83 G1CollectedHeap* g1h = _g1h;
mgerdin@5811 84 CardTableModRefBS* ct_bs = g1h->g1_barrier_set();
johnc@4123 85
johnc@3463 86 HeapWord* start = mr.start();
johnc@4123 87 HeapWord* end = mr.end();
johnc@3463 88 size_t region_size_bytes = mr.byte_size();
tonyp@3713 89 uint index = hr->hrs_index();
johnc@3463 90
johnc@3463 91 assert(!hr->continuesHumongous(), "should not be HC region");
johnc@3463 92 assert(hr == g1h->heap_region_containing(start), "sanity");
johnc@3463 93 assert(hr == g1h->heap_region_containing(mr.last()), "sanity");
johnc@3463 94 assert(marked_bytes_array != NULL, "pre-condition");
johnc@3463 95 assert(task_card_bm != NULL, "pre-condition");
johnc@3463 96
johnc@3463 97 // Add to the task local marked bytes for this region.
johnc@3463 98 marked_bytes_array[index] += region_size_bytes;
johnc@3463 99
johnc@3463 100 BitMap::idx_t start_idx = card_bitmap_index_for(start);
johnc@4123 101 BitMap::idx_t end_idx = card_bitmap_index_for(end);
johnc@3463 102
johnc@4123 103 // Note: if we're looking at the last region in heap - end
johnc@4123 104 // could be actually just beyond the end of the heap; end_idx
johnc@4123 105 // will then correspond to a (non-existent) card that is also
johnc@4123 106 // just beyond the heap.
johnc@4123 107 if (g1h->is_in_g1_reserved(end) && !ct_bs->is_card_aligned(end)) {
johnc@4123 108 // end of region is not card aligned - incremement to cover
johnc@4123 109 // all the cards spanned by the region.
johnc@4123 110 end_idx += 1;
johnc@3463 111 }
johnc@4123 112 // The card bitmap is task/worker specific => no need to use
johnc@4123 113 // the 'par' BitMap routines.
johnc@4123 114 // Set bits in the exclusive bit range [start_idx, end_idx).
johnc@4123 115 set_card_bitmap_range(task_card_bm, start_idx, end_idx, false /* is_par */);
johnc@3463 116 }
johnc@3463 117
tonyp@3464 118 // Counts the given memory region in the task/worker counting
tonyp@3464 119 // data structures for the given worker id.
tonyp@3464 120 inline void ConcurrentMark::count_region(MemRegion mr,
tonyp@3464 121 HeapRegion* hr,
tonyp@3464 122 uint worker_id) {
tonyp@3464 123 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
tonyp@3464 124 BitMap* task_card_bm = count_card_bitmap_for(worker_id);
tonyp@3464 125 count_region(mr, hr, marked_bytes_array, task_card_bm);
tonyp@3464 126 }
tonyp@3464 127
johnc@3463 128 // Counts the given memory region, which may be a single object, in the
johnc@3463 129 // task/worker counting data structures for the given worker id.
johnc@3463 130 inline void ConcurrentMark::count_region(MemRegion mr, uint worker_id) {
johnc@3463 131 HeapWord* addr = mr.start();
johnc@3463 132 HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
tonyp@3464 133 count_region(mr, hr, worker_id);
johnc@3463 134 }
johnc@3463 135
johnc@3463 136 // Counts the given object in the given task/worker counting data structures.
johnc@3463 137 inline void ConcurrentMark::count_object(oop obj,
johnc@3463 138 HeapRegion* hr,
johnc@3463 139 size_t* marked_bytes_array,
johnc@3463 140 BitMap* task_card_bm) {
johnc@3463 141 MemRegion mr((HeapWord*)obj, obj->size());
johnc@3463 142 count_region(mr, hr, marked_bytes_array, task_card_bm);
johnc@3463 143 }
johnc@3463 144
johnc@3463 145 // Counts the given object in the task/worker counting data
johnc@3463 146 // structures for the given worker id.
tonyp@3464 147 inline void ConcurrentMark::count_object(oop obj,
tonyp@3464 148 HeapRegion* hr,
tonyp@3464 149 uint worker_id) {
johnc@3463 150 size_t* marked_bytes_array = count_marked_bytes_array_for(worker_id);
johnc@3463 151 BitMap* task_card_bm = count_card_bitmap_for(worker_id);
johnc@3463 152 HeapWord* addr = (HeapWord*) obj;
johnc@3463 153 count_object(obj, hr, marked_bytes_array, task_card_bm);
johnc@3463 154 }
johnc@3463 155
johnc@3463 156 // Attempts to mark the given object and, if successful, counts
johnc@3463 157 // the object in the given task/worker counting structures.
johnc@3463 158 inline bool ConcurrentMark::par_mark_and_count(oop obj,
johnc@3463 159 HeapRegion* hr,
johnc@3463 160 size_t* marked_bytes_array,
johnc@3463 161 BitMap* task_card_bm) {
johnc@3463 162 HeapWord* addr = (HeapWord*)obj;
johnc@3463 163 if (_nextMarkBitMap->parMark(addr)) {
johnc@3463 164 // Update the task specific count data for the object.
johnc@3463 165 count_object(obj, hr, marked_bytes_array, task_card_bm);
johnc@3463 166 return true;
johnc@3463 167 }
johnc@3463 168 return false;
johnc@3463 169 }
johnc@3463 170
johnc@3463 171 // Attempts to mark the given object and, if successful, counts
johnc@3463 172 // the object in the task/worker counting structures for the
johnc@3463 173 // given worker id.
johnc@3463 174 inline bool ConcurrentMark::par_mark_and_count(oop obj,
tonyp@3464 175 size_t word_size,
tonyp@3464 176 HeapRegion* hr,
tonyp@3464 177 uint worker_id) {
tonyp@3464 178 HeapWord* addr = (HeapWord*)obj;
tonyp@3464 179 if (_nextMarkBitMap->parMark(addr)) {
tonyp@3464 180 MemRegion mr(addr, word_size);
tonyp@3464 181 count_region(mr, hr, worker_id);
tonyp@3464 182 return true;
tonyp@3464 183 }
tonyp@3464 184 return false;
tonyp@3464 185 }
tonyp@3464 186
tonyp@3464 187 // Attempts to mark the given object and, if successful, counts
tonyp@3464 188 // the object in the task/worker counting structures for the
tonyp@3464 189 // given worker id.
tonyp@3464 190 inline bool ConcurrentMark::par_mark_and_count(oop obj,
johnc@3463 191 HeapRegion* hr,
johnc@3463 192 uint worker_id) {
johnc@3463 193 HeapWord* addr = (HeapWord*)obj;
johnc@3463 194 if (_nextMarkBitMap->parMark(addr)) {
johnc@3463 195 // Update the task specific count data for the object.
johnc@3463 196 count_object(obj, hr, worker_id);
johnc@3463 197 return true;
johnc@3463 198 }
johnc@3463 199 return false;
johnc@3463 200 }
johnc@3463 201
johnc@3463 202 // As above - but we don't know the heap region containing the
johnc@3463 203 // object and so have to supply it.
johnc@3463 204 inline bool ConcurrentMark::par_mark_and_count(oop obj, uint worker_id) {
johnc@3463 205 HeapWord* addr = (HeapWord*)obj;
johnc@3463 206 HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
johnc@3463 207 return par_mark_and_count(obj, hr, worker_id);
johnc@3463 208 }
johnc@3463 209
johnc@3463 210 // Similar to the above routine but we already know the size, in words, of
johnc@3463 211 // the object that we wish to mark/count
johnc@3463 212 inline bool ConcurrentMark::par_mark_and_count(oop obj,
johnc@3463 213 size_t word_size,
johnc@3463 214 uint worker_id) {
johnc@3463 215 HeapWord* addr = (HeapWord*)obj;
johnc@3463 216 if (_nextMarkBitMap->parMark(addr)) {
johnc@3463 217 // Update the task specific count data for the object.
johnc@3463 218 MemRegion mr(addr, word_size);
johnc@3463 219 count_region(mr, worker_id);
johnc@3463 220 return true;
johnc@3463 221 }
johnc@3463 222 return false;
johnc@3463 223 }
johnc@3463 224
johnc@3463 225 // Unconditionally mark the given object, and unconditinally count
johnc@3463 226 // the object in the counting structures for worker id 0.
johnc@3463 227 // Should *not* be called from parallel code.
johnc@3463 228 inline bool ConcurrentMark::mark_and_count(oop obj, HeapRegion* hr) {
johnc@3463 229 HeapWord* addr = (HeapWord*)obj;
johnc@3463 230 _nextMarkBitMap->mark(addr);
johnc@3463 231 // Update the task specific count data for the object.
johnc@3463 232 count_object(obj, hr, 0 /* worker_id */);
johnc@3463 233 return true;
johnc@3463 234 }
johnc@3463 235
johnc@3463 236 // As above - but we don't have the heap region containing the
johnc@3463 237 // object, so we have to supply it.
johnc@3463 238 inline bool ConcurrentMark::mark_and_count(oop obj) {
johnc@3463 239 HeapWord* addr = (HeapWord*)obj;
johnc@3463 240 HeapRegion* hr = _g1h->heap_region_containing_raw(addr);
johnc@3463 241 return mark_and_count(obj, hr);
johnc@3463 242 }
johnc@3463 243
johnc@3454 244 inline bool CMBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) {
johnc@3454 245 HeapWord* start_addr = MAX2(startWord(), mr.start());
johnc@3454 246 HeapWord* end_addr = MIN2(endWord(), mr.end());
johnc@3454 247
johnc@3454 248 if (end_addr > start_addr) {
johnc@3454 249 // Right-open interval [start-offset, end-offset).
johnc@3454 250 BitMap::idx_t start_offset = heapWordToOffset(start_addr);
johnc@3454 251 BitMap::idx_t end_offset = heapWordToOffset(end_addr);
johnc@3454 252
johnc@3454 253 start_offset = _bm.get_next_one_offset(start_offset, end_offset);
johnc@3454 254 while (start_offset < end_offset) {
johnc@3454 255 if (!cl->do_bit(start_offset)) {
johnc@3454 256 return false;
johnc@3454 257 }
tamao@4733 258 HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr);
johnc@3454 259 BitMap::idx_t next_offset = heapWordToOffset(next_addr);
johnc@3454 260 start_offset = _bm.get_next_one_offset(next_offset, end_offset);
johnc@3454 261 }
johnc@3454 262 }
johnc@3454 263 return true;
johnc@3454 264 }
johnc@3454 265
johnc@3454 266 inline bool CMBitMapRO::iterate(BitMapClosure* cl) {
johnc@3454 267 MemRegion mr(startWord(), sizeInWords());
johnc@3454 268 return iterate(cl, mr);
johnc@3454 269 }
johnc@3454 270
tschatzl@7051 271 #define check_mark(addr) \
tschatzl@7051 272 assert(_bmStartWord <= (addr) && (addr) < (_bmStartWord + _bmWordSize), \
tschatzl@7051 273 "outside underlying space?"); \
tschatzl@7051 274 assert(G1CollectedHeap::heap()->is_in_exact(addr), \
tschatzl@7051 275 err_msg("Trying to access not available bitmap "PTR_FORMAT \
tschatzl@7051 276 " corresponding to "PTR_FORMAT" (%u)", \
tschatzl@7051 277 p2i(this), p2i(addr), G1CollectedHeap::heap()->addr_to_region(addr)));
tschatzl@7051 278
tschatzl@7051 279 inline void CMBitMap::mark(HeapWord* addr) {
tschatzl@7051 280 check_mark(addr);
tschatzl@7051 281 _bm.set_bit(heapWordToOffset(addr));
tschatzl@7051 282 }
tschatzl@7051 283
tschatzl@7051 284 inline void CMBitMap::clear(HeapWord* addr) {
tschatzl@7051 285 check_mark(addr);
tschatzl@7051 286 _bm.clear_bit(heapWordToOffset(addr));
tschatzl@7051 287 }
tschatzl@7051 288
tschatzl@7051 289 inline bool CMBitMap::parMark(HeapWord* addr) {
tschatzl@7051 290 check_mark(addr);
tschatzl@7051 291 return _bm.par_set_bit(heapWordToOffset(addr));
tschatzl@7051 292 }
tschatzl@7051 293
tschatzl@7051 294 inline bool CMBitMap::parClear(HeapWord* addr) {
tschatzl@7051 295 check_mark(addr);
tschatzl@7051 296 return _bm.par_clear_bit(heapWordToOffset(addr));
tschatzl@7051 297 }
tschatzl@7051 298
tschatzl@7051 299 #undef check_mark
tschatzl@7051 300
tonyp@2968 301 inline void CMTask::push(oop obj) {
tonyp@2968 302 HeapWord* objAddr = (HeapWord*) obj;
tonyp@2968 303 assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
tonyp@2968 304 assert(!_g1h->is_on_master_free_list(
tonyp@2968 305 _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant");
tonyp@2968 306 assert(!_g1h->is_obj_ill(obj), "invariant");
tonyp@2968 307 assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
tonyp@2968 308
tonyp@2968 309 if (_cm->verbose_high()) {
drchase@6680 310 gclog_or_tty->print_cr("[%u] pushing " PTR_FORMAT, _worker_id, p2i((void*) obj));
tonyp@2968 311 }
tonyp@2968 312
tonyp@2968 313 if (!_task_queue->push(obj)) {
tonyp@2968 314 // The local task queue looks full. We need to push some entries
tonyp@2968 315 // to the global stack.
tonyp@2968 316
tonyp@2968 317 if (_cm->verbose_medium()) {
johnc@4173 318 gclog_or_tty->print_cr("[%u] task queue overflow, "
tonyp@2968 319 "moving entries to the global stack",
johnc@4173 320 _worker_id);
tonyp@2968 321 }
tonyp@2968 322 move_entries_to_global_stack();
tonyp@2968 323
tonyp@2968 324 // this should succeed since, even if we overflow the global
tonyp@2968 325 // stack, we should have definitely removed some entries from the
tonyp@2968 326 // local queue. So, there must be space on it.
tonyp@2968 327 bool success = _task_queue->push(obj);
tonyp@2968 328 assert(success, "invariant");
tonyp@2968 329 }
tonyp@2968 330
tonyp@2968 331 statsOnly( int tmp_size = _task_queue->size();
tonyp@2973 332 if (tmp_size > _local_max_size) {
tonyp@2968 333 _local_max_size = tmp_size;
tonyp@2973 334 }
tonyp@2968 335 ++_local_pushes );
tonyp@2968 336 }
tonyp@2968 337
tonyp@2968 338 // This determines whether the method below will check both the local
tonyp@2968 339 // and global fingers when determining whether to push on the stack a
tonyp@2968 340 // gray object (value 1) or whether it will only check the global one
tonyp@2968 341 // (value 0). The tradeoffs are that the former will be a bit more
tonyp@2968 342 // accurate and possibly push less on the stack, but it might also be
tonyp@2968 343 // a little bit slower.
tonyp@2968 344
tonyp@2968 345 #define _CHECK_BOTH_FINGERS_ 1
tonyp@2968 346
tonyp@2968 347 inline void CMTask::deal_with_reference(oop obj) {
tonyp@2968 348 if (_cm->verbose_high()) {
johnc@4173 349 gclog_or_tty->print_cr("[%u] we're dealing with reference = "PTR_FORMAT,
drchase@6680 350 _worker_id, p2i((void*) obj));
tonyp@2968 351 }
tonyp@2968 352
tonyp@2968 353 ++_refs_reached;
tonyp@2968 354
tonyp@2968 355 HeapWord* objAddr = (HeapWord*) obj;
tonyp@2968 356 assert(obj->is_oop_or_null(true /* ignore mark word */), "Error");
johnc@3463 357 if (_g1h->is_in_g1_reserved(objAddr)) {
tonyp@2968 358 assert(obj != NULL, "null check is implicit");
tonyp@2968 359 if (!_nextMarkBitMap->isMarked(objAddr)) {
tonyp@2968 360 // Only get the containing region if the object is not marked on the
tonyp@2968 361 // bitmap (otherwise, it's a waste of time since we won't do
tonyp@2968 362 // anything with it).
tonyp@2968 363 HeapRegion* hr = _g1h->heap_region_containing_raw(obj);
tonyp@2968 364 if (!hr->obj_allocated_since_next_marking(obj)) {
tonyp@2968 365 if (_cm->verbose_high()) {
johnc@4173 366 gclog_or_tty->print_cr("[%u] "PTR_FORMAT" is not considered marked",
drchase@6680 367 _worker_id, p2i((void*) obj));
tonyp@2968 368 }
tonyp@2968 369
tonyp@2968 370 // we need to mark it first
johnc@3463 371 if (_cm->par_mark_and_count(obj, hr, _marked_bytes_array, _card_bm)) {
tonyp@2968 372 // No OrderAccess:store_load() is needed. It is implicit in the
johnc@3463 373 // CAS done in CMBitMap::parMark() call in the routine above.
tonyp@2968 374 HeapWord* global_finger = _cm->finger();
tonyp@2968 375
tonyp@2968 376 #if _CHECK_BOTH_FINGERS_
tonyp@2968 377 // we will check both the local and global fingers
tonyp@2968 378
tonyp@2968 379 if (_finger != NULL && objAddr < _finger) {
tonyp@2968 380 if (_cm->verbose_high()) {
johnc@4173 381 gclog_or_tty->print_cr("[%u] below the local finger ("PTR_FORMAT"), "
drchase@6680 382 "pushing it", _worker_id, p2i(_finger));
tonyp@2968 383 }
tonyp@2968 384 push(obj);
tonyp@2968 385 } else if (_curr_region != NULL && objAddr < _region_limit) {
tonyp@2968 386 // do nothing
tonyp@2968 387 } else if (objAddr < global_finger) {
tonyp@2968 388 // Notice that the global finger might be moving forward
tonyp@2968 389 // concurrently. This is not a problem. In the worst case, we
tonyp@2968 390 // mark the object while it is above the global finger and, by
tonyp@2968 391 // the time we read the global finger, it has moved forward
tonyp@2968 392 // passed this object. In this case, the object will probably
tonyp@2968 393 // be visited when a task is scanning the region and will also
tonyp@2968 394 // be pushed on the stack. So, some duplicate work, but no
tonyp@2968 395 // correctness problems.
tonyp@2968 396
tonyp@2968 397 if (_cm->verbose_high()) {
johnc@4173 398 gclog_or_tty->print_cr("[%u] below the global finger "
tonyp@2968 399 "("PTR_FORMAT"), pushing it",
drchase@6680 400 _worker_id, p2i(global_finger));
tonyp@2968 401 }
tonyp@2968 402 push(obj);
tonyp@2968 403 } else {
tonyp@2968 404 // do nothing
tonyp@2968 405 }
tonyp@2968 406 #else // _CHECK_BOTH_FINGERS_
tonyp@2968 407 // we will only check the global finger
tonyp@2968 408
tonyp@2968 409 if (objAddr < global_finger) {
tonyp@2968 410 // see long comment above
tonyp@2968 411
tonyp@2968 412 if (_cm->verbose_high()) {
johnc@4173 413 gclog_or_tty->print_cr("[%u] below the global finger "
tonyp@2968 414 "("PTR_FORMAT"), pushing it",
drchase@6680 415 _worker_id, p2i(global_finger));
tonyp@2968 416 }
tonyp@2968 417 push(obj);
tonyp@2968 418 }
tonyp@2968 419 #endif // _CHECK_BOTH_FINGERS_
tonyp@2968 420 }
tonyp@2968 421 }
tonyp@2968 422 }
tonyp@2968 423 }
tonyp@2968 424 }
tonyp@2968 425
tonyp@3416 426 inline void ConcurrentMark::markPrev(oop p) {
tonyp@3416 427 assert(!_prevMarkBitMap->isMarked((HeapWord*) p), "sanity");
tonyp@3416 428 // Note we are overriding the read-only view of the prev map here, via
tonyp@3416 429 // the cast.
tonyp@3416 430 ((CMBitMap*)_prevMarkBitMap)->mark((HeapWord*) p);
tonyp@3416 431 }
tonyp@3416 432
tonyp@3464 433 inline void ConcurrentMark::grayRoot(oop obj, size_t word_size,
tonyp@3464 434 uint worker_id, HeapRegion* hr) {
tonyp@3464 435 assert(obj != NULL, "pre-condition");
tonyp@3416 436 HeapWord* addr = (HeapWord*) obj;
tonyp@3464 437 if (hr == NULL) {
tonyp@3464 438 hr = _g1h->heap_region_containing_raw(addr);
tonyp@3464 439 } else {
tonyp@3464 440 assert(hr->is_in(addr), "pre-condition");
tonyp@3464 441 }
tonyp@3464 442 assert(hr != NULL, "sanity");
tonyp@3464 443 // Given that we're looking for a region that contains an object
tonyp@3464 444 // header it's impossible to get back a HC region.
tonyp@3464 445 assert(!hr->continuesHumongous(), "sanity");
tonyp@3416 446
tonyp@3416 447 // We cannot assert that word_size == obj->size() given that obj
tonyp@3416 448 // might not be in a consistent state (another thread might be in
tonyp@3416 449 // the process of copying it). So the best thing we can do is to
tonyp@3416 450 // assert that word_size is under an upper bound which is its
tonyp@3416 451 // containing region's capacity.
tonyp@3416 452 assert(word_size * HeapWordSize <= hr->capacity(),
tonyp@3416 453 err_msg("size: "SIZE_FORMAT" capacity: "SIZE_FORMAT" "HR_FORMAT,
tonyp@3416 454 word_size * HeapWordSize, hr->capacity(),
tonyp@3416 455 HR_FORMAT_PARAMS(hr)));
tonyp@3416 456
tonyp@3464 457 if (addr < hr->next_top_at_mark_start()) {
tonyp@3464 458 if (!_nextMarkBitMap->isMarked(addr)) {
tonyp@3464 459 par_mark_and_count(obj, word_size, hr, worker_id);
tonyp@3464 460 }
tonyp@3416 461 }
tonyp@3416 462 }
tonyp@3416 463
tonyp@2968 464 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_INLINE_HPP

mercurial