Skip to content

Commit 6423698

Browse files
author
Thomas Schatzl
committed
Remove _top_at_mark_start HeapRegion member
1 parent 33b201f commit 6423698

10 files changed

+37
-100
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ class G1ClearBitMapTask : public WorkerTask {
748748
}
749749
assert(cur >= end, "Must have completed iteration over the bitmap for region %u.", r->hrm_index());
750750

751-
r->reset_top_at_mark_start();
751+
_cm->reset_top_at_mark_start(r);
752752

753753
return false;
754754
}
@@ -860,9 +860,15 @@ void G1PreConcurrentStartTask::ResetMarkingStateTask::do_work(uint worker_id) {
860860
}
861861

862862
class NoteStartOfMarkHRClosure : public HeapRegionClosure {
863+
G1ConcurrentMark* _cm;
864+
863865
public:
866+
NoteStartOfMarkHRClosure() : HeapRegionClosure(), _cm(G1CollectedHeap::heap()->concurrent_mark()) { }
867+
864868
bool do_heap_region(HeapRegion* r) override {
865-
r->note_start_of_marking();
869+
if (r->is_old_or_humongous() && !r->is_collection_set_candidate()) {
870+
_cm->update_top_at_mark_start(r);
871+
}
866872
return false;
867873
}
868874
};
@@ -1261,7 +1267,7 @@ class G1UpdateRemSetTrackingBeforeRebuildTask : public WorkerTask {
12611267
}
12621268

12631269
void add_marked_bytes_and_note_end(HeapRegion* hr, size_t marked_bytes) {
1264-
hr->note_end_of_marking(marked_bytes);
1270+
hr->note_end_of_marking(_cm->top_at_mark_start(hr), marked_bytes);
12651271
_cl->do_heap_region(hr);
12661272
}
12671273

@@ -1936,6 +1942,7 @@ void G1ConcurrentMark::flush_all_task_caches() {
19361942
void G1ConcurrentMark::clear_bitmap_for_region(HeapRegion* hr) {
19371943
assert_at_safepoint();
19381944
_mark_bitmap.clear_range(MemRegion(hr->bottom(), hr->end()));
1945+
reset_top_at_mark_start(hr);
19391946
}
19401947

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ class G1ConcurrentMark : public CHeapObj<mtGC> {
564564

565565
inline void update_top_at_mark_start(HeapRegion* r);
566566
inline void reset_top_at_mark_start(HeapRegion* r);
567-
inline HeapWord* top_at_mark_start(HeapRegion* r) const;
567+
inline HeapWord* top_at_mark_start(const HeapRegion* r) const;
568568
inline HeapWord* top_at_mark_start(uint region) const;
569569
inline bool obj_allocated_since_mark_start(oop obj) const;
570570

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,15 @@ inline size_t G1CMTask::scan_objArray(objArrayOop obj, MemRegion mr) {
187187
inline void G1ConcurrentMark::update_top_at_mark_start(HeapRegion* r) {
188188
uint const region = r->hrm_index();
189189
assert(region < _g1h->max_reserved_regions(), "Tried to access TAMS for region %u out of bounds", region);
190-
assert(_top_at_mark_starts[region] == r->bottom(),
191-
"TAMS for region %u has already been set to " PTR_FORMAT " should be bottom " PTR_FORMAT,
192-
region, p2i(_top_at_mark_starts[region]), p2i(r->bottom()));
193190
_top_at_mark_starts[region] = r->top();
194191
}
195192

196193
inline void G1ConcurrentMark::reset_top_at_mark_start(HeapRegion* r) {
197194
_top_at_mark_starts[r->hrm_index()] = r->bottom();
198195
}
199196

200-
inline HeapWord* G1ConcurrentMark::top_at_mark_start(HeapRegion* r) const {
201-
HeapWord* value = top_at_mark_start(r->hrm_index());
202-
assert(r->top_at_mark_start() == top_at_mark_start(r->hrm_index()),
203-
"Inconsistency check region %u %s " PTR_FORMAT " " PTR_FORMAT,
204-
r->hrm_index(), r->get_short_type_str(), p2i(r->top_at_mark_start()), p2i(top_at_mark_start(r->hrm_index()) ) );
205-
206-
return value;
197+
inline HeapWord* G1ConcurrentMark::top_at_mark_start(const HeapRegion* r) const {
198+
return top_at_mark_start(r->hrm_index());
207199
}
208200

209201
inline HeapWord* G1ConcurrentMark::top_at_mark_start(uint region) const {
@@ -214,9 +206,6 @@ inline HeapWord* G1ConcurrentMark::top_at_mark_start(uint region) const {
214206
inline bool G1ConcurrentMark::obj_allocated_since_mark_start(oop obj) const {
215207
uint const region = _g1h->addr_to_region(obj);
216208
assert(region < _g1h->max_reserved_regions(), "obj " PTR_FORMAT " outside heap %u", p2i(obj), region);
217-
assert(_g1h->region_at(region)->top_at_mark_start() == top_at_mark_start(region),
218-
"Inconsistency region %u %s " PTR_FORMAT " " PTR_FORMAT, region, _g1h->region_at(region)->get_short_type_str(), p2i(_g1h->region_at(region)->top_at_mark_start()), p2i(top_at_mark_start(region))
219-
);
220209
return cast_from_oop<HeapWord*>(obj) >= top_at_mark_start(region);
221210
}
222211

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

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

125125
rem_set()->clear();
126126

127-
init_top_at_mark_start();
127+
G1CollectedHeap::heap()->concurrent_mark()->reset_top_at_mark_start(this); // FIXME
128+
_parsable_bottom = bottom();
129+
_garbage_bytes = 0;
130+
128131
if (clear_space) clear(SpaceDecorator::Mangle);
129132
}
130133

@@ -226,7 +229,6 @@ HeapRegion::HeapRegion(uint hrm_index,
226229
#ifdef ASSERT
227230
_containing_set(nullptr),
228231
#endif
229-
_top_at_mark_start(nullptr),
230232
_parsable_bottom(nullptr),
231233
_garbage_bytes(0),
232234
_young_index_in_cset(-1),
@@ -414,8 +416,9 @@ void HeapRegion::print_on(outputStream* st) const {
414416
} else {
415417
st->print("| ");
416418
}
419+
G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
417420
st->print("|TAMS " PTR_FORMAT "| PB " PTR_FORMAT "| %s ",
418-
p2i(top_at_mark_start()), p2i(parsable_bottom_acquire()), rem_set()->get_state_str());
421+
p2i(cm->top_at_mark_start(this)), p2i(parsable_bottom_acquire()), rem_set()->get_state_str());
419422
if (UseNUMA) {
420423
G1NUMA* numa = G1NUMA::numa();
421424
if (node_index() < numa->num_active_nodes()) {

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,6 @@ class HeapRegion : public CHeapObj<mtGC> {
223223
HeapRegionSetBase* _containing_set;
224224
#endif // ASSERT
225225

226-
// The start of the unmarked area. The unmarked area extends from this
227-
// word until the top and/or end of the region, and is the part
228-
// of the region for which no marking was done, i.e. objects may
229-
// have been allocated in this part since the last mark phase.
230-
HeapWord* volatile _top_at_mark_start;
231-
232226
// The area above this limit is fully parsable. This limit
233227
// is equal to bottom except
234228
//
@@ -246,8 +240,6 @@ class HeapRegion : public CHeapObj<mtGC> {
246240
// Amount of dead data in the region.
247241
size_t _garbage_bytes;
248242

249-
inline void init_top_at_mark_start();
250-
251243
// Data for young region survivor prediction.
252244
uint _young_index_in_cset;
253245
G1SurvRateGroup* _surv_rate_group;
@@ -352,10 +344,6 @@ class HeapRegion : public CHeapObj<mtGC> {
352344

353345
inline bool is_collection_set_candidate() const;
354346

355-
// Get the start of the unmarked area in this region.
356-
HeapWord* top_at_mark_start() const;
357-
void set_top_at_mark_start(HeapWord* value);
358-
359347
// Retrieve parsable bottom; since it may be modified concurrently, outside a
360348
// safepoint the _acquire method must be used.
361349
HeapWord* parsable_bottom() const;
@@ -366,20 +354,13 @@ class HeapRegion : public CHeapObj<mtGC> {
366354
// that the collector is about to start or has finished (concurrently)
367355
// marking the heap.
368356

369-
// Notify the region that concurrent marking is starting. Initialize
370-
// all fields related to the next marking info.
371-
inline void note_start_of_marking();
372-
373-
// Notify the region that concurrent marking has finished. Passes the number of
374-
// bytes between bottom and TAMS.
375-
inline void note_end_of_marking(size_t marked_bytes);
357+
// Notify the region that concurrent marking has finished. Passes TAMS and the number of
358+
// bytes marked between bottom and TAMS.
359+
inline void note_end_of_marking(HeapWord* top_at_mark_start, size_t marked_bytes);
376360

377361
// Notify the region that scrubbing has completed.
378362
inline void note_end_of_scrubbing();
379363

380-
// Notify the region that the (corresponding) bitmap has been cleared.
381-
inline void reset_top_at_mark_start();
382-
383364
// During the concurrent scrubbing phase, can there be any areas with unloaded
384365
// classes or dead objects in this region?
385366
// This set only includes old regions - humongous regions only

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

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -176,27 +176,26 @@ inline void HeapRegion::prepare_for_full_gc() {
176176

177177
inline void HeapRegion::reset_compacted_after_full_gc(HeapWord* new_top) {
178178
set_top(new_top);
179-
// After a compaction the mark bitmap in a movable region is invalid.
180-
// But all objects are live, we get this by setting TAMS to bottom.
181-
init_top_at_mark_start();
182179

183180
reset_after_full_gc_common();
184181
}
185182

186183
inline void HeapRegion::reset_skip_compacting_after_full_gc() {
187184
assert(!is_free(), "must be");
188185

189-
_garbage_bytes = 0;
190-
191-
reset_top_at_mark_start();
192-
193186
reset_after_full_gc_common();
194187
}
195188

196189
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
193+
197194
// Everything above bottom() is parsable and live.
198195
reset_parsable_bottom();
199196

197+
_garbage_bytes = 0;
198+
200199
// Clear unused heap memory in debug builds.
201200
if (ZapUnusedHeapArea) {
202201
mangle_unused_area();
@@ -266,21 +265,6 @@ inline void HeapRegion::update_bot_for_obj(HeapWord* obj_start, size_t obj_size)
266265
_bot_part.update_for_block(obj_start, obj_end);
267266
}
268267

269-
inline HeapWord* HeapRegion::top_at_mark_start() const {
270-
HeapWord* value = Atomic::load(&_top_at_mark_start);
271-
assert(value == G1CollectedHeap::heap()->concurrent_mark()->top_at_mark_start(hrm_index()),
272-
"must be equal region %u %s " PTR_FORMAT " " PTR_FORMAT,
273-
hrm_index(), get_short_type_str(),
274-
p2i(value), p2i(G1CollectedHeap::heap()->concurrent_mark()->top_at_mark_start(hrm_index())));
275-
return value;
276-
}
277-
278-
inline void HeapRegion::set_top_at_mark_start(HeapWord* value) {
279-
Atomic::store(&_top_at_mark_start, value);
280-
assert(_top_at_mark_start == G1CollectedHeap::heap()->concurrent_mark()->top_at_mark_start(this),
281-
"duh " PTR_FORMAT " " PTR_FORMAT, p2i(_top_at_mark_start), p2i(G1CollectedHeap::heap()->concurrent_mark()->top_at_mark_start(this)));
282-
}
283-
284268
inline HeapWord* HeapRegion::parsable_bottom() const {
285269
assert(!is_init_completed() || SafepointSynchronize::is_at_safepoint(), "only during initialization or safepoint");
286270
return _parsable_bottom;
@@ -294,48 +278,22 @@ inline void HeapRegion::reset_parsable_bottom() {
294278
Atomic::release_store(&_parsable_bottom, bottom());
295279
}
296280

297-
inline void HeapRegion::note_start_of_marking() {
298-
assert(top_at_mark_start() == bottom(), "Region's TAMS must always be at bottom");
299-
if (is_old_or_humongous() && !is_collection_set_candidate()) {
300-
G1CollectedHeap::heap()->concurrent_mark()->update_top_at_mark_start(this);
301-
set_top_at_mark_start(top());
302-
}
303-
}
304-
305-
inline void HeapRegion::note_end_of_marking(size_t marked_bytes) {
281+
inline void HeapRegion::note_end_of_marking(HeapWord* top_at_mark_start, size_t marked_bytes) {
306282
assert_at_safepoint();
307283

308-
if (top_at_mark_start() != bottom()) {
309-
_garbage_bytes = byte_size(bottom(), top_at_mark_start()) - marked_bytes;
284+
if (top_at_mark_start != bottom()) {
285+
_garbage_bytes = byte_size(bottom(), top_at_mark_start) - marked_bytes;
310286
}
311287

312288
if (needs_scrubbing()) {
313-
_parsable_bottom = top_at_mark_start();
289+
_parsable_bottom = top_at_mark_start;
314290
}
315291
}
316292

317293
inline void HeapRegion::note_end_of_scrubbing() {
318294
reset_parsable_bottom();
319295
}
320296

321-
inline void HeapRegion::init_top_at_mark_start() {
322-
reset_top_at_mark_start();
323-
_parsable_bottom = bottom();
324-
_garbage_bytes = 0;
325-
}
326-
327-
inline void HeapRegion::reset_top_at_mark_start() {
328-
// We do not need a release store here because
329-
//
330-
// - if this method is called during concurrent bitmap clearing, we do not read
331-
// the bitmap any more for live/dead information (we do not read the bitmap at
332-
// all at that point).
333-
// - otherwise we reclaim regions only during GC and we do not read tams and the
334-
// bitmap concurrently.
335-
G1CollectedHeap::heap()->concurrent_mark()->reset_top_at_mark_start(this);
336-
set_top_at_mark_start(bottom());
337-
}
338-
339297
inline bool HeapRegion::needs_scrubbing() const {
340298
return is_old();
341299
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,6 @@ class G1MergeHeapRootsTask : public WorkerTask {
11331133
// so the bitmap for the regions in the collection set must be cleared if not already.
11341134
if (should_clear_region(hr)) {
11351135
_g1h->clear_bitmap_for_region(hr);
1136-
hr->reset_top_at_mark_start();
11371136
} else {
11381137
assert_bitmap_clear(hr, _g1h->concurrent_mark()->mark_bitmap());
11391138
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,15 @@ void G1RemSetTrackingPolicy::update_at_free(HeapRegion* r) {
5656
}
5757

5858
static void print_before_rebuild(HeapRegion* r, bool selected_for_rebuild, size_t total_live_bytes, size_t live_bytes) {
59+
G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
5960
log_trace(gc, remset, tracking)("Before rebuild region %u "
6061
"(tams: " PTR_FORMAT ") "
6162
"total_live_bytes %zu "
6263
"selected %s "
6364
"(live_bytes %zu "
6465
"type %s)",
6566
r->hrm_index(),
66-
p2i(r->top_at_mark_start()),
67+
p2i(cm->top_at_mark_start(r)),
6768
total_live_bytes,
6869
BOOL_TO_STR(selected_for_rebuild),
6970
live_bytes,
@@ -152,7 +153,7 @@ void G1RemSetTrackingPolicy::update_after_rebuild(HeapRegion* r) {
152153
"remset occ %zu "
153154
"size %zu)",
154155
r->hrm_index(),
155-
p2i(r->top_at_mark_start()),
156+
p2i(cm->top_at_mark_start(r)),
156157
cm->live_bytes(r->hrm_index()),
157158
r->rem_set()->occupied(),
158159
r->rem_set()->mem_size());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static inline bool requires_marking(const void* entry, G1CollectedHeap* g1h) {
8686
"Non-heap pointer in SATB buffer: " PTR_FORMAT, p2i(entry));
8787

8888
G1ConcurrentMark* cm = g1h->concurrent_mark();
89-
if (cm->obj_allocated_since_mark_start(entry)) {
89+
if (cm->obj_allocated_since_mark_start(cast_to_oop(entry))) {
9090
return false;
9191
}
9292

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,8 @@ class G1PostEvacuateCollectionSetCleanupTask2::ProcessEvacuationFailedRegionsTas
560560
} else {
561561
// This evacuation failed region is going to be marked through. Update mark data.
562562
cm->update_top_at_mark_start(r);
563-
r->set_top_at_mark_start(r->top());
564563
cm->set_live_bytes(r->hrm_index(), r->live_bytes());
565-
assert(cm->mark_bitmap()->get_next_marked_addr(r->bottom(), r->top_at_mark_start()) != r->top_at_mark_start(),
564+
assert(cm->mark_bitmap()->get_next_marked_addr(r->bottom(), cm->top_at_mark_start(r)) != cm->top_at_mark_start(r),
566565
"Marks must be on bitmap for region %u", r->hrm_index());
567566
}
568567
return false;

0 commit comments

Comments
 (0)