8330003: Serial: Move the logic of FastEvacuateFollowersClosure to SerialHeap

Reviewed-by: ayang, tschatzl
This commit is contained in:
Guoxiong Li 2024-04-12 07:26:01 +00:00
parent 2c45eca159
commit 2c8b432b89
4 changed files with 27 additions and 33 deletions

View File

@ -76,20 +76,6 @@ public:
void do_oop(narrowOop* p) { do_oop_work(p); }
};
class YoungGenScanClosure : public InHeapScanClosure {
template <typename T>
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 <typename T>
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);
}
};

View File

@ -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

View File

@ -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 <typename OopClosureType1, typename OopClosureType2>
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;

View File

@ -30,13 +30,6 @@
#include "gc/serial/defNewGeneration.inline.hpp"
#include "gc/serial/tenuredGeneration.inline.hpp"
template <typename OopClosureType1, typename OopClosureType2>
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 <typename T>
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;