Skip to content

Commit 4591937

Browse files
author
Thomas Schatzl
committed
8290357: Drop HeapRegion::marked_bytes()
Reviewed-by: sangheki, iwalulya
1 parent 7676be8 commit 4591937

File tree

8 files changed

+12
-52
lines changed

8 files changed

+12
-52
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,16 @@ class G1RebuildRSAndScrubTask : public WorkerTask {
7373

7474
const bool _should_rebuild_remset;
7575

76-
size_t _marked_words;
7776
size_t _processed_words;
7877

7978
const size_t ProcessingYieldLimitInWords = G1RebuildRemSetChunkSize / HeapWordSize;
8079

81-
void reset_marked_words() {
82-
_marked_words = 0;
83-
}
84-
8580
void reset_processed_words() {
8681
_processed_words = 0;
8782
}
8883

89-
void assert_marked_words(HeapRegion* hr) {
90-
assert((_marked_words * HeapWordSize) == hr->marked_bytes(),
91-
"Mismatch between marking and re-calculation for region %u, %zu != %zu",
92-
hr->hrm_index(), (_marked_words * HeapWordSize), hr->marked_bytes());
93-
}
94-
9584
void add_processed_words(size_t processed) {
9685
_processed_words += processed;
97-
_marked_words += processed;
9886
}
9987

10088
// Yield if enough has been processed; returns if the concurrent marking cycle
@@ -228,7 +216,6 @@ class G1RebuildRSAndScrubTask : public WorkerTask {
228216
bool scan_and_scrub_region(HeapRegion* hr, HeapWord* const pb) {
229217
assert(should_rebuild_or_scrub(hr), "must be");
230218

231-
reset_marked_words();
232219
log_trace(gc, marking)("Scrub and rebuild region: " HR_FORMAT " pb: " PTR_FORMAT " TARS: " PTR_FORMAT,
233220
HR_FORMAT_PARAMS(hr), p2i(pb), p2i(_cm->top_at_rebuild_start(hr->hrm_index())));
234221

@@ -240,9 +227,6 @@ class G1RebuildRSAndScrubTask : public WorkerTask {
240227
// Scrubbing completed for this region - notify that we are done with it, resetting
241228
// pb to bottom.
242229
hr->note_end_of_scrubbing();
243-
// Assert that the size of marked objects from the marking matches
244-
// the size of the objects which we scanned to rebuild remembered sets.
245-
assert_marked_words(hr);
246230

247231
// Rebuild from TAMS (= parsable_bottom) to TARS.
248232
if (scan_from_pb_to_tars(hr, pb, _cm->top_at_rebuild_start(hr->hrm_index()))) {
@@ -270,7 +254,6 @@ class G1RebuildRSAndScrubTask : public WorkerTask {
270254
assert(_bitmap->is_marked(humongous) || pb == hr->bottom(),
271255
"Humongous object not live");
272256

273-
reset_marked_words();
274257
log_trace(gc, marking)("Rebuild for humongous region: " HR_FORMAT " pb: " PTR_FORMAT " TARS: " PTR_FORMAT,
275258
HR_FORMAT_PARAMS(hr), p2i(pb), p2i(_cm->top_at_rebuild_start(hr->hrm_index())));
276259

@@ -282,13 +265,6 @@ class G1RebuildRSAndScrubTask : public WorkerTask {
282265
if (mark_aborted) {
283266
log_trace(gc, marking)("Rebuild aborted for region: %u (%s)", hr->hrm_index(), hr->get_short_type_str());
284267
return true;
285-
} else if (_bitmap->is_marked(humongous) && should_rebuild_or_scrub(hr)) {
286-
// Only verify that the marked size matches the rebuilt size if this object was marked
287-
// and the object should still be handled. The should_rebuild_or_scrub() state can
288-
// change during rebuild for humongous objects that are eagerly reclaimed so we need to
289-
// check this.
290-
// If the object has not been marked the size from marking will be 0.
291-
assert_marked_words(hr);
292268
}
293269
return false;
294270
}
@@ -299,7 +275,6 @@ class G1RebuildRSAndScrubTask : public WorkerTask {
299275
_bitmap(_cm->mark_bitmap()),
300276
_rebuild_closure(G1CollectedHeap::heap(), worker_id),
301277
_should_rebuild_remset(should_rebuild_remset),
302-
_marked_words(0),
303278
_processed_words(0) { }
304279

305280
bool do_heap_region(HeapRegion* hr) {

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@ static void print_before_rebuild(HeapRegion* r, bool selected_for_rebuild, size_
6666
"total_live_bytes %zu "
6767
"selected %s "
6868
"(live_bytes %zu "
69-
"marked %zu "
7069
"type %s)",
7170
r->hrm_index(),
7271
p2i(r->top_at_mark_start()),
7372
total_live_bytes,
7473
BOOL_TO_STR(selected_for_rebuild),
7574
live_bytes,
76-
r->marked_bytes(),
7775
r->get_type_str());
7876
}
7977

@@ -102,7 +100,7 @@ bool G1RemSetTrackingPolicy::update_humongous_before_rebuild(HeapRegion* r, bool
102100
return selected_for_rebuild;
103101
}
104102

105-
bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_bytes) {
103+
bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_bytes_below_tams) {
106104
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
107105
assert(!r->is_humongous(), "Region %u is humongous", r->hrm_index());
108106

@@ -114,8 +112,8 @@ bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_by
114112

115113
assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
116114

117-
size_t between_tams_and_top = (r->top() - r->top_at_mark_start()) * HeapWordSize;
118-
size_t total_live_bytes = live_bytes + between_tams_and_top;
115+
size_t live_bytes_above_tams = (r->top() - r->top_at_mark_start()) * HeapWordSize;
116+
size_t total_live_bytes = live_bytes_below_tams + live_bytes_above_tams;
119117

120118
bool selected_for_rebuild = false;
121119
// For old regions, to be of interest for rebuilding the remembered set the following must apply:
@@ -131,7 +129,7 @@ bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_by
131129
selected_for_rebuild = true;
132130
}
133131

134-
print_before_rebuild(r, selected_for_rebuild, total_live_bytes, live_bytes);
132+
print_before_rebuild(r, selected_for_rebuild, total_live_bytes, live_bytes_below_tams);
135133

136134
return selected_for_rebuild;
137135
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class G1RemSetTrackingPolicy : public CHeapObj<mtGC> {
4646
bool update_humongous_before_rebuild(HeapRegion* r, bool is_live);
4747
// Update remembered set tracking state before we are going to rebuild remembered
4848
// sets. Called at safepoint in the remark pause.
49-
bool update_before_rebuild(HeapRegion* r, size_t live_bytes);
49+
bool update_before_rebuild(HeapRegion* r, size_t live_bytes_below_tams);
5050
// Update remembered set tracking state after rebuild is complete, i.e. the cleanup
5151
// pause. Called at safepoint.
5252
void update_after_rebuild(HeapRegion* r);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class G1PostEvacuateCollectionSetCleanupTask2::RedirtyLoggedCardsTask : public G
395395

396396
// Helper class to keep statistics for the collection set freeing
397397
class FreeCSetStats {
398-
size_t _before_used_bytes; // Usage in regions successfully evacutate
398+
size_t _before_used_bytes; // Usage in regions successfully evacuate
399399
size_t _after_used_bytes; // Usage in regions failing evacuation
400400
size_t _bytes_allocated_in_old_since_last_gc; // Size of young regions turned into old
401401
size_t _failure_used_words; // Live size in failed regions
@@ -438,7 +438,7 @@ class FreeCSetStats {
438438
}
439439

440440
void account_failed_region(HeapRegion* r) {
441-
size_t used_words = r->marked_bytes() / HeapWordSize;
441+
size_t used_words = r->live_bytes() / HeapWordSize;
442442
_failure_used_words += used_words;
443443
_failure_waste_words += HeapRegion::GrainWords - used_words;
444444
_after_used_bytes += r->used();

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ HeapRegion::HeapRegion(uint hrm_index,
237237
_top_at_mark_start(NULL),
238238
_parsable_bottom(NULL),
239239
_garbage_bytes(0),
240-
_marked_bytes(0),
241240
_young_index_in_cset(-1),
242241
_surv_rate_group(NULL), _age_index(G1SurvRateGroup::InvalidAgeIndex), _gc_efficiency(-1.0),
243242
_node_index(G1NUMA::UnknownNodeIndex)
@@ -271,9 +270,7 @@ void HeapRegion::report_region_type_change(G1HeapRegionTraceType::Type to) {
271270

272271
void HeapRegion::note_self_forwarding_removal_start(bool during_concurrent_start) {
273272
// We always scrub the region to make sure the entire region is
274-
// parsable after the self-forwarding point removal, and update _marked_bytes
275-
// at the end.
276-
_marked_bytes = 0;
273+
// parsable after the self-forwarding point removal.
277274
_garbage_bytes = 0;
278275

279276
if (during_concurrent_start) {
@@ -291,7 +288,6 @@ void HeapRegion::note_self_forwarding_removal_start(bool during_concurrent_start
291288
void HeapRegion::note_self_forwarding_removal_end(size_t marked_bytes) {
292289
assert(marked_bytes <= used(),
293290
"marked: " SIZE_FORMAT " used: " SIZE_FORMAT, marked_bytes, used());
294-
_marked_bytes = marked_bytes;
295291
_garbage_bytes = used() - marked_bytes;
296292
}
297293

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,11 @@ class HeapRegion : public CHeapObj<mtGC> {
246246

247247
// Amount of dead data in the region.
248248
size_t _garbage_bytes;
249-
// We use concurrent marking to determine the amount of live data
250-
// in each heap region.
251-
size_t _marked_bytes; // Bytes known to be live via last completed marking.
252249

253250
void init_top_at_mark_start() {
254251
set_top_at_mark_start(bottom());
255252
_parsable_bottom = bottom();
256253
_garbage_bytes = 0;
257-
_marked_bytes = 0;
258254
}
259255

260256
// Data for young region survivor prediction.
@@ -339,8 +335,6 @@ class HeapRegion : public CHeapObj<mtGC> {
339335
// up once during initialization time.
340336
static void setup_heap_region_size(size_t max_heap_size);
341337

342-
// The number of bytes marked live in the region in the last marking phase.
343-
size_t marked_bytes() const { return _marked_bytes; }
344338
// An upper bound on the number of live bytes in the region.
345339
size_t live_bytes() const {
346340
return used() - garbage_bytes();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ inline void HeapRegion::reset_compacted_after_full_gc(HeapWord* new_top) {
204204
inline void HeapRegion::reset_skip_compacting_after_full_gc() {
205205
assert(!is_free(), "must be");
206206

207-
_marked_bytes = used();
208207
_garbage_bytes = 0;
209208

210209
set_top_at_mark_start(bottom());
@@ -317,8 +316,7 @@ inline void HeapRegion::note_start_of_marking() {
317316
inline void HeapRegion::note_end_of_marking(size_t marked_bytes) {
318317
assert_at_safepoint();
319318

320-
_marked_bytes = marked_bytes;
321-
_garbage_bytes = byte_size(bottom(), top_at_mark_start()) - _marked_bytes;
319+
_garbage_bytes = byte_size(bottom(), top_at_mark_start()) - marked_bytes;
322320

323321
if (needs_scrubbing()) {
324322
_parsable_bottom = top_at_mark_start();

src/hotspot/share/prims/whitebox.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,16 @@ class OldRegionsLivenessClosure: public HeapRegionClosure {
601601

602602
bool do_heap_region(HeapRegion* r) {
603603
if (r->is_old()) {
604-
size_t prev_live = r->marked_bytes();
605604
size_t live = r->live_bytes();
606605
size_t size = r->used();
607606
size_t reg_size = HeapRegion::GrainBytes;
608607
if (size > 0 && ((int)(live * 100 / size) < _liveness)) {
609608
_total_memory += size;
610609
++_total_count;
611610
if (size == reg_size) {
612-
// we don't include non-full regions since they are unlikely included in mixed gc
613-
// for testing purposes it's enough to have lowest estimation of total memory that is expected to be freed
614-
_total_memory_to_free += size - prev_live;
611+
// We don't include non-full regions since they are unlikely included in mixed gc
612+
// for testing purposes it's enough to have lowest estimation of total memory that is expected to be freed
613+
_total_memory_to_free += size - live;
615614
}
616615
}
617616
}

0 commit comments

Comments
 (0)