445 return; |
445 return; |
446 } |
446 } |
447 |
447 |
448 // Note that this may be a continued H region. |
448 // Note that this may be a continued H region. |
449 HeapRegion* from_hr = _g1h->heap_region_containing_raw(from); |
449 HeapRegion* from_hr = _g1h->heap_region_containing_raw(from); |
450 RegionIdx_t from_hrs_ind = (RegionIdx_t) from_hr->hrm_index(); |
450 RegionIdx_t from_hrm_ind = (RegionIdx_t) from_hr->hrm_index(); |
451 |
451 |
452 // If the region is already coarsened, return. |
452 // If the region is already coarsened, return. |
453 if (_coarse_map.at(from_hrs_ind)) { |
453 if (_coarse_map.at(from_hrm_ind)) { |
454 if (G1TraceHeapRegionRememberedSet) { |
454 if (G1TraceHeapRegionRememberedSet) { |
455 gclog_or_tty->print_cr(" coarse map hit."); |
455 gclog_or_tty->print_cr(" coarse map hit."); |
456 } |
456 } |
457 assert(contains_reference(from), "We just added it!"); |
457 assert(contains_reference(from), "We just added it!"); |
458 return; |
458 return; |
459 } |
459 } |
460 |
460 |
461 // Otherwise find a per-region table to add it to. |
461 // Otherwise find a per-region table to add it to. |
462 size_t ind = from_hrs_ind & _mod_max_fine_entries_mask; |
462 size_t ind = from_hrm_ind & _mod_max_fine_entries_mask; |
463 PerRegionTable* prt = find_region_table(ind, from_hr); |
463 PerRegionTable* prt = find_region_table(ind, from_hr); |
464 if (prt == NULL) { |
464 if (prt == NULL) { |
465 MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); |
465 MutexLockerEx x(_m, Mutex::_no_safepoint_check_flag); |
466 // Confirm that it's really not there... |
466 // Confirm that it's really not there... |
467 prt = find_region_table(ind, from_hr); |
467 prt = find_region_table(ind, from_hr); |
472 >> CardTableModRefBS::card_shift; |
472 >> CardTableModRefBS::card_shift; |
473 CardIdx_t card_index = from_card - from_hr_bot_card_index; |
473 CardIdx_t card_index = from_card - from_hr_bot_card_index; |
474 assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion, |
474 assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion, |
475 "Must be in range."); |
475 "Must be in range."); |
476 if (G1HRRSUseSparseTable && |
476 if (G1HRRSUseSparseTable && |
477 _sparse_table.add_card(from_hrs_ind, card_index)) { |
477 _sparse_table.add_card(from_hrm_ind, card_index)) { |
478 if (G1RecordHRRSOops) { |
478 if (G1RecordHRRSOops) { |
479 HeapRegionRemSet::record(hr(), from); |
479 HeapRegionRemSet::record(hr(), from); |
480 if (G1TraceHeapRegionRememberedSet) { |
480 if (G1TraceHeapRegionRememberedSet) { |
481 gclog_or_tty->print(" Added card " PTR_FORMAT " to region " |
481 gclog_or_tty->print(" Added card " PTR_FORMAT " to region " |
482 "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n", |
482 "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n", |
492 return; |
492 return; |
493 } else { |
493 } else { |
494 if (G1TraceHeapRegionRememberedSet) { |
494 if (G1TraceHeapRegionRememberedSet) { |
495 gclog_or_tty->print_cr(" [tid %d] sparse table entry " |
495 gclog_or_tty->print_cr(" [tid %d] sparse table entry " |
496 "overflow(f: %d, t: %u)", |
496 "overflow(f: %d, t: %u)", |
497 tid, from_hrs_ind, cur_hrm_ind); |
497 tid, from_hrm_ind, cur_hrm_ind); |
498 } |
498 } |
499 } |
499 } |
500 |
500 |
501 if (_n_fine_entries == _max_fine_entries) { |
501 if (_n_fine_entries == _max_fine_entries) { |
502 prt = delete_region_table(); |
502 prt = delete_region_table(); |
513 _fine_grain_regions[ind] = prt; |
513 _fine_grain_regions[ind] = prt; |
514 _n_fine_entries++; |
514 _n_fine_entries++; |
515 |
515 |
516 if (G1HRRSUseSparseTable) { |
516 if (G1HRRSUseSparseTable) { |
517 // Transfer from sparse to fine-grain. |
517 // Transfer from sparse to fine-grain. |
518 SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrs_ind); |
518 SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrm_ind); |
519 assert(sprt_entry != NULL, "There should have been an entry"); |
519 assert(sprt_entry != NULL, "There should have been an entry"); |
520 for (int i = 0; i < SparsePRTEntry::cards_num(); i++) { |
520 for (int i = 0; i < SparsePRTEntry::cards_num(); i++) { |
521 CardIdx_t c = sprt_entry->card(i); |
521 CardIdx_t c = sprt_entry->card(i); |
522 if (c != SparsePRTEntry::NullEntry) { |
522 if (c != SparsePRTEntry::NullEntry) { |
523 prt->add_card(c); |
523 prt->add_card(c); |
524 } |
524 } |
525 } |
525 } |
526 // Now we can delete the sparse entry. |
526 // Now we can delete the sparse entry. |
527 bool res = _sparse_table.delete_entry(from_hrs_ind); |
527 bool res = _sparse_table.delete_entry(from_hrm_ind); |
528 assert(res, "It should have been there."); |
528 assert(res, "It should have been there."); |
529 } |
529 } |
530 } |
530 } |
531 assert(prt != NULL && prt->hr() == from_hr, "consequence"); |
531 assert(prt != NULL && prt->hr() == from_hr, "consequence"); |
532 } |
532 } |