Skip to content

Commit 04597a4

Browse files
author
Thomas Schatzl
committed
some attempts to not have TAMSes always be updated for all regions
1 parent 6423698 commit 04597a4

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ HeapRegion* G1CollectedHeap::new_region(size_t word_size,
190190
res = _hrm.allocate_free_region(type, node_index);
191191
}
192192
}
193+
if (res != nullptr) {
194+
concurrent_mark()->clear_statistics(res);
195+
}
193196
return res;
194197
}
195198

@@ -2635,6 +2638,8 @@ void G1CollectedHeap::free_region(HeapRegion* hr, FreeRegionList* free_list) {
26352638
if (free_list != nullptr) {
26362639
free_list->add_ordered(hr);
26372640
}
2641+
2642+
concurrent_mark()->clear_statistics(hr);
26382643
}
26392644

26402645
void G1CollectedHeap::retain_region(HeapRegion* hr) {

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ void G1ConcurrentMark::reset() {
567567

568568
uint max_reserved_regions = _g1h->max_reserved_regions();
569569
for (uint i = 0; i < max_reserved_regions; i++) {
570-
_top_at_mark_starts[i] = _g1h->bottom_addr_for_region(i);
571570
_top_at_rebuild_starts[i] = nullptr;
572571
_region_mark_stats[i].clear();
573572
}
@@ -591,16 +590,6 @@ void G1ConcurrentMark::humongous_object_eagerly_reclaimed(HeapRegion* r) {
591590

592591
// Need to clear mark bit of the humongous object. Doing this unconditionally is fine.
593592
mark_bitmap()->clear(r->bottom());
594-
595-
if (!_g1h->collector_state()->mark_or_rebuild_in_progress()) {
596-
return;
597-
}
598-
599-
// Clear any statistics about the region gathered so far.
600-
_g1h->humongous_obj_regions_iterate(r,
601-
[&] (HeapRegion* r) {
602-
clear_statistics(r);
603-
});
604593
}
605594

606595
void G1ConcurrentMark::reset_marking_for_restart() {
@@ -856,7 +845,7 @@ class G1PreConcurrentStartTask::NoteStartOfMarkTask : public G1AbstractSubTask {
856845

857846
void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work(uint worker_id) {
858847
// Reset marking state.
859-
//_cm->reset();
848+
_cm->reset();
860849
}
861850

862851
class NoteStartOfMarkHRClosure : public HeapRegionClosure {
@@ -868,6 +857,8 @@ class NoteStartOfMarkHRClosure : public HeapRegionClosure {
868857
bool do_heap_region(HeapRegion* r) override {
869858
if (r->is_old_or_humongous() && !r->is_collection_set_candidate()) {
870859
_cm->update_top_at_mark_start(r);
860+
} else {
861+
_cm->reset_top_at_mark_start(r);
871862
}
872863
return false;
873864
}
@@ -886,16 +877,25 @@ G1PreConcurrentStartTask::G1PreConcurrentStartTask(GCCause::Cause cause, G1Concu
886877
G1BatchedTask("Pre Concurrent Start", G1CollectedHeap::heap()->phase_times()) {
887878
add_serial_task(new ResetMarkingStateTask(cm));
888879
add_parallel_task(new NoteStartOfMarkTask());
880+
881+
//cm->invalidate_top_at_mark_starts();
889882
};
890883

884+
#ifdef ASSERT
885+
void G1ConcurrentMark::invalidate_top_at_mark_starts() {
886+
for (uint i = 0; i < G1CollectedHeap::heap()->max_reserved_regions(); i++) {
887+
_top_at_mark_starts[i] = nullptr;
888+
}
889+
}
890+
#endif
891+
891892
void G1ConcurrentMark::pre_concurrent_start(GCCause::Cause cause) {
892893
assert_at_safepoint_on_vm_thread();
893894

894895
G1CollectedHeap::start_codecache_marking_cycle_if_inactive(true /* concurrent_mark_start */);
895896

896897
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_strong);
897898

898-
reset();
899899
G1PreConcurrentStartTask cl(cause, this);
900900
G1CollectedHeap::heap()->run_batch_task(&cl);
901901

@@ -1481,7 +1481,6 @@ class G1ReclaimEmptyRegionsTask : public WorkerTask {
14811481
_g1h->free_region(hr, _local_cleanup_list);
14821482
}
14831483
hr->clear_cardtable();
1484-
_g1h->concurrent_mark()->clear_statistics(hr);
14851484
}
14861485

14871486
return false;
@@ -1942,7 +1941,6 @@ void G1ConcurrentMark::flush_all_task_caches() {
19421941
void G1ConcurrentMark::clear_bitmap_for_region(HeapRegion* hr) {
19431942
assert_at_safepoint();
19441943
_mark_bitmap.clear_range(MemRegion(hr->bottom(), hr->end()));
1945-
reset_top_at_mark_start(hr);
19461944
}
19471945

19481946
HeapRegion* G1ConcurrentMark::claim_region(uint worker_id) {

src/hotspot/share/gc/g1/g1ConcurrentMark.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,8 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
568568
inline HeapWord* top_at_mark_start(uint region) const;
569569
inline bool obj_allocated_since_mark_start(oop obj) const;
570570

571+
void invalidate_top_at_mark_starts() NOT_DEBUG_RETURN;
572+
571573
// Sets the internal top_at_region_start for the given region to current top of the region.
572574
inline void update_top_at_rebuild_start(HeapRegion* r);
573575
// TARS for the given region during remembered set rebuilding.

src/hotspot/share/gc/g1/g1HeapRegion.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ void HeapRegion::hr_clear(bool clear_space) {
124124

125125
rem_set()->clear();
126126

127-
G1CollectedHeap::heap()->concurrent_mark()->reset_top_at_mark_start(this); // FIXME
128127
_parsable_bottom = bottom();
129128
_garbage_bytes = 0;
130129

src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ inline void HeapRegion::reset_skip_compacting_after_full_gc() {
187187
}
188188

189189
inline void HeapRegion::reset_after_full_gc_common() {
190-
// After a full gc the mark bitmap in a movable region is invalid.
191-
// But all objects are live, we get this by setting TAMS to bottom.
192-
G1CollectedHeap::heap()->concurrent_mark()->reset_top_at_mark_start(this); // FIXME
190+
// After a full gc the mark bitmap in a movable region is invalid. Reset marking
191+
// information.
192+
G1CollectedHeap::heap()->concurrent_mark()->clear_statistics(this); // FIXME?
193193

194194
// Everything above bottom() is parsable and live.
195195
reset_parsable_bottom();

src/hotspot/share/gc/g1/g1YoungGCPostEvacuateTasks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,12 @@ class G1PostEvacuateCollectionSetCleanupTask2::ProcessEvacuationFailedRegionsTas
550550
assert(cm->live_bytes(r->hrm_index()) == 0, "Marking live bytes must not be set for region %u", r->hrm_index());
551551

552552
// Concurrent mark does not mark through regions that we retain (they are root
553-
// regions wrt to marking), so we must clear their mark data (tams, bitmap)
553+
// regions wrt to marking), so we must clear their mark data (tams, bitmap, ...)
554554
// set eagerly or during evacuation failure.
555555
bool clear_mark_data = !g1h->collector_state()->in_concurrent_start_gc() ||
556556
g1h->policy()->should_retain_evac_failed_region(r);
557557

558+
cm->clear_statistics(r);
558559
if (clear_mark_data) {
559560
g1h->clear_bitmap_for_region(r);
560561
} else {

0 commit comments

Comments
 (0)