402
403 void FromCardCache::clear(uint region_idx) {
404 uint num_par_remsets = HeapRegionRemSet::num_par_rem_sets();
405 for (uint i = 0; i < num_par_remsets; i++) {
406 set(i, region_idx, InvalidCard);
407 }
408 }
409
410 void OtherRegionsTable::initialize(uint max_regions) {
411 FromCardCache::initialize(HeapRegionRemSet::num_par_rem_sets(), max_regions);
412 }
413
414 void OtherRegionsTable::invalidate(uint start_idx, size_t num_regions) {
415 FromCardCache::invalidate(start_idx, num_regions);
416 }
417
418 void OtherRegionsTable::print_from_card_cache() {
419 FromCardCache::print();
420 }
421
422 void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) {
423 uint cur_hrm_ind = hr()->hrm_index();
424
425 if (G1TraceHeapRegionRememberedSet) {
426 gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").",
427 from,
428 UseCompressedOops
429 ? (void *)oopDesc::load_decode_heap_oop((narrowOop*)from)
430 : (void *)oopDesc::load_decode_heap_oop((oop*)from));
431 }
432
433 int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift);
434
435 if (G1TraceHeapRegionRememberedSet) {
436 gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = %d)",
437 hr()->bottom(), from_card,
438 FromCardCache::at((uint)tid, cur_hrm_ind));
439 }
440
441 if (FromCardCache::contains_or_replace((uint)tid, cur_hrm_ind, from_card)) {
442 if (G1TraceHeapRegionRememberedSet) {
443 gclog_or_tty->print_cr(" from-card cache hit.");
444 }
445 assert(contains_reference(from), "We just added it!");
446 return;
447 }
448
449 // Note that this may be a continued H region.
450 HeapRegion* from_hr = _g1h->heap_region_containing_raw(from);
451 RegionIdx_t from_hrm_ind = (RegionIdx_t) from_hr->hrm_index();
452
453 // If the region is already coarsened, return.
454 if (_coarse_map.at(from_hrm_ind)) {
455 if (G1TraceHeapRegionRememberedSet) {
456 gclog_or_tty->print_cr(" coarse map hit.");
457 }
458 assert(contains_reference(from), "We just added it!");
459 return;
460 }
461
476 "Must be in range.");
477 if (G1HRRSUseSparseTable &&
478 _sparse_table.add_card(from_hrm_ind, card_index)) {
479 if (G1RecordHRRSOops) {
480 HeapRegionRemSet::record(hr(), from);
481 if (G1TraceHeapRegionRememberedSet) {
482 gclog_or_tty->print(" Added card " PTR_FORMAT " to region "
483 "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
484 align_size_down(uintptr_t(from),
485 CardTableModRefBS::card_size),
486 hr()->bottom(), from);
487 }
488 }
489 if (G1TraceHeapRegionRememberedSet) {
490 gclog_or_tty->print_cr(" added card to sparse table.");
491 }
492 assert(contains_reference_locked(from), "We just added it!");
493 return;
494 } else {
495 if (G1TraceHeapRegionRememberedSet) {
496 gclog_or_tty->print_cr(" [tid %d] sparse table entry "
497 "overflow(f: %d, t: %u)",
498 tid, from_hrm_ind, cur_hrm_ind);
499 }
500 }
501
502 if (_n_fine_entries == _max_fine_entries) {
503 prt = delete_region_table();
504 // There is no need to clear the links to the 'all' list here:
505 // prt will be reused immediately, i.e. remain in the 'all' list.
506 prt->init(from_hr, false /* clear_links_to_all_list */);
507 } else {
508 prt = PerRegionTable::alloc(from_hr);
509 link_to_all(prt);
510 }
511
512 PerRegionTable* first_prt = _fine_grain_regions[ind];
513 prt->set_collision_list_next(first_prt);
514 _fine_grain_regions[ind] = prt;
515 _n_fine_entries++;
516
|
402
403 void FromCardCache::clear(uint region_idx) {
404 uint num_par_remsets = HeapRegionRemSet::num_par_rem_sets();
405 for (uint i = 0; i < num_par_remsets; i++) {
406 set(i, region_idx, InvalidCard);
407 }
408 }
409
410 void OtherRegionsTable::initialize(uint max_regions) {
411 FromCardCache::initialize(HeapRegionRemSet::num_par_rem_sets(), max_regions);
412 }
413
414 void OtherRegionsTable::invalidate(uint start_idx, size_t num_regions) {
415 FromCardCache::invalidate(start_idx, num_regions);
416 }
417
418 void OtherRegionsTable::print_from_card_cache() {
419 FromCardCache::print();
420 }
421
422 void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) {
423 uint cur_hrm_ind = hr()->hrm_index();
424
425 if (G1TraceHeapRegionRememberedSet) {
426 gclog_or_tty->print_cr("ORT::add_reference_work(" PTR_FORMAT "->" PTR_FORMAT ").",
427 from,
428 UseCompressedOops
429 ? (void *)oopDesc::load_decode_heap_oop((narrowOop*)from)
430 : (void *)oopDesc::load_decode_heap_oop((oop*)from));
431 }
432
433 int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift);
434
435 if (G1TraceHeapRegionRememberedSet) {
436 gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = %d)",
437 hr()->bottom(), from_card,
438 FromCardCache::at(tid, cur_hrm_ind));
439 }
440
441 if (FromCardCache::contains_or_replace(tid, cur_hrm_ind, from_card)) {
442 if (G1TraceHeapRegionRememberedSet) {
443 gclog_or_tty->print_cr(" from-card cache hit.");
444 }
445 assert(contains_reference(from), "We just added it!");
446 return;
447 }
448
449 // Note that this may be a continued H region.
450 HeapRegion* from_hr = _g1h->heap_region_containing_raw(from);
451 RegionIdx_t from_hrm_ind = (RegionIdx_t) from_hr->hrm_index();
452
453 // If the region is already coarsened, return.
454 if (_coarse_map.at(from_hrm_ind)) {
455 if (G1TraceHeapRegionRememberedSet) {
456 gclog_or_tty->print_cr(" coarse map hit.");
457 }
458 assert(contains_reference(from), "We just added it!");
459 return;
460 }
461
476 "Must be in range.");
477 if (G1HRRSUseSparseTable &&
478 _sparse_table.add_card(from_hrm_ind, card_index)) {
479 if (G1RecordHRRSOops) {
480 HeapRegionRemSet::record(hr(), from);
481 if (G1TraceHeapRegionRememberedSet) {
482 gclog_or_tty->print(" Added card " PTR_FORMAT " to region "
483 "[" PTR_FORMAT "...) for ref " PTR_FORMAT ".\n",
484 align_size_down(uintptr_t(from),
485 CardTableModRefBS::card_size),
486 hr()->bottom(), from);
487 }
488 }
489 if (G1TraceHeapRegionRememberedSet) {
490 gclog_or_tty->print_cr(" added card to sparse table.");
491 }
492 assert(contains_reference_locked(from), "We just added it!");
493 return;
494 } else {
495 if (G1TraceHeapRegionRememberedSet) {
496 gclog_or_tty->print_cr(" [tid %u] sparse table entry "
497 "overflow(f: %d, t: %u)",
498 tid, from_hrm_ind, cur_hrm_ind);
499 }
500 }
501
502 if (_n_fine_entries == _max_fine_entries) {
503 prt = delete_region_table();
504 // There is no need to clear the links to the 'all' list here:
505 // prt will be reused immediately, i.e. remain in the 'all' list.
506 prt->init(from_hr, false /* clear_links_to_all_list */);
507 } else {
508 prt = PerRegionTable::alloc(from_hr);
509 link_to_all(prt);
510 }
511
512 PerRegionTable* first_prt = _fine_grain_regions[ind];
513 prt->set_collision_list_next(first_prt);
514 _fine_grain_regions[ind] = prt;
515 _n_fine_entries++;
516
|