Skip to content

Commit 17fd801

Browse files
author
Thomas Schatzl
committed
8370807: G1: Improve region attribute table method naming
Reviewed-by: ayang, sjohanss, iwalulya
1 parent 87a4772 commit 17fd801

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3159,9 +3159,9 @@ G1HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size, G1HeapRegio
31593159
young_regions_cset_group()->add(new_alloc_region);
31603160
} else {
31613161
new_alloc_region->set_old();
3162+
update_region_attr(new_alloc_region);
31623163
}
31633164
_policy->remset_tracker()->update_at_allocate(new_alloc_region);
3164-
register_region_with_region_attr(new_alloc_region);
31653165
G1HeapRegionPrinter::alloc(new_alloc_region);
31663166
return new_alloc_region;
31673167
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,17 @@ class G1CollectedHeap : public CollectedHeap {
645645
size_t word_size,
646646
bool update_remsets);
647647

648-
// We register a region with the fast "in collection set" test. We
649-
// simply set to true the array slot corresponding to this region.
650-
void register_young_region_with_region_attr(G1HeapRegion* r) {
651-
_region_attr.set_in_young(r->hrm_index(), r->has_pinned_objects());
652-
}
648+
// The following methods update the region attribute table, i.e. a compact
649+
// representation of per-region information that is regularly accessed
650+
// during GC.
651+
inline void register_young_region_with_region_attr(G1HeapRegion* r);
653652
inline void register_new_survivor_region_with_region_attr(G1HeapRegion* r);
654-
inline void register_region_with_region_attr(G1HeapRegion* r);
655-
inline void register_old_region_with_region_attr(G1HeapRegion* r);
653+
inline void register_old_collection_set_region_with_region_attr(G1HeapRegion* r);
656654
inline void register_optional_region_with_region_attr(G1HeapRegion* r);
657655

656+
// Updates region state without overwriting the type in the region attribute table.
657+
inline void update_region_attr(G1HeapRegion* r);
658+
658659
void clear_region_attr(const G1HeapRegion* hr) {
659660
_region_attr.clear(hr);
660661
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,26 @@ void G1CollectedHeap::register_humongous_candidate_region_with_region_attr(uint
191191
_region_attr.set_humongous_candidate(index);
192192
}
193193

194+
void G1CollectedHeap::register_young_region_with_region_attr(G1HeapRegion* r) {
195+
assert(!is_in_cset(r), "should not already be registered as in collection set");
196+
_region_attr.set_in_young(r->hrm_index(), r->has_pinned_objects());
197+
}
198+
194199
void G1CollectedHeap::register_new_survivor_region_with_region_attr(G1HeapRegion* r) {
195-
_region_attr.set_new_survivor_region(r->hrm_index());
200+
assert(!is_in_cset(r), "should not already be registered as in collection set");
201+
_region_attr.set_new_survivor_region(r->hrm_index(), r->has_pinned_objects());
196202
}
197203

198-
void G1CollectedHeap::register_region_with_region_attr(G1HeapRegion* r) {
204+
void G1CollectedHeap::update_region_attr(G1HeapRegion* r) {
199205
_region_attr.set_remset_is_tracked(r->hrm_index(), r->rem_set()->is_tracked());
200206
_region_attr.set_is_pinned(r->hrm_index(), r->has_pinned_objects());
201207
}
202208

203-
void G1CollectedHeap::register_old_region_with_region_attr(G1HeapRegion* r) {
209+
void G1CollectedHeap::register_old_collection_set_region_with_region_attr(G1HeapRegion* r) {
210+
assert(!is_in_cset(r), "should not already be registered as in collection set");
211+
assert(r->is_old(), "must be");
204212
assert(r->rem_set()->is_complete(), "must be");
205-
_region_attr.set_in_old(r->hrm_index(), true);
213+
_region_attr.set_in_old(r->hrm_index(), true, r->has_pinned_objects());
206214
_rem_set->exclude_region_from_scan(r->hrm_index());
207215
}
208216

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ void G1CollectionSet::add_old_region(G1HeapRegion* hr) {
126126

127127
assert(!hr->rem_set()->has_cset_group(), "Should have already uninstalled group remset");
128128

129-
assert(!hr->in_collection_set(), "should not already be in the collection set");
130-
_g1h->register_old_region_with_region_attr(hr);
129+
_g1h->register_old_collection_set_region_with_region_attr(hr);
131130

132131
assert(_regions_cur_length < _regions_max_length, "Collection set now larger than maximum size.");
133132
_regions[_regions_cur_length++] = hr->hrm_index();
@@ -736,7 +735,7 @@ void G1CollectionSet::abandon_optional_collection_set(G1ParScanThreadStateSet* p
736735
// Clear collection set marker and make sure that the remembered set information
737736
// is correct as we still need it later.
738737
_g1h->clear_region_attr(r);
739-
_g1h->register_region_with_region_attr(r);
738+
_g1h->update_region_attr(r);
740739
r->clear_index_in_opt_cset();
741740
};
742741

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ struct G1HeapRegionAttr {
8484

8585
bool remset_is_tracked() const { return _remset_is_tracked != 0; }
8686

87-
void set_new_survivor() { _type = NewSurvivor; }
8887
bool is_pinned() const { return _is_pinned != 0; }
8988

9089
void set_old() { _type = Old; }
@@ -132,10 +131,10 @@ class G1HeapRegionAttrBiasedMappedArray : public G1BiasedMappedArray<G1HeapRegio
132131
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Optional, remset_is_tracked));
133132
}
134133

135-
void set_new_survivor_region(uintptr_t index) {
134+
void set_new_survivor_region(uintptr_t index, bool region_is_pinned) {
136135
assert(get_by_index(index).is_default(),
137136
"Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
138-
get_ref_by_index(index)->set_new_survivor();
137+
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::NewSurvivor, true, region_is_pinned));
139138
}
140139

141140
void set_humongous_candidate(uintptr_t index) {
@@ -170,12 +169,10 @@ class G1HeapRegionAttrBiasedMappedArray : public G1BiasedMappedArray<G1HeapRegio
170169
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Young, true, is_pinned));
171170
}
172171

173-
void set_in_old(uintptr_t index, bool remset_is_tracked) {
172+
void set_in_old(uintptr_t index, bool remset_is_tracked, bool is_pinned) {
174173
assert(get_by_index(index).is_default(),
175174
"Region attributes at index " INTPTR_FORMAT " should be default but is %s", index, get_by_index(index).get_type_str());
176-
// We do not select regions with pinned objects into the collection set.
177-
const bool region_is_pinned = false;
178-
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Old, remset_is_tracked, region_is_pinned));
175+
set_by_index(index, G1HeapRegionAttr(G1HeapRegionAttr::Old, remset_is_tracked, is_pinned));
179176
}
180177

181178
bool is_in_cset_or_humongous_candidate(HeapWord* addr) const { return at(addr).is_in_cset_or_humongous_candidate(); }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class G1PrepareEvacuationTask : public WorkerTask {
426426

427427
// Now check if region is a humongous candidate
428428
if (!hr->is_starts_humongous()) {
429-
_g1h->register_region_with_region_attr(hr);
429+
_g1h->update_region_attr(hr);
430430
return false;
431431
}
432432

@@ -436,7 +436,7 @@ class G1PrepareEvacuationTask : public WorkerTask {
436436
_worker_humongous_candidates++;
437437
// We will later handle the remembered sets of these regions.
438438
} else {
439-
_g1h->register_region_with_region_attr(hr);
439+
_g1h->update_region_attr(hr);
440440
}
441441
log_debug(gc, humongous)("Humongous region %u (object size %zu @ " PTR_FORMAT ") remset %zu code roots %zu "
442442
"marked %d pinned count %zu reclaim candidate %d type %s",

0 commit comments

Comments
 (0)