diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index adf7823cb0c..7bbc9976473 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -63,43 +63,75 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/stack.inline.hpp" -// -// DefNewGeneration functions. +class IsAliveClosure: public BoolObjectClosure { + Generation* _young_gen; +public: + IsAliveClosure(Generation* young_gen) : _young_gen(young_gen) { + assert(_young_gen->kind() == Generation::DefNew, + "Expected the young generation here"); + } -// Methods of protected closure types. + bool do_object_b(oop p) { + return cast_from_oop(p) >= _young_gen->reserved().end() || p->is_forwarded(); + } +}; -DefNewGeneration::IsAliveClosure::IsAliveClosure(Generation* young_gen) : _young_gen(young_gen) { - assert(_young_gen->kind() == Generation::DefNew, "Expected the young generation here"); -} +class KeepAliveClosure: public OopClosure { + ScanWeakRefClosure* _cl; + CardTableRS* _rs; + HeapWord* _boundary; -bool DefNewGeneration::IsAliveClosure::do_object_b(oop p) { - return cast_from_oop(p) >= _young_gen->reserved().end() || p->is_forwarded(); -} + template + inline void do_oop_work(T* p) { +#ifdef ASSERT + { + // We never expect to see a null reference being processed + // as a weak reference. + oop obj = RawAccess::oop_load(p); + assert (oopDesc::is_oop(obj), "expected an oop while scanning weak refs"); + } +#endif // ASSERT -DefNewGeneration::FastKeepAliveClosure:: -FastKeepAliveClosure(DefNewGeneration* g, ScanWeakRefClosure* cl) : - _cl(cl) { - _rs = GenCollectedHeap::heap()->rem_set(); - _boundary = g->reserved().end(); -} + Devirtualizer::do_oop(_cl, p); -void DefNewGeneration::FastKeepAliveClosure::do_oop(oop* p) { DefNewGeneration::FastKeepAliveClosure::do_oop_work(p); } -void DefNewGeneration::FastKeepAliveClosure::do_oop(narrowOop* p) { DefNewGeneration::FastKeepAliveClosure::do_oop_work(p); } + // Optimized for Defnew generation if it's the youngest generation: + // we set a younger_gen card if we have an older->youngest + // generation pointer. + oop obj = RawAccess::oop_load(p); + if ((cast_from_oop(obj) < _boundary) && GenCollectedHeap::heap()->is_in_reserved(p)) { + _rs->inline_write_ref_field_gc(p); + } + } -DefNewGeneration::FastEvacuateFollowersClosure:: -FastEvacuateFollowersClosure(SerialHeap* heap, - DefNewScanClosure* cur, - DefNewYoungerGenClosure* older) : - _heap(heap), _scan_cur_or_nonheap(cur), _scan_older(older) -{ -} +public: + KeepAliveClosure(DefNewGeneration* g, ScanWeakRefClosure* cl) : + _cl(cl) { + _rs = GenCollectedHeap::heap()->rem_set(); + _boundary = g->reserved().end(); + } -void DefNewGeneration::FastEvacuateFollowersClosure::do_void() { - do { - _heap->oop_since_save_marks_iterate(_scan_cur_or_nonheap, _scan_older); - } while (!_heap->no_allocs_since_save_marks()); - guarantee(_heap->young_gen()->promo_failure_scan_is_complete(), "Failed to finish scan"); -} + void do_oop(oop* p) { do_oop_work(p); } + void do_oop(narrowOop* p) { do_oop_work(p); } +}; + +class FastEvacuateFollowersClosure: public VoidClosure { + SerialHeap* _heap; + DefNewScanClosure* _scan_cur_or_nonheap; + DefNewYoungerGenClosure* _scan_older; +public: + FastEvacuateFollowersClosure(SerialHeap* heap, + DefNewScanClosure* cur, + DefNewYoungerGenClosure* older) : + _heap(heap), _scan_cur_or_nonheap(cur), _scan_older(older) + {} + + void do_void() { + do { + _heap->oop_since_save_marks_iterate(_scan_cur_or_nonheap, _scan_older); + } while (!_heap->no_allocs_since_save_marks()); + guarantee(_heap->young_gen()->promo_failure_scan_is_complete(), "Failed to finish scan"); + } +}; void CLDScanClosure::do_cld(ClassLoaderData* cld) { NOT_PRODUCT(ResourceMark rm); @@ -578,7 +610,7 @@ void DefNewGeneration::collect(bool full, // "evacuate followers". evacuate_followers.do_void(); - FastKeepAliveClosure keep_alive(this, &scan_weak_ref); + KeepAliveClosure keep_alive(this, &scan_weak_ref); ReferenceProcessor* rp = ref_processor(); ReferenceProcessorPhaseTimes pt(_gc_timer, rp->max_num_queues()); SerialGCRefProcProxyTask task(is_alive, keep_alive, evacuate_followers); diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp index 33328266fa4..4c478fa8243 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -159,36 +159,6 @@ protected: return n > alignment ? align_down(n, alignment) : alignment; } - public: // was "protected" but caused compile error on win32 - class IsAliveClosure: public BoolObjectClosure { - Generation* _young_gen; - public: - IsAliveClosure(Generation* young_gen); - bool do_object_b(oop p); - }; - - class FastKeepAliveClosure: public OopClosure { - ScanWeakRefClosure* _cl; - CardTableRS* _rs; - HeapWord* _boundary; - template void do_oop_work(T* p); - public: - FastKeepAliveClosure(DefNewGeneration* g, ScanWeakRefClosure* cl); - virtual void do_oop(oop* p); - virtual void do_oop(narrowOop* p); - }; - - class FastEvacuateFollowersClosure: public VoidClosure { - SerialHeap* _heap; - DefNewScanClosure* _scan_cur_or_nonheap; - DefNewYoungerGenClosure* _scan_older; - public: - FastEvacuateFollowersClosure(SerialHeap* heap, - DefNewScanClosure* cur, - DefNewYoungerGenClosure* older); - void do_void(); - }; - public: DefNewGeneration(ReservedSpace rs, size_t initial_byte_size, diff --git a/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp b/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp index 23582cc6e18..330879a27f2 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.inline.hpp @@ -36,28 +36,6 @@ // Methods of protected closure types -template -inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) { -#ifdef ASSERT - { - // We never expect to see a null reference being processed - // as a weak reference. - oop obj = RawAccess::oop_load(p); - assert (oopDesc::is_oop(obj), "expected an oop while scanning weak refs"); - } -#endif // ASSERT - - Devirtualizer::do_oop(_cl, p); - - // Optimized for Defnew generation if it's the youngest generation: - // we set a younger_gen card if we have an older->youngest - // generation pointer. - oop obj = RawAccess::oop_load(p); - if ((cast_from_oop(obj) < _boundary) && GenCollectedHeap::heap()->is_in_reserved(p)) { - _rs->inline_write_ref_field_gc(p); - } -} - template void DefNewGeneration::oop_since_save_marks_iterate(OopClosureType* cl) { // No allocation in eden and from spaces, so no iteration required.