8319703: Serial: Remove generationSpec

Reviewed-by: cjplummer, tschatzl
This commit is contained in:
Albert Mingkun Yang 2023-11-27 16:09:20 +00:00
parent a006d7eae0
commit f9e9131e12
12 changed files with 11 additions and 264 deletions

View File

@ -81,7 +81,6 @@
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/isGCActiveMark.hpp"
#include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/oopStorageParState.hpp"

View File

@ -40,7 +40,6 @@
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/preservedMarks.inline.hpp"
#include "gc/shared/referencePolicy.hpp"
#include "gc/shared/referenceProcessorPhaseTimes.hpp"
@ -560,7 +559,7 @@ void DefNewGeneration::compute_new_size() {
size_t old_size = gch->old_gen()->capacity();
size_t new_size_before = _virtual_space.committed_size();
size_t min_new_size = initial_size();
size_t min_new_size = NewSize;
size_t max_new_size = reserved().byte_size();
assert(min_new_size <= new_size_before &&
new_size_before <= max_new_size,

View File

@ -31,7 +31,6 @@
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/space.inline.hpp"
#include "gc/shared/spaceDecorator.inline.hpp"
#include "logging/log.hpp"
@ -57,14 +56,6 @@ Generation::Generation(ReservedSpace rs, size_t initial_size) :
(HeapWord*)_virtual_space.high_boundary());
}
size_t Generation::initial_size() {
SerialHeap* serial_heap = SerialHeap::heap();
if (serial_heap->is_young_gen(this)) {
return serial_heap->young_gen_spec()->init_size();
}
return serial_heap->old_gen_spec()->init_size();
}
size_t Generation::max_capacity() const {
return reserved().byte_size();
}

View File

@ -50,7 +50,6 @@
class DefNewGeneration;
class GCMemoryManager;
class GenerationSpec;
class ContiguousSpace;
class CompactPoint;
class OopClosure;
@ -113,8 +112,6 @@ class Generation: public CHeapObj<mtGC> {
virtual Generation::Name kind() { return Generation::Other; }
// Space inquiries (results in bytes)
size_t initial_size();
virtual size_t capacity() const = 0; // The maximum number of object bytes the
// generation can currently hold.
virtual size_t used() const = 0; // The number of used bytes in the gen.

View File

@ -32,7 +32,6 @@
#include "gc/shared/gcLocker.hpp"
#include "gc/shared/gcTimer.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/space.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
@ -165,7 +164,7 @@ void TenuredGeneration::compute_new_size_inner() {
const double min_tmp = used_after_gc / maximum_used_percentage;
size_t minimum_desired_capacity = (size_t)MIN2(min_tmp, double(max_uintx));
// Don't shrink less than the initial generation size
minimum_desired_capacity = MAX2(minimum_desired_capacity, initial_size());
minimum_desired_capacity = MAX2(minimum_desired_capacity, OldSize);
assert(used_after_gc <= minimum_desired_capacity, "sanity check");
const size_t free_after_gc = free();
@ -204,7 +203,7 @@ void TenuredGeneration::compute_new_size_inner() {
const double minimum_used_percentage = 1.0 - maximum_free_percentage;
const double max_tmp = used_after_gc / minimum_used_percentage;
size_t maximum_desired_capacity = (size_t)MIN2(max_tmp, double(max_uintx));
maximum_desired_capacity = MAX2(maximum_desired_capacity, initial_size());
maximum_desired_capacity = MAX2(maximum_desired_capacity, OldSize);
log_trace(gc, heap)(" maximum_free_percentage: %6.2f minimum_used_percentage: %6.2f",
maximum_free_percentage, minimum_used_percentage);
log_trace(gc, heap)(" _capacity_at_prologue: %6.1fK minimum_desired_capacity: %6.1fK maximum_desired_capacity: %6.1fK",
@ -234,7 +233,7 @@ void TenuredGeneration::compute_new_size_inner() {
}
assert(shrink_bytes <= max_shrink_bytes, "invalid shrink size");
log_trace(gc, heap)(" shrinking: initSize: %.1fK maximum_desired_capacity: %.1fK",
initial_size() / (double) K, maximum_desired_capacity / (double) K);
OldSize / (double) K, maximum_desired_capacity / (double) K);
log_trace(gc, heap)(" shrink_bytes: %.1fK current_shrink_factor: " SIZE_FORMAT " new shrink factor: " SIZE_FORMAT " _min_heap_delta_bytes: %.1fK",
shrink_bytes / (double) K,
current_shrink_factor,

View File

@ -34,6 +34,7 @@
#include "gc/serial/defNewGeneration.hpp"
#include "gc/serial/genMarkSweep.hpp"
#include "gc/serial/markSweep.hpp"
#include "gc/serial/tenuredGeneration.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/collectorCounters.hpp"
@ -47,7 +48,6 @@
#include "gc/shared/gcVMOperations.hpp"
#include "gc/shared/genArguments.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/oopStorage.inline.hpp"
#include "gc/shared/oopStorageParState.inline.hpp"
@ -85,14 +85,6 @@ GenCollectedHeap::GenCollectedHeap(Generation::Name young,
CollectedHeap(),
_young_gen(nullptr),
_old_gen(nullptr),
_young_gen_spec(new GenerationSpec(young,
NewSize,
MaxNewSize,
GenAlignment)),
_old_gen_spec(new GenerationSpec(old,
OldSize,
MaxOldSize,
GenAlignment)),
_rem_set(nullptr),
_soft_ref_policy(),
_gc_policy_counters(new GCPolicyCounters(policy_counters_name, 2, 2)),
@ -115,8 +107,8 @@ jint GenCollectedHeap::initialize() {
initialize_reserved_region(heap_rs);
ReservedSpace young_rs = heap_rs.first_part(_young_gen_spec->max_size());
ReservedSpace old_rs = heap_rs.last_part(_young_gen_spec->max_size());
ReservedSpace young_rs = heap_rs.first_part(MaxNewSize);
ReservedSpace old_rs = heap_rs.last_part(MaxNewSize);
_rem_set = create_rem_set(heap_rs.region());
_rem_set->initialize(young_rs.base(), old_rs.base());
@ -125,8 +117,8 @@ jint GenCollectedHeap::initialize() {
bs->initialize();
BarrierSet::set_barrier_set(bs);
_young_gen = _young_gen_spec->init(young_rs, rem_set());
_old_gen = _old_gen_spec->init(old_rs, rem_set());
_young_gen = new DefNewGeneration(young_rs, NewSize, MinNewSize, MaxNewSize);
_old_gen = new TenuredGeneration(old_rs, OldSize, MinOldSize, MaxOldSize, rem_set());
GCInitLogger::print();
@ -143,8 +135,8 @@ ReservedHeapSpace GenCollectedHeap::allocate(size_t alignment) {
assert(alignment % pageSize == 0, "Must be");
// Check for overflow.
size_t total_reserved = _young_gen_spec->max_size() + _old_gen_spec->max_size();
if (total_reserved < _young_gen_spec->max_size()) {
size_t total_reserved = MaxNewSize + MaxOldSize;
if (total_reserved < MaxNewSize) {
vm_exit_during_initialization("The size of the object heap + VM data exceeds "
"the maximum representable size");
}
@ -199,14 +191,6 @@ PreGenGCValues GenCollectedHeap::get_pre_gc_values() const {
old_gen()->capacity());
}
GenerationSpec* GenCollectedHeap::young_gen_spec() const {
return _young_gen_spec;
}
GenerationSpec* GenCollectedHeap::old_gen_spec() const {
return _old_gen_spec;
}
size_t GenCollectedHeap::capacity() const {
return _young_gen->capacity() + _old_gen->capacity();
}

View File

@ -33,7 +33,6 @@
class CardTableRS;
class GCPolicyCounters;
class GenerationSpec;
// A "GenCollectedHeap" is a CollectedHeap that uses generational
// collection. It has two generations, young and old.
@ -62,9 +61,6 @@ protected:
Generation* _old_gen;
private:
GenerationSpec* _young_gen_spec;
GenerationSpec* _old_gen_spec;
// The singleton CardTable Remembered Set.
CardTableRS* _rem_set;
@ -144,9 +140,6 @@ public:
MemRegion reserved_region() const { return _reserved; }
bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }
GenerationSpec* young_gen_spec() const;
GenerationSpec* old_gen_spec() const;
SoftRefPolicy* soft_ref_policy() override { return &_soft_ref_policy; }
// Performance Counter support

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/serial/cardTableRS.hpp"
#include "gc/shared/generationSpec.hpp"
#include "runtime/java.hpp"
#include "utilities/macros.hpp"
#if INCLUDE_SERIALGC
#include "gc/serial/defNewGeneration.hpp"
#include "gc/serial/tenuredGeneration.hpp"
#endif
Generation* GenerationSpec::init(ReservedSpace rs, CardTableRS* remset) {
switch (name()) {
#if INCLUDE_SERIALGC
case Generation::DefNew:
return new DefNewGeneration(rs, _init_size, _min_size, _max_size);
case Generation::MarkSweepCompact:
return new TenuredGeneration(rs, _init_size, _min_size, _max_size, remset);
#endif
default:
guarantee(false, "unrecognized GenerationName");
return nullptr;
}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_SHARED_GENERATIONSPEC_HPP
#define SHARE_GC_SHARED_GENERATIONSPEC_HPP
#include "gc/serial/generation.hpp"
#include "utilities/align.hpp"
// The specification of a generation. This class also encapsulates
// some generation-specific behavior. This is done here rather than as a
// virtual function of Generation because these methods are needed in
// initialization of the Generations.
class GenerationSpec : public CHeapObj<mtGC> {
friend class VMStructs;
private:
Generation::Name _name;
size_t _init_size;
size_t _min_size;
size_t _max_size;
public:
GenerationSpec(Generation::Name name, size_t init_size, size_t max_size, size_t alignment) :
_name(name),
_init_size(align_up(init_size, alignment)),
_min_size(_init_size),
_max_size(align_up(max_size, alignment))
{ }
Generation* init(ReservedSpace rs, CardTableRS* remset);
Generation::Name name() const { return _name; }
size_t init_size() const { return _init_size; }
size_t min_size() const { return _min_size; }
size_t max_size() const { return _max_size; }
};
typedef GenerationSpec* GenerationSpecPtr;
#endif // SHARE_GC_SHARED_GENERATIONSPEC_HPP

View File

@ -29,7 +29,6 @@
#include "gc/shared/cardTable.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/genCollectedHeap.hpp"
#include "gc/shared/generationSpec.hpp"
#include "gc/shared/oopStorage.hpp"
#include "gc/shared/space.hpp"
#if INCLUDE_EPSILONGC
@ -114,14 +113,8 @@
nonstatic_field(Generation::StatRecord, invocations, int) \
nonstatic_field(Generation::StatRecord, accumulated_time, elapsedTimer) \
\
nonstatic_field(GenerationSpec, _name, Generation::Name) \
nonstatic_field(GenerationSpec, _init_size, size_t) \
nonstatic_field(GenerationSpec, _max_size, size_t) \
\
nonstatic_field(GenCollectedHeap, _young_gen, Generation*) \
nonstatic_field(GenCollectedHeap, _old_gen, Generation*) \
nonstatic_field(GenCollectedHeap, _young_gen_spec, GenerationSpec*) \
nonstatic_field(GenCollectedHeap, _old_gen_spec, GenerationSpec*) \
\
nonstatic_field(MemRegion, _start, HeapWord*) \
nonstatic_field(MemRegion, _word_size, size_t) \
@ -172,7 +165,6 @@
declare_toplevel_type(AgeTable) \
declare_toplevel_type(CardTable::CardValue) \
declare_toplevel_type(Generation::StatRecord) \
declare_toplevel_type(GenerationSpec) \
declare_toplevel_type(HeapWord) \
declare_toplevel_type(MemRegion) \
declare_toplevel_type(ThreadLocalAllocBuffer) \
@ -190,7 +182,6 @@
declare_toplevel_type(DefNewGeneration*) \
declare_toplevel_type(GenCollectedHeap*) \
declare_toplevel_type(Generation*) \
declare_toplevel_type(GenerationSpec**) \
declare_toplevel_type(HeapWord*) \
declare_toplevel_type(HeapWord* volatile) \
declare_toplevel_type(MemRegion*) \

View File

@ -39,9 +39,6 @@ public abstract class GenCollectedHeap extends CollectedHeap {
private static AddressField youngGenField;
private static AddressField oldGenField;
private static AddressField youngGenSpecField;
private static AddressField oldGenSpecField;
private static GenerationFactory genFactory;
static {
@ -57,8 +54,6 @@ public abstract class GenCollectedHeap extends CollectedHeap {
youngGenField = type.getAddressField("_young_gen");
oldGenField = type.getAddressField("_old_gen");
youngGenSpecField = type.getAddressField("_young_gen_spec");
oldGenSpecField = type.getAddressField("_old_gen_spec");
genFactory = new GenerationFactory();
}
@ -115,26 +110,6 @@ public abstract class GenCollectedHeap extends CollectedHeap {
return used;
}
/** Package-private access to GenerationSpecs */
GenerationSpec spec(int level) {
if (Assert.ASSERTS_ENABLED) {
Assert.that((level == 0) || (level == 1), "Index " + level +
" out of range (should be 0 or 1)");
}
if ((level != 0) && (level != 1)) {
return null;
}
if (level == 0) {
return VMObjectFactory.newObject(GenerationSpec.class,
youngGenSpecField.getAddress());
} else {
return VMObjectFactory.newObject(GenerationSpec.class,
oldGenSpecField.getAddress());
}
}
public void liveRegionsIterate(LiveRegionsClosure closure) {
// Run through all generations, obtaining bottom-top pairs.
for (int i = 0; i < nGens(); i++) {

View File

@ -1,71 +0,0 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc.shared;
import java.util.*;
import sun.jvm.hotspot.debugger.*;
import sun.jvm.hotspot.runtime.*;
import sun.jvm.hotspot.types.*;
import sun.jvm.hotspot.utilities.Observable;
import sun.jvm.hotspot.utilities.Observer;
public class GenerationSpec extends VMObject {
private static CIntegerField nameField;
private static CIntegerField initSizeField;
private static CIntegerField maxSizeField;
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
initialize(VM.getVM().getTypeDataBase());
}
});
}
private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("GenerationSpec");
nameField = type.getCIntegerField("_name");
initSizeField = type.getCIntegerField("_init_size");
maxSizeField = type.getCIntegerField("_max_size");
}
public GenerationSpec(Address addr) {
super(addr);
}
public Generation.Name name() {
return Generation.nameForEnum((int)nameField.getValue(addr));
}
public long initSize() {
return initSizeField.getValue(addr);
}
public long maxSize() {
return maxSizeField.getValue(addr);
}
}