From 2c8b432b8911bc1a52b02def89e4820c76ea67ba Mon Sep 17 00:00:00 2001 From: Guoxiong Li Date: Fri, 12 Apr 2024 07:26:01 +0000 Subject: [PATCH] 8330003: Serial: Move the logic of FastEvacuateFollowersClosure to SerialHeap Reviewed-by: ayang, tschatzl --- .../share/gc/serial/defNewGeneration.cpp | 19 +---------------- src/hotspot/share/gc/serial/serialHeap.cpp | 11 +++++++++- src/hotspot/share/gc/serial/serialHeap.hpp | 9 ++------ .../share/gc/serial/serialHeap.inline.hpp | 21 ++++++++++++------- 4 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index ee7ef765fa3..7ac0d9b554a 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -76,20 +76,6 @@ public: void do_oop(narrowOop* p) { do_oop_work(p); } }; -class YoungGenScanClosure : public InHeapScanClosure { - template - void do_oop_work(T* p) { - assert(SerialHeap::heap()->young_gen()->to()->is_in_reserved(p), "precondition"); - - try_scavenge(p, [] (auto) {}); - } -public: - YoungGenScanClosure(DefNewGeneration* g) : InHeapScanClosure(g) {} - - void do_oop(oop* p) { do_oop_work(p); } - void do_oop(narrowOop* p) { do_oop_work(p); } -}; - class RootScanClosure : public OffHeapScanClosure { template void do_oop_work(T* p) { @@ -231,10 +217,7 @@ public: {} void do_void() { - do { - _heap->oop_since_save_marks_iterate(_young_cl, _old_cl); - } while (!_heap->no_allocs_since_save_marks()); - guarantee(_heap->young_gen()->promo_failure_scan_is_complete(), "Failed to finish scan"); + _heap->scan_evacuated_objs(_young_cl, _old_cl); } }; diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 8c43239b201..84d941fbdb7 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -32,7 +32,7 @@ #include "gc/serial/cardTableRS.hpp" #include "gc/serial/defNewGeneration.inline.hpp" #include "gc/serial/serialFullGC.hpp" -#include "gc/serial/serialHeap.hpp" +#include "gc/serial/serialHeap.inline.hpp" #include "gc/serial/serialMemoryPools.hpp" #include "gc/serial/serialVMOperations.hpp" #include "gc/serial/tenuredGeneration.inline.hpp" @@ -762,6 +762,15 @@ bool SerialHeap::no_allocs_since_save_marks() { _old_gen->no_allocs_since_save_marks(); } +void SerialHeap::scan_evacuated_objs(YoungGenScanClosure* young_cl, + OldGenScanClosure* old_cl) { + do { + young_gen()->oop_since_save_marks_iterate(young_cl); + old_gen()->oop_since_save_marks_iterate(old_cl); + } while (!no_allocs_since_save_marks()); + guarantee(young_gen()->promo_failure_scan_is_complete(), "Failed to finish scan"); +} + // public collection interfaces void SerialHeap::collect(GCCause::Cause cause) { // The caller doesn't have the Heap_lock diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp index 54a776406fa..d13b8706c22 100644 --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -355,13 +355,8 @@ public: return _old_gen; } - // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects - // allocated since the last call to save_marks in the young generation. - // The "cur" closure is applied to references in the younger generation - // at "level", and the "older" closure to older generations. - template - void oop_since_save_marks_iterate(OopClosureType1* cur, - OopClosureType2* older); + void scan_evacuated_objs(YoungGenScanClosure* young_cl, + OldGenScanClosure* old_cl); void safepoint_synchronize_begin() override; void safepoint_synchronize_end() override; diff --git a/src/hotspot/share/gc/serial/serialHeap.inline.hpp b/src/hotspot/share/gc/serial/serialHeap.inline.hpp index 27819f0d1c9..750c0e9c311 100644 --- a/src/hotspot/share/gc/serial/serialHeap.inline.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.inline.hpp @@ -30,13 +30,6 @@ #include "gc/serial/defNewGeneration.inline.hpp" #include "gc/serial/tenuredGeneration.inline.hpp" -template -void SerialHeap::oop_since_save_marks_iterate(OopClosureType1* cur, - OopClosureType2* older) { - young_gen()->oop_since_save_marks_iterate(cur); - old_gen()->oop_since_save_marks_iterate(older); -} - class ScavengeHelper { DefNewGeneration* _young_gen; HeapWord* _young_gen_end; @@ -100,6 +93,20 @@ protected: OffHeapScanClosure(DefNewGeneration* young_gen) : _helper(young_gen) {} }; +class YoungGenScanClosure : public InHeapScanClosure { + template + void do_oop_work(T* p) { + assert(SerialHeap::heap()->young_gen()->to()->is_in_reserved(p), "precondition"); + + try_scavenge(p, [] (auto) {}); + } +public: + YoungGenScanClosure(DefNewGeneration* g) : InHeapScanClosure(g) {} + + void do_oop(oop* p) { do_oop_work(p); } + void do_oop(narrowOop* p) { do_oop_work(p); } +}; + class OldGenScanClosure : public InHeapScanClosure { CardTableRS* _rs;