@@ -2563,10 +2563,12 @@ void G1CollectedHeap::verify_region_attr_is_remset_tracked() {
25632563 public:
25642564 virtual bool do_heap_region (G1HeapRegion* r) {
25652565 G1CollectedHeap* g1h = G1CollectedHeap::heap ();
2566- const bool is_remset_tracked = g1h->region_attr (r->bottom ()).is_remset_tracked ();
2567- assert (r->rem_set ()->is_tracked () == is_remset_tracked,
2568- " Region %u remset tracking status (%s) different to region attribute (%s)" ,
2569- r->hrm_index (), BOOL_TO_STR (r->rem_set ()->is_tracked ()), BOOL_TO_STR (is_remset_tracked));
2566+ G1HeapRegionAttr attr = g1h->region_attr (r->bottom ());
2567+ bool const is_remset_tracked = attr.is_remset_tracked ();
2568+ assert ((r->rem_set ()->is_tracked () == is_remset_tracked) ||
2569+ (attr.is_new_survivor () && is_remset_tracked),
2570+ " Region %u (%s) remset tracking status (%s) different to region attribute (%s)" ,
2571+ r->hrm_index (), r->get_type_str (), BOOL_TO_STR (r->rem_set ()->is_tracked ()), BOOL_TO_STR (is_remset_tracked));
25702572 return false ;
25712573 }
25722574 } cl;
@@ -3105,9 +3107,8 @@ G1HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size,
31053107 new_alloc_region->set_eden ();
31063108 _eden.add (new_alloc_region);
31073109 _policy->set_region_eden (new_alloc_region);
3108- _policy->remset_tracker ()->update_at_allocate (new_alloc_region);
3109- // Install the group cardset.
3110- young_regions_cset_group ()->add (new_alloc_region);
3110+
3111+ collection_set ()->add_eden_region (new_alloc_region);
31113112 G1HeapRegionPrinter::alloc (new_alloc_region);
31123113 return new_alloc_region;
31133114 }
@@ -3120,7 +3121,6 @@ void G1CollectedHeap::retire_mutator_alloc_region(G1HeapRegion* alloc_region,
31203121 assert_heap_locked_or_at_safepoint (true /* should_be_vm_thread */ );
31213122 assert (alloc_region->is_eden (), " all mutator alloc regions should be eden" );
31223123
3123- collection_set ()->add_eden_region (alloc_region);
31243124 increase_used (allocated_bytes);
31253125 _eden.add_used_bytes (allocated_bytes);
31263126 G1HeapRegionPrinter::retire (alloc_region);
@@ -3164,14 +3164,20 @@ G1HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size, G1HeapRegio
31643164 if (type.is_survivor ()) {
31653165 new_alloc_region->set_survivor ();
31663166 _survivor.add (new_alloc_region);
3167+ // The remembered set/group cardset for this region will be installed at the
3168+ // end of GC. Cannot do that right now because we still need the current young
3169+ // gen cardset group.
3170+ // However, register with the attribute table to collect remembered set entries
3171+ // immediately as it is the only source for determining the need for remembered
3172+ // set tracking during GC.
31673173 register_new_survivor_region_with_region_attr (new_alloc_region);
3168- // Install the group cardset.
3169- young_regions_cset_group ()->add (new_alloc_region);
31703174 } else {
31713175 new_alloc_region->set_old ();
3176+ // Update remembered set/cardset.
3177+ _policy->remset_tracker ()->update_at_allocate (new_alloc_region);
3178+ // Synchronize with region attribute table.
31723179 update_region_attr (new_alloc_region);
31733180 }
3174- _policy->remset_tracker ()->update_at_allocate (new_alloc_region);
31753181 G1HeapRegionPrinter::alloc (new_alloc_region);
31763182 return new_alloc_region;
31773183 }
0 commit comments