8139800: Remove OopsInGenClosure
Reviewed-by: kbarrett, sjohanss
This commit is contained in:
parent
bfabf1279d
commit
1605edfcc3
@ -92,8 +92,8 @@ void DefNewGeneration::FastKeepAliveClosure::do_oop(narrowOop* p) { DefNewGenera
|
||||
|
||||
DefNewGeneration::FastEvacuateFollowersClosure::
|
||||
FastEvacuateFollowersClosure(SerialHeap* heap,
|
||||
FastScanClosure* cur,
|
||||
FastScanClosure* older) :
|
||||
DefNewScanClosure* cur,
|
||||
DefNewYoungerGenClosure* older) :
|
||||
_heap(heap), _scan_cur_or_nonheap(cur), _scan_older(older)
|
||||
{
|
||||
}
|
||||
@ -105,12 +105,6 @@ void DefNewGeneration::FastEvacuateFollowersClosure::do_void() {
|
||||
guarantee(_heap->young_gen()->promo_failure_scan_is_complete(), "Failed to finish scan");
|
||||
}
|
||||
|
||||
FastScanClosure::FastScanClosure(DefNewGeneration* g, bool gc_barrier) :
|
||||
OopsInClassLoaderDataOrGenClosure(g), _g(g), _gc_barrier(gc_barrier)
|
||||
{
|
||||
_boundary = _g->reserved().end();
|
||||
}
|
||||
|
||||
void CLDScanClosure::do_cld(ClassLoaderData* cld) {
|
||||
NOT_PRODUCT(ResourceMark rm);
|
||||
log_develop_trace(gc, scavenge)("CLDScanClosure::do_cld " PTR_FORMAT ", %s, dirty: %s",
|
||||
@ -570,16 +564,16 @@ void DefNewGeneration::collect(bool full,
|
||||
assert(heap->no_allocs_since_save_marks(),
|
||||
"save marks have not been newly set.");
|
||||
|
||||
FastScanClosure fsc_with_no_gc_barrier(this, false);
|
||||
FastScanClosure fsc_with_gc_barrier(this, true);
|
||||
DefNewScanClosure scan_closure(this);
|
||||
DefNewYoungerGenClosure younger_gen_closure(this, _old_gen);
|
||||
|
||||
CLDScanClosure cld_scan_closure(&fsc_with_no_gc_barrier,
|
||||
CLDScanClosure cld_scan_closure(&scan_closure,
|
||||
heap->rem_set()->cld_rem_set()->accumulate_modified_oops());
|
||||
|
||||
set_promo_failure_scan_stack_closure(&fsc_with_no_gc_barrier);
|
||||
set_promo_failure_scan_stack_closure(&scan_closure);
|
||||
FastEvacuateFollowersClosure evacuate_followers(heap,
|
||||
&fsc_with_no_gc_barrier,
|
||||
&fsc_with_gc_barrier);
|
||||
&scan_closure,
|
||||
&younger_gen_closure);
|
||||
|
||||
assert(heap->no_allocs_since_save_marks(),
|
||||
"save marks have not been newly set.");
|
||||
@ -591,8 +585,8 @@ void DefNewGeneration::collect(bool full,
|
||||
StrongRootsScope srs(0);
|
||||
|
||||
heap->young_process_roots(&srs,
|
||||
&fsc_with_no_gc_barrier,
|
||||
&fsc_with_gc_barrier,
|
||||
&scan_closure,
|
||||
&younger_gen_closure,
|
||||
&cld_scan_closure);
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,12 @@
|
||||
#include "utilities/stack.hpp"
|
||||
|
||||
class ContiguousSpace;
|
||||
class STWGCTimer;
|
||||
class CSpaceCounters;
|
||||
class DefNewYoungerGenClosure;
|
||||
class DefNewScanClosure;
|
||||
class ScanWeakRefClosure;
|
||||
class SerialHeap;
|
||||
class STWGCTimer;
|
||||
|
||||
// DefNewGeneration is a young generation containing eden, from- and
|
||||
// to-space.
|
||||
@ -180,12 +182,12 @@ protected:
|
||||
|
||||
class FastEvacuateFollowersClosure: public VoidClosure {
|
||||
SerialHeap* _heap;
|
||||
FastScanClosure* _scan_cur_or_nonheap;
|
||||
FastScanClosure* _scan_older;
|
||||
DefNewScanClosure* _scan_cur_or_nonheap;
|
||||
DefNewYoungerGenClosure* _scan_older;
|
||||
public:
|
||||
FastEvacuateFollowersClosure(SerialHeap* heap,
|
||||
FastScanClosure* cur,
|
||||
FastScanClosure* older);
|
||||
DefNewScanClosure* cur,
|
||||
DefNewYoungerGenClosure* older);
|
||||
void do_void();
|
||||
};
|
||||
|
||||
|
@ -90,11 +90,10 @@ inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {
|
||||
|
||||
template <typename OopClosureType>
|
||||
void DefNewGeneration::oop_since_save_marks_iterate(OopClosureType* cl) {
|
||||
cl->set_generation(this);
|
||||
eden()->oop_since_save_marks_iterate(cl);
|
||||
to()->oop_since_save_marks_iterate(cl);
|
||||
from()->oop_since_save_marks_iterate(cl);
|
||||
cl->reset_generation();
|
||||
|
||||
save_marks();
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ GrowableArray<MemoryPool*> SerialHeap::memory_pools() {
|
||||
}
|
||||
|
||||
void SerialHeap::young_process_roots(StrongRootsScope* scope,
|
||||
OopsInGenClosure* root_closure,
|
||||
OopsInGenClosure* old_gen_closure,
|
||||
OopIterateClosure* root_closure,
|
||||
OopIterateClosure* old_gen_closure,
|
||||
CLDClosure* cld_closure) {
|
||||
MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);
|
||||
|
||||
@ -99,13 +99,11 @@ void SerialHeap::young_process_roots(StrongRootsScope* scope,
|
||||
cld_closure, cld_closure, &mark_code_closure);
|
||||
|
||||
if (_process_strong_tasks->try_claim_task(GCH_PS_younger_gens)) {
|
||||
root_closure->reset_generation();
|
||||
|
||||
}
|
||||
|
||||
old_gen_closure->set_generation(_old_gen);
|
||||
rem_set()->at_younger_refs_iterate();
|
||||
old_gen()->younger_refs_iterate(old_gen_closure, scope->n_threads());
|
||||
old_gen_closure->reset_generation();
|
||||
|
||||
_process_strong_tasks->all_tasks_completed(scope->n_threads());
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
class GCMemoryManager;
|
||||
class MemoryPool;
|
||||
class OopsInGenClosure;
|
||||
class OopIterateClosure;
|
||||
class TenuredGeneration;
|
||||
|
||||
class SerialHeap : public GenCollectedHeap {
|
||||
@ -78,8 +78,8 @@ public:
|
||||
OopClosureType2* older);
|
||||
|
||||
void young_process_roots(StrongRootsScope* scope,
|
||||
OopsInGenClosure* root_closure,
|
||||
OopsInGenClosure* old_gen_closure,
|
||||
OopIterateClosure* root_closure,
|
||||
OopIterateClosure* old_gen_closure,
|
||||
CLDClosure* cld_closure);
|
||||
};
|
||||
|
||||
|
@ -55,9 +55,8 @@ bool TenuredGeneration::block_is_obj(const HeapWord* addr) const {
|
||||
|
||||
template <typename OopClosureType>
|
||||
void TenuredGeneration::oop_since_save_marks_iterate(OopClosureType* blk) {
|
||||
blk->set_generation(this);
|
||||
_the_space->oop_since_save_marks_iterate(blk);
|
||||
blk->reset_generation();
|
||||
|
||||
save_marks();
|
||||
}
|
||||
|
||||
|
@ -34,91 +34,76 @@ class CardTableBarrierSet;
|
||||
class DefNewGeneration;
|
||||
class KlassRemSet;
|
||||
|
||||
// Closure for iterating roots from a particular generation
|
||||
// Note: all classes deriving from this MUST call this do_barrier
|
||||
// method at the end of their own do_oop method!
|
||||
// Note: no do_oop defined, this is an abstract class.
|
||||
|
||||
class OopsInGenClosure : public OopIterateClosure {
|
||||
private:
|
||||
Generation* _orig_gen; // generation originally set in ctor
|
||||
Generation* _gen; // generation being scanned
|
||||
|
||||
protected:
|
||||
// Some subtypes need access.
|
||||
HeapWord* _gen_boundary; // start of generation
|
||||
CardTableRS* _rs; // remembered set
|
||||
|
||||
// For assertions
|
||||
Generation* generation() { return _gen; }
|
||||
CardTableRS* rs() { return _rs; }
|
||||
|
||||
// Derived classes that modify oops so that they might be old-to-young
|
||||
// pointers must call the method below.
|
||||
template <class T> void do_barrier(T* p);
|
||||
|
||||
public:
|
||||
OopsInGenClosure(Generation* gen);
|
||||
void set_generation(Generation* gen);
|
||||
|
||||
void reset_generation() { _gen = _orig_gen; }
|
||||
|
||||
HeapWord* gen_boundary() { return _gen_boundary; }
|
||||
};
|
||||
|
||||
class BasicOopsInGenClosure: public OopsInGenClosure {
|
||||
public:
|
||||
BasicOopsInGenClosure(Generation* gen);
|
||||
|
||||
virtual bool do_metadata() { return false; }
|
||||
virtual void do_klass(Klass* k) { ShouldNotReachHere(); }
|
||||
virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); }
|
||||
};
|
||||
|
||||
// Super class for scan closures. It contains code to dirty scanned class loader data.
|
||||
class OopsInClassLoaderDataOrGenClosure: public BasicOopsInGenClosure {
|
||||
ClassLoaderData* _scanned_cld;
|
||||
public:
|
||||
OopsInClassLoaderDataOrGenClosure(Generation* g) : BasicOopsInGenClosure(g), _scanned_cld(NULL) {}
|
||||
void set_scanned_cld(ClassLoaderData* cld) {
|
||||
assert(cld == NULL || _scanned_cld == NULL, "Must be");
|
||||
_scanned_cld = cld;
|
||||
}
|
||||
bool is_scanning_a_cld() { return _scanned_cld != NULL; }
|
||||
void do_cld_barrier();
|
||||
};
|
||||
|
||||
#if INCLUDE_SERIALGC
|
||||
|
||||
// Closure for scanning DefNewGeneration.
|
||||
// Super closure class for scanning DefNewGeneration.
|
||||
//
|
||||
// This closure only performs barrier store calls on
|
||||
// pointers into the DefNewGeneration.
|
||||
class FastScanClosure: public OopsInClassLoaderDataOrGenClosure {
|
||||
protected:
|
||||
DefNewGeneration* _g;
|
||||
HeapWord* _boundary;
|
||||
bool _gc_barrier;
|
||||
template <class T> inline void do_oop_work(T* p);
|
||||
public:
|
||||
FastScanClosure(DefNewGeneration* g, bool gc_barrier);
|
||||
// - Derived: The derived type provides necessary barrier
|
||||
// after an oop has been updated.
|
||||
template <typename Derived>
|
||||
class FastScanClosure : public BasicOopIterateClosure {
|
||||
private:
|
||||
DefNewGeneration* _young_gen;
|
||||
HeapWord* _young_gen_end;
|
||||
|
||||
template <typename T>
|
||||
void do_oop_work(T* p);
|
||||
|
||||
protected:
|
||||
FastScanClosure(DefNewGeneration* g);
|
||||
|
||||
public:
|
||||
virtual void do_oop(oop* p);
|
||||
virtual void do_oop(narrowOop* p);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SERIALGC
|
||||
// Closure for scanning DefNewGeneration when iterating over the old generation.
|
||||
//
|
||||
// This closure performs barrier store calls on pointers into the DefNewGeneration.
|
||||
class DefNewYoungerGenClosure : public FastScanClosure<DefNewYoungerGenClosure> {
|
||||
private:
|
||||
Generation* _old_gen;
|
||||
HeapWord* _old_gen_start;
|
||||
CardTableRS* _rs;
|
||||
|
||||
public:
|
||||
DefNewYoungerGenClosure(DefNewGeneration* young_gen, Generation* old_gen);
|
||||
|
||||
template <typename T>
|
||||
void barrier(T* p);
|
||||
};
|
||||
|
||||
// Closure for scanning DefNewGeneration when *not* iterating over the old generation.
|
||||
//
|
||||
// This closures records changes to oops in CLDs.
|
||||
class DefNewScanClosure : public FastScanClosure<DefNewScanClosure> {
|
||||
ClassLoaderData* _scanned_cld;
|
||||
|
||||
public:
|
||||
DefNewScanClosure(DefNewGeneration* g);
|
||||
|
||||
void set_scanned_cld(ClassLoaderData* cld) {
|
||||
assert(cld == NULL || _scanned_cld == NULL, "Must be");
|
||||
_scanned_cld = cld;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void barrier(T* p);
|
||||
};
|
||||
|
||||
class CLDScanClosure: public CLDClosure {
|
||||
OopsInClassLoaderDataOrGenClosure* _scavenge_closure;
|
||||
DefNewScanClosure* _scavenge_closure;
|
||||
// true if the the modified oops state should be saved.
|
||||
bool _accumulate_modified_oops;
|
||||
bool _accumulate_modified_oops;
|
||||
public:
|
||||
CLDScanClosure(OopsInClassLoaderDataOrGenClosure* scavenge_closure,
|
||||
CLDScanClosure(DefNewScanClosure* scavenge_closure,
|
||||
bool accumulate_modified_oops) :
|
||||
_scavenge_closure(scavenge_closure), _accumulate_modified_oops(accumulate_modified_oops) {}
|
||||
void do_cld(ClassLoaderData* cld);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SERIALGC
|
||||
|
||||
class FilteringClosure: public OopIterateClosure {
|
||||
private:
|
||||
HeapWord* _boundary;
|
||||
|
@ -37,65 +37,64 @@
|
||||
#include "gc/serial/defNewGeneration.inline.hpp"
|
||||
#endif
|
||||
|
||||
inline OopsInGenClosure::OopsInGenClosure(Generation* gen) :
|
||||
OopIterateClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) {
|
||||
set_generation(gen);
|
||||
}
|
||||
|
||||
inline void OopsInGenClosure::set_generation(Generation* gen) {
|
||||
_gen = gen;
|
||||
_gen_boundary = _gen->reserved().start();
|
||||
// Barrier set for the heap, must be set after heap is initialized
|
||||
if (_rs == NULL) {
|
||||
_rs = GenCollectedHeap::heap()->rem_set();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> inline void OopsInGenClosure::do_barrier(T* p) {
|
||||
assert(generation()->is_in_reserved(p), "expected ref in generation");
|
||||
T heap_oop = RawAccess<>::oop_load(p);
|
||||
assert(!CompressedOops::is_null(heap_oop), "expected non-null oop");
|
||||
oop obj = CompressedOops::decode_not_null(heap_oop);
|
||||
// If p points to a younger generation, mark the card.
|
||||
if (cast_from_oop<HeapWord*>(obj) < _gen_boundary) {
|
||||
_rs->inline_write_ref_field_gc(p, obj);
|
||||
}
|
||||
}
|
||||
|
||||
inline BasicOopsInGenClosure::BasicOopsInGenClosure(Generation* gen) : OopsInGenClosure(gen) {
|
||||
}
|
||||
|
||||
inline void OopsInClassLoaderDataOrGenClosure::do_cld_barrier() {
|
||||
assert(_scanned_cld != NULL, "Must be");
|
||||
if (!_scanned_cld->has_modified_oops()) {
|
||||
_scanned_cld->record_modified_oops();
|
||||
}
|
||||
}
|
||||
|
||||
#if INCLUDE_SERIALGC
|
||||
|
||||
template <class T> inline void FastScanClosure::do_oop_work(T* p) {
|
||||
template <typename Derived>
|
||||
inline FastScanClosure<Derived>::FastScanClosure(DefNewGeneration* g) :
|
||||
BasicOopIterateClosure(g->ref_processor()),
|
||||
_young_gen(g),
|
||||
_young_gen_end(g->reserved().end()) {}
|
||||
|
||||
template <typename Derived>
|
||||
template <typename T>
|
||||
inline void FastScanClosure<Derived>::do_oop_work(T* p) {
|
||||
T heap_oop = RawAccess<>::oop_load(p);
|
||||
// Should we copy the obj?
|
||||
if (!CompressedOops::is_null(heap_oop)) {
|
||||
oop obj = CompressedOops::decode_not_null(heap_oop);
|
||||
if (cast_from_oop<HeapWord*>(obj) < _boundary) {
|
||||
assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?");
|
||||
if (cast_from_oop<HeapWord*>(obj) < _young_gen_end) {
|
||||
assert(!_young_gen->to()->is_in_reserved(obj), "Scanning field twice?");
|
||||
oop new_obj = obj->is_forwarded() ? obj->forwardee()
|
||||
: _g->copy_to_survivor_space(obj);
|
||||
: _young_gen->copy_to_survivor_space(obj);
|
||||
RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
|
||||
if (is_scanning_a_cld()) {
|
||||
do_cld_barrier();
|
||||
} else if (_gc_barrier) {
|
||||
// Now call parent closure
|
||||
do_barrier(p);
|
||||
}
|
||||
|
||||
static_cast<Derived*>(this)->barrier(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void FastScanClosure::do_oop(oop* p) { FastScanClosure::do_oop_work(p); }
|
||||
inline void FastScanClosure::do_oop(narrowOop* p) { FastScanClosure::do_oop_work(p); }
|
||||
template <typename Derived>
|
||||
inline void FastScanClosure<Derived>::do_oop(oop* p) { do_oop_work(p); }
|
||||
template <typename Derived>
|
||||
inline void FastScanClosure<Derived>::do_oop(narrowOop* p) { do_oop_work(p); }
|
||||
|
||||
inline DefNewYoungerGenClosure::DefNewYoungerGenClosure(DefNewGeneration* young_gen, Generation* old_gen) :
|
||||
FastScanClosure<DefNewYoungerGenClosure>(young_gen),
|
||||
_old_gen(old_gen),
|
||||
_old_gen_start(old_gen->reserved().start()),
|
||||
_rs(GenCollectedHeap::heap()->rem_set()) {}
|
||||
|
||||
template <typename T>
|
||||
void DefNewYoungerGenClosure::barrier(T* p) {
|
||||
assert(_old_gen->is_in_reserved(p), "expected ref in generation");
|
||||
T heap_oop = RawAccess<>::oop_load(p);
|
||||
assert(!CompressedOops::is_null(heap_oop), "expected non-null oop");
|
||||
oop obj = CompressedOops::decode_not_null(heap_oop);
|
||||
// If p points to a younger generation, mark the card.
|
||||
if (cast_from_oop<HeapWord*>(obj) < _old_gen_start) {
|
||||
_rs->inline_write_ref_field_gc(p, obj);
|
||||
}
|
||||
}
|
||||
|
||||
inline DefNewScanClosure::DefNewScanClosure(DefNewGeneration* g) :
|
||||
FastScanClosure<DefNewScanClosure>(g), _scanned_cld(NULL) {}
|
||||
|
||||
template <class T>
|
||||
void DefNewScanClosure::barrier(T* p) {
|
||||
if (_scanned_cld != NULL && !_scanned_cld->has_modified_oops()) {
|
||||
_scanned_cld->record_modified_oops();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INCLUDE_SERIALGC
|
||||
|
||||
|
@ -56,7 +56,6 @@ class CompactibleSpace;
|
||||
class ContiguousSpace;
|
||||
class CompactPoint;
|
||||
class OopClosure;
|
||||
class FastScanClosure;
|
||||
class GenCollectedHeap;
|
||||
class GCStats;
|
||||
|
||||
|
@ -42,7 +42,6 @@
|
||||
|
||||
// Forward declarations.
|
||||
class OopClosure;
|
||||
class FastScanClosure;
|
||||
class FilteringClosure;
|
||||
|
||||
class PSPromotionManager;
|
||||
|
Loading…
x
Reference in New Issue
Block a user