8178151: Clean up G1RemSet files

Remove unnecessary class members, improve method visibility and naming

Reviewed-by: ehelin, sjohanss
This commit is contained in:
Thomas Schatzl 2017-06-28 14:15:56 +02:00
parent be1f5ab521
commit ea07d0ec2a
4 changed files with 43 additions and 47 deletions

@ -1108,7 +1108,7 @@ void G1CollectedHeap::clear_rsets_post_compaction() {
class RebuildRSOutOfRegionClosure: public HeapRegionClosure {
G1CollectedHeap* _g1h;
UpdateRSOopClosure _cl;
RebuildRSOopClosure _cl;
public:
RebuildRSOutOfRegionClosure(G1CollectedHeap* g1, uint worker_i = 0) :
_cl(g1->g1_rem_set(), worker_i),

@ -326,10 +326,10 @@ void G1RemSet::initialize(size_t capacity, uint max_regions) {
}
}
G1ScanRSClosure::G1ScanRSClosure(G1RemSetScanState* scan_state,
G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
CodeBlobClosure* code_root_cl,
uint worker_i) :
G1ScanRSForRegionClosure::G1ScanRSForRegionClosure(G1RemSetScanState* scan_state,
G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
CodeBlobClosure* code_root_cl,
uint worker_i) :
_scan_state(scan_state),
_scan_objs_on_card_cl(scan_obj_on_card),
_code_root_cl(code_root_cl),
@ -341,10 +341,9 @@ G1ScanRSClosure::G1ScanRSClosure(G1RemSetScanState* scan_state,
_g1h = G1CollectedHeap::heap();
_bot = _g1h->bot();
_ct_bs = _g1h->g1_barrier_set();
_block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
}
void G1ScanRSClosure::scan_card(size_t index, HeapWord* card_start, HeapRegion *r) {
void G1ScanRSForRegionClosure::scan_card(size_t index, HeapWord* card_start, HeapRegion *r) {
MemRegion card_region(card_start, BOTConstants::N_words);
MemRegion pre_gc_allocated(r->bottom(), _scan_state->scan_top(r->hrm_index()));
MemRegion mr = pre_gc_allocated.intersection(card_region);
@ -359,13 +358,13 @@ void G1ScanRSClosure::scan_card(size_t index, HeapWord* card_start, HeapRegion *
}
}
void G1ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
void G1ScanRSForRegionClosure::scan_strong_code_roots(HeapRegion* r) {
double scan_start = os::elapsedTime();
r->strong_code_roots_do(_code_root_cl);
_strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start);
}
bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) {
bool G1ScanRSForRegionClosure::doHeapRegion(HeapRegion* r) {
assert(r->in_collection_set(), "should only be called on elements of CS.");
uint region_idx = r->hrm_index();
@ -379,15 +378,16 @@ bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) {
_scan_state->add_dirty_region(region_idx);
}
// We claim cards in blocks so as to reduce the contention.
size_t const block_size = G1RSetScanBlockSize;
HeapRegionRemSetIterator iter(r->rem_set());
size_t card_index;
// We claim cards in block so as to reduce the contention. The block size is determined by
// the G1RSetScanBlockSize parameter.
size_t claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size);
size_t claimed_card_block = _scan_state->iter_claimed_next(region_idx, block_size);
for (size_t current_card = 0; iter.has_next(card_index); current_card++) {
if (current_card >= claimed_card_block + _block_size) {
claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size);
if (current_card >= claimed_card_block + block_size) {
claimed_card_block = _scan_state->iter_claimed_next(region_idx, block_size);
}
if (current_card < claimed_card_block) {
_cards_skipped++;
@ -419,7 +419,7 @@ void G1RemSet::scan_rem_set(G1ParScanThreadState* pss,
double rs_time_start = os::elapsedTime();
G1ScanObjsDuringScanRSClosure scan_cl(_g1, pss);
G1ScanRSClosure cl(_scan_state, &scan_cl, heap_region_codeblobs, worker_i);
G1ScanRSForRegionClosure cl(_scan_state, &scan_cl, heap_region_codeblobs, worker_i);
_g1->collection_set_iterate_from(&cl, worker_i);
double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) -

@ -65,6 +65,16 @@ private:
// set in the event of an evacuation failure.
DirtyCardQueueSet _into_cset_dirty_card_queue_set;
// Scan all remembered sets of the collection set for references into the collection
// set.
void scan_rem_set(G1ParScanThreadState* pss,
CodeBlobClosure* heap_region_codeblobs,
uint worker_i);
// Flush remaining refinement buffers for cross-region references to either evacuate references
// into the collection set or update the remembered set.
void update_rem_set(DirtyCardQueue* into_cset_dcq, G1ParScanThreadState* pss, uint worker_i);
protected:
G1CollectedHeap* _g1;
size_t _conc_refine_cards;
@ -107,39 +117,28 @@ public:
// Prepare for and cleanup after an oops_into_collection_set_do
// call. Must call each of these once before and after (in sequential
// code) any threads call oops_into_collection_set_do. (This offers an
// opportunity to sequential setup and teardown of structures needed by a
// parallel iteration over the CS's RS.)
// code) any thread calls oops_into_collection_set_do.
void prepare_for_oops_into_collection_set_do();
void cleanup_after_oops_into_collection_set_do();
void scan_rem_set(G1ParScanThreadState* pss,
CodeBlobClosure* heap_region_codeblobs,
uint worker_i);
G1RemSetScanState* scan_state() const { return _scan_state; }
// Flush remaining refinement buffers into the remembered set.
void update_rem_set(DirtyCardQueue* into_cset_dcq, G1ParScanThreadState* pss, uint worker_i);
// Record, if necessary, the fact that *p (where "p" is in region "from",
// which is required to be non-NULL) has changed to a new non-NULL value.
template <class T> void par_write_ref(HeapRegion* from, T* p, uint tid);
// Requires "region_bm" and "card_bm" to be bitmaps with 1 bit per region
// or card, respectively, such that a region or card with a corresponding
// 0 bit contains no part of any live object. Eliminates any remembered
// set entries that correspond to dead heap ranges. "worker_num" is the
// parallel thread id of the current thread, and "hrclaimer" is the
// HeapRegionClaimer that should be used.
// Eliminates any remembered set entries that correspond to dead heap ranges.
void scrub(uint worker_num, HeapRegionClaimer* hrclaimer);
// Refine the card corresponding to "card_ptr".
// Refine the card corresponding to "card_ptr". Safe to be called concurrently
// to the mutator.
void refine_card_concurrently(jbyte* card_ptr,
uint worker_i);
// Refine the card corresponding to "card_ptr". Returns "true" if the given card contains
// oops that have references into the current collection set.
// Refine the card corresponding to "card_ptr", applying the given closure to
// all references found. Returns "true" if the given card contains
// oops that have references into the current collection set. Must only be
// called during gc.
bool refine_card_during_gc(jbyte* card_ptr,
G1ScanObjsDuringUpdateRSClosure* update_rs_cl);
@ -152,9 +151,7 @@ public:
// Prepare remembered set for verification.
void prepare_for_verify();
size_t conc_refine_cards() const {
return _conc_refine_cards;
}
size_t conc_refine_cards() const { return _conc_refine_cards; }
void create_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap);
void finalize_card_live_data(WorkGang* workers, G1CMBitMap* mark_bitmap);
@ -170,7 +167,7 @@ public:
#endif
};
class G1ScanRSClosure : public HeapRegionClosure {
class G1ScanRSForRegionClosure : public HeapRegionClosure {
G1RemSetScanState* _scan_state;
size_t _cards_scanned;
@ -187,15 +184,14 @@ class G1ScanRSClosure : public HeapRegionClosure {
double _strong_code_root_scan_time_sec;
uint _worker_i;
size_t _block_size;
void scan_card(size_t index, HeapWord* card_start, HeapRegion *r);
void scan_strong_code_roots(HeapRegion* r);
public:
G1ScanRSClosure(G1RemSetScanState* scan_state,
G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
CodeBlobClosure* code_root_cl,
uint worker_i);
G1ScanRSForRegionClosure(G1RemSetScanState* scan_state,
G1ScanObjsDuringScanRSClosure* scan_obj_on_card,
CodeBlobClosure* code_root_cl,
uint worker_i);
bool doHeapRegion(HeapRegion* r);
@ -208,7 +204,7 @@ public:
size_t cards_skipped() const { return _cards_skipped; }
};
class UpdateRSOopClosure: public ExtendedOopClosure {
class RebuildRSOopClosure: public ExtendedOopClosure {
HeapRegion* _from;
G1RemSet* _rs;
uint _worker_i;
@ -216,7 +212,7 @@ class UpdateRSOopClosure: public ExtendedOopClosure {
template <class T> void do_oop_work(T* p);
public:
UpdateRSOopClosure(G1RemSet* rs, uint worker_i = 0) :
RebuildRSOopClosure(G1RemSet* rs, uint worker_i = 0) :
_from(NULL), _rs(rs), _worker_i(worker_i)
{}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -58,7 +58,7 @@ inline void G1RemSet::par_write_ref(HeapRegion* from, T* p, uint tid) {
}
template <class T>
inline void UpdateRSOopClosure::do_oop_work(T* p) {
inline void RebuildRSOopClosure::do_oop_work(T* p) {
assert(_from != NULL, "from region must be non-NULL");
_rs->par_write_ref(_from, p, _worker_i);
}