8317994: Serial: Use SerialHeap in generation

Reviewed-by: tschatzl, sangheki, mli
This commit is contained in:
Albert Mingkun Yang 2023-10-16 09:54:22 +00:00
parent 37eb98604f
commit a27fc7efd4
2 changed files with 9 additions and 16 deletions

View File

@ -25,12 +25,12 @@
#include "precompiled.hpp"
#include "gc/serial/cardTableRS.hpp"
#include "gc/serial/generation.hpp"
#include "gc/serial/serialHeap.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/continuationGCSupport.inline.hpp"
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/space.inline.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
@ -58,11 +58,11 @@ Generation::Generation(ReservedSpace rs, size_t initial_size) :
}
size_t Generation::initial_size() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
if (gch->is_young_gen(this)) {
return gch->young_gen_spec()->init_size();
SerialHeap* serial_heap = SerialHeap::heap();
if (serial_heap->is_young_gen(this)) {
return serial_heap->young_gen_spec()->init_size();
}
return gch->old_gen_spec()->init_size();
return serial_heap->old_gen_spec()->init_size();
}
size_t Generation::max_capacity() const {
@ -86,7 +86,7 @@ void Generation::print_summary_info_on(outputStream* st) {
double time = sr->accumulated_time.seconds();
st->print_cr("Accumulated %s generation GC time %3.7f secs, "
"%u GC's, avg GC time %3.7f",
GenCollectedHeap::heap()->is_young_gen(this) ? "young" : "old" ,
SerialHeap::heap()->is_young_gen(this) ? "young" : "old" ,
time,
sr->invocations,
sr->invocations > 0 ? time / sr->invocations : 0.0);
@ -116,8 +116,8 @@ size_t Generation::max_contiguous_available() const {
// The largest number of contiguous free words in this or any higher generation.
size_t avail = contiguous_available();
size_t old_avail = 0;
if (GenCollectedHeap::heap()->is_young_gen(this)) {
old_avail = GenCollectedHeap::heap()->old_gen()->contiguous_available();
if (SerialHeap::heap()->is_young_gen(this)) {
old_avail = SerialHeap::heap()->old_gen()->contiguous_available();
}
return MAX2(avail, old_avail);
}
@ -135,7 +135,7 @@ oop Generation::promote(oop obj, size_t obj_size) {
assert(obj_size == obj->size(), "bad obj_size passed in");
#ifndef PRODUCT
if (GenCollectedHeap::heap()->promotion_should_fail()) {
if (SerialHeap::heap()->promotion_should_fail()) {
return nullptr;
}
#endif // #ifndef PRODUCT
@ -236,8 +236,6 @@ void Generation::object_iterate(ObjectClosure* cl) {
space_iterate(&blk);
}
#if INCLUDE_SERIALGC
void Generation::prepare_for_compaction(CompactPoint* cp) {
// Generic implementation, can be specialized
ContiguousSpace* space = first_compaction_space();
@ -268,5 +266,3 @@ void Generation::compact() {
sp = sp->next_compaction_space();
}
}
#endif // INCLUDE_SERIALGC

View File

@ -54,7 +54,6 @@ class GenerationSpec;
class ContiguousSpace;
class CompactPoint;
class OopClosure;
class GenCollectedHeap;
class GCStats;
// A "ScratchBlock" represents a block of memory in one generation usable by
@ -290,14 +289,12 @@ class Generation: public CHeapObj<mtGC> {
GCStats* gc_stats() const { return _gc_stats; }
virtual void update_gc_stats(Generation* current_generation, bool full) {}
#if INCLUDE_SERIALGC
// Mark sweep support phase2
virtual void prepare_for_compaction(CompactPoint* cp);
// Mark sweep support phase3
virtual void adjust_pointers();
// Mark sweep support phase4
virtual void compact();
#endif
// Accessing "marks".