52 53 if (TraceBlockOffsetTable) { 54 gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: "); 55 gclog_or_tty->print_cr(" " 56 " rs.base(): " PTR_FORMAT 57 " rs.size(): " SIZE_FORMAT 58 " rs end(): " PTR_FORMAT, 59 p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end())); 60 } 61 } 62 63 bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const { 64 assert(p >= _reserved.start(), "just checking"); 65 size_t delta = pointer_delta(p, _reserved.start()); 66 return (delta & right_n_bits(LogN_words)) == (size_t)NoBits; 67 } 68 69 #ifdef ASSERT 70 void G1BlockOffsetSharedArray::check_index(size_t index, const char* msg) const { 71 assert((index) < (_reserved.word_size() >> LogN_words), 72 err_msg("%s - index: "SIZE_FORMAT", _vs.committed_size: "SIZE_FORMAT, 73 msg, (index), (_reserved.word_size() >> LogN_words))); 74 assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)), 75 err_msg("Index "SIZE_FORMAT" corresponding to "PTR_FORMAT 76 " (%u) is not in committed area.", 77 (index), 78 p2i(address_for_index_raw(index)), 79 G1CollectedHeap::heap()->addr_to_region(address_for_index_raw(index)))); 80 } 81 #endif // ASSERT 82 83 ////////////////////////////////////////////////////////////////////// 84 // G1BlockOffsetArray 85 ////////////////////////////////////////////////////////////////////// 86 87 G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array, 88 MemRegion mr) : 89 G1BlockOffsetTable(mr.start(), mr.end()), 90 _unallocated_block(_bottom), 91 _array(array), _gsp(NULL) { 92 assert(_bottom <= _end, "arguments out of order"); 93 } 94 95 void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) { 413 guarantee(backskip >= 1, "Must be going back at least one card."); 414 415 size_t max_backskip = current_card - start_card; 416 guarantee(backskip <= max_backskip, 417 err_msg("Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT, 418 start_card, current_card, backskip)); 419 420 HeapWord* backskip_address = _array->address_for_index(current_card - backskip); 421 guarantee(backskip_address >= gsp()->bottom(), 422 err_msg("Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT, 423 p2i(gsp()->bottom()), p2i(backskip_address))); 424 } 425 } 426 } 427 428 #ifndef PRODUCT 429 void 430 G1BlockOffsetArray::print_on(outputStream* out) { 431 size_t from_index = _array->index_for(_bottom); 432 size_t to_index = _array->index_for(_end); 433 out->print_cr(">> BOT for area ["PTR_FORMAT","PTR_FORMAT") " 434 "cards ["SIZE_FORMAT","SIZE_FORMAT")", 435 p2i(_bottom), p2i(_end), from_index, to_index); 436 for (size_t i = from_index; i < to_index; ++i) { 437 out->print_cr(" entry "SIZE_FORMAT_W(8)" | "PTR_FORMAT" : %3u", 438 i, p2i(_array->address_for_index(i)), 439 (uint) _array->offset_array(i)); 440 } 441 } 442 #endif // !PRODUCT 443 444 ////////////////////////////////////////////////////////////////////// 445 // G1BlockOffsetArrayContigSpace 446 ////////////////////////////////////////////////////////////////////// 447 448 HeapWord* 449 G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) { 450 assert(_bottom <= addr && addr < _end, 451 "addr must be covered by this Array"); 452 HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); 453 return forward_to_block_containing_addr(q, addr); 454 } 455 456 HeapWord* 457 G1BlockOffsetArrayContigSpace:: 497 _next_offset_index = _array->index_for(_bottom); 498 _next_offset_index++; 499 _next_offset_threshold = 500 _array->address_for_index(_next_offset_index); 501 return _next_offset_threshold; 502 } 503 504 void 505 G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) { 506 assert(new_top <= _end, "_end should have already been updated"); 507 508 // The first BOT entry should have offset 0. 509 reset_bot(); 510 alloc_block(_bottom, new_top); 511 } 512 513 #ifndef PRODUCT 514 void 515 G1BlockOffsetArrayContigSpace::print_on(outputStream* out) { 516 G1BlockOffsetArray::print_on(out); 517 out->print_cr(" next offset threshold: "PTR_FORMAT, p2i(_next_offset_threshold)); 518 out->print_cr(" next offset index: "SIZE_FORMAT, _next_offset_index); 519 } 520 #endif // !PRODUCT | 52 53 if (TraceBlockOffsetTable) { 54 gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: "); 55 gclog_or_tty->print_cr(" " 56 " rs.base(): " PTR_FORMAT 57 " rs.size(): " SIZE_FORMAT 58 " rs end(): " PTR_FORMAT, 59 p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end())); 60 } 61 } 62 63 bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const { 64 assert(p >= _reserved.start(), "just checking"); 65 size_t delta = pointer_delta(p, _reserved.start()); 66 return (delta & right_n_bits(LogN_words)) == (size_t)NoBits; 67 } 68 69 #ifdef ASSERT 70 void G1BlockOffsetSharedArray::check_index(size_t index, const char* msg) const { 71 assert((index) < (_reserved.word_size() >> LogN_words), 72 err_msg("%s - index: " SIZE_FORMAT ", _vs.committed_size: " SIZE_FORMAT, 73 msg, (index), (_reserved.word_size() >> LogN_words))); 74 assert(G1CollectedHeap::heap()->is_in_exact(address_for_index_raw(index)), 75 err_msg("Index " SIZE_FORMAT " corresponding to " PTR_FORMAT 76 " (%u) is not in committed area.", 77 (index), 78 p2i(address_for_index_raw(index)), 79 G1CollectedHeap::heap()->addr_to_region(address_for_index_raw(index)))); 80 } 81 #endif // ASSERT 82 83 ////////////////////////////////////////////////////////////////////// 84 // G1BlockOffsetArray 85 ////////////////////////////////////////////////////////////////////// 86 87 G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array, 88 MemRegion mr) : 89 G1BlockOffsetTable(mr.start(), mr.end()), 90 _unallocated_block(_bottom), 91 _array(array), _gsp(NULL) { 92 assert(_bottom <= _end, "arguments out of order"); 93 } 94 95 void G1BlockOffsetArray::set_space(G1OffsetTableContigSpace* sp) { 413 guarantee(backskip >= 1, "Must be going back at least one card."); 414 415 size_t max_backskip = current_card - start_card; 416 guarantee(backskip <= max_backskip, 417 err_msg("Going backwards beyond the start_card. start_card: " SIZE_FORMAT " current_card: " SIZE_FORMAT " backskip: " SIZE_FORMAT, 418 start_card, current_card, backskip)); 419 420 HeapWord* backskip_address = _array->address_for_index(current_card - backskip); 421 guarantee(backskip_address >= gsp()->bottom(), 422 err_msg("Going backwards beyond bottom of the region: bottom: " PTR_FORMAT ", backskip_address: " PTR_FORMAT, 423 p2i(gsp()->bottom()), p2i(backskip_address))); 424 } 425 } 426 } 427 428 #ifndef PRODUCT 429 void 430 G1BlockOffsetArray::print_on(outputStream* out) { 431 size_t from_index = _array->index_for(_bottom); 432 size_t to_index = _array->index_for(_end); 433 out->print_cr(">> BOT for area [" PTR_FORMAT "," PTR_FORMAT ") " 434 "cards [" SIZE_FORMAT "," SIZE_FORMAT ")", 435 p2i(_bottom), p2i(_end), from_index, to_index); 436 for (size_t i = from_index; i < to_index; ++i) { 437 out->print_cr(" entry " SIZE_FORMAT_W(8) " | " PTR_FORMAT " : %3u", 438 i, p2i(_array->address_for_index(i)), 439 (uint) _array->offset_array(i)); 440 } 441 } 442 #endif // !PRODUCT 443 444 ////////////////////////////////////////////////////////////////////// 445 // G1BlockOffsetArrayContigSpace 446 ////////////////////////////////////////////////////////////////////// 447 448 HeapWord* 449 G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) { 450 assert(_bottom <= addr && addr < _end, 451 "addr must be covered by this Array"); 452 HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1); 453 return forward_to_block_containing_addr(q, addr); 454 } 455 456 HeapWord* 457 G1BlockOffsetArrayContigSpace:: 497 _next_offset_index = _array->index_for(_bottom); 498 _next_offset_index++; 499 _next_offset_threshold = 500 _array->address_for_index(_next_offset_index); 501 return _next_offset_threshold; 502 } 503 504 void 505 G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) { 506 assert(new_top <= _end, "_end should have already been updated"); 507 508 // The first BOT entry should have offset 0. 509 reset_bot(); 510 alloc_block(_bottom, new_top); 511 } 512 513 #ifndef PRODUCT 514 void 515 G1BlockOffsetArrayContigSpace::print_on(outputStream* out) { 516 G1BlockOffsetArray::print_on(out); 517 out->print_cr(" next offset threshold: " PTR_FORMAT, p2i(_next_offset_threshold)); 518 out->print_cr(" next offset index: " SIZE_FORMAT, _next_offset_index); 519 } 520 #endif // !PRODUCT |