--- old/src/hotspot/share/gc/shared/genOopClosures.inline.hpp 2020-08-25 10:54:39.679826230 +0200 +++ new/src/hotspot/share/gc/shared/genOopClosures.inline.hpp 2020-08-25 10:54:39.139817132 +0200 @@ -37,66 +37,65 @@ #include "gc/serial/defNewGeneration.inline.hpp" #endif -inline OopsInGenClosure::OopsInGenClosure(Generation* gen) : - OopIterateClosure(gen->ref_processor()), _orig_gen(gen), _rs(NULL) { - set_generation(gen); -} +#if INCLUDE_SERIALGC + +template +inline FastScanClosure::FastScanClosure(DefNewGeneration* g) : + BasicOopIterateClosure(g->ref_processor()), + _young_gen(g), + _young_gen_end(g->reserved().end()) {} + +template +template +inline void FastScanClosure::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(obj) < _young_gen_end) { + assert(!_young_gen->to()->is_in_reserved(obj), "Scanning field twice?"); + oop new_obj = obj->is_forwarded() ? obj->forwardee() + : _young_gen->copy_to_survivor_space(obj); + RawAccess::oop_store(p, new_obj); -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(); + static_cast(this)->barrier(p); + } } } -template inline void OopsInGenClosure::do_barrier(T* p) { - assert(generation()->is_in_reserved(p), "expected ref in generation"); +template +inline void FastScanClosure::do_oop(oop* p) { do_oop_work(p); } +template +inline void FastScanClosure::do_oop(narrowOop* p) { do_oop_work(p); } + +inline DefNewYoungerGenClosure::DefNewYoungerGenClosure(DefNewGeneration* young_gen, Generation* old_gen) : + FastScanClosure(young_gen), + _old_gen(old_gen), + _old_gen_start(old_gen->reserved().start()), + _rs(GenCollectedHeap::heap()->rem_set()) {} + +template +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(obj) < _gen_boundary) { + if (cast_from_oop(obj) < _old_gen_start) { _rs->inline_write_ref_field_gc(p, obj); } } -inline BasicOopsInGenClosure::BasicOopsInGenClosure(Generation* gen) : OopsInGenClosure(gen) { -} +inline DefNewScanClosure::DefNewScanClosure(DefNewGeneration* g) : + FastScanClosure(g), _scanned_cld(NULL) {} -inline void OopsInClassLoaderDataOrGenClosure::do_cld_barrier() { - assert(_scanned_cld != NULL, "Must be"); - if (!_scanned_cld->has_modified_oops()) { +template +void DefNewScanClosure::barrier(T* p) { + if (_scanned_cld != NULL && !_scanned_cld->has_modified_oops()) { _scanned_cld->record_modified_oops(); } } -#if INCLUDE_SERIALGC - -template inline void FastScanClosure::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(obj) < _boundary) { - assert(!_g->to()->is_in_reserved(obj), "Scanning field twice?"); - oop new_obj = obj->is_forwarded() ? obj->forwardee() - : _g->copy_to_survivor_space(obj); - RawAccess::oop_store(p, new_obj); - if (is_scanning_a_cld()) { - do_cld_barrier(); - } else if (_gc_barrier) { - // Now call parent closure - do_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); } - #endif // INCLUDE_SERIALGC template void FilteringClosure::do_oop_work(T* p) {