mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8075635: Remove GenerationSpec array
Replaced the array with explicit variables for young and old Reviewed-by: kbarrett, mgerdin
This commit is contained in:
parent
0a05ebc7f7
commit
2c63bc9175
11 changed files with 72 additions and 77 deletions
|
@ -37,7 +37,9 @@ public class GenCollectedHeap extends SharedHeap {
|
|||
private static CIntegerField nGensField;
|
||||
private static AddressField youngGenField;
|
||||
private static AddressField oldGenField;
|
||||
private static AddressField genSpecsField;
|
||||
|
||||
private static AddressField youngGenSpecField;
|
||||
private static AddressField oldGenSpecField;
|
||||
|
||||
private static GenerationFactory genFactory;
|
||||
|
||||
|
@ -55,9 +57,12 @@ public class GenCollectedHeap extends SharedHeap {
|
|||
nGensField = type.getCIntegerField("_n_gens");
|
||||
youngGenField = type.getAddressField("_young_gen");
|
||||
oldGenField = type.getAddressField("_old_gen");
|
||||
genSpecsField = type.getAddressField("_gen_specs");
|
||||
|
||||
genFactory = new GenerationFactory();
|
||||
|
||||
Type collectorPolicyType = db.lookupType("GenCollectorPolicy");
|
||||
youngGenSpecField = collectorPolicyType.getAddressField("_young_gen_spec");
|
||||
oldGenSpecField = collectorPolicyType.getAddressField("_old_gen_spec");
|
||||
}
|
||||
|
||||
public GenCollectedHeap(Address addr) {
|
||||
|
@ -115,21 +120,23 @@ public class GenCollectedHeap extends SharedHeap {
|
|||
/** Package-private access to GenerationSpecs */
|
||||
GenerationSpec spec(int level) {
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that((level >= 0) && (level < nGens()), "Index " + level +
|
||||
" out of range (should be between 0 and " + nGens() + ")");
|
||||
Assert.that((level == 0) || (level == 1), "Index " + level +
|
||||
" out of range (should be 0 or 1)");
|
||||
}
|
||||
|
||||
if ((level < 0) || (level >= nGens())) {
|
||||
if ((level != 0) && (level != 1)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Address ptrList = genSpecsField.getValue(addr);
|
||||
if (ptrList == null) {
|
||||
return null;
|
||||
}
|
||||
if (level == 0) {
|
||||
return (GenerationSpec)
|
||||
VMObjectFactory.newObject(GenerationSpec.class,
|
||||
ptrList.getAddressAt(level * VM.getVM().getAddressSize()));
|
||||
youngGenSpecField.getAddress());
|
||||
} else {
|
||||
return (GenerationSpec)
|
||||
VMObjectFactory.newObject(GenerationSpec.class,
|
||||
oldGenSpecField.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
public CollectedHeapName kind() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
|
@ -52,9 +52,10 @@ void ConcurrentMarkSweepPolicy::initialize_alignments() {
|
|||
}
|
||||
|
||||
void ConcurrentMarkSweepPolicy::initialize_generations() {
|
||||
_generations = NEW_C_HEAP_ARRAY(GenerationSpecPtr, number_of_generations(), mtGC);
|
||||
_generations[0] = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size);
|
||||
_generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, _initial_old_size, _max_old_size);
|
||||
_young_gen_spec = new GenerationSpec(Generation::ParNew, _initial_young_size,
|
||||
_max_young_size, _gen_alignment);
|
||||
_old_gen_spec = new GenerationSpec(Generation::ConcurrentMarkSweep,
|
||||
_initial_old_size, _max_old_size, _gen_alignment);
|
||||
}
|
||||
|
||||
void ConcurrentMarkSweepPolicy::initialize_size_policy(size_t init_eden_size,
|
||||
|
|
|
@ -190,11 +190,12 @@ GenCollectorPolicy::GenCollectorPolicy() :
|
|||
_min_young_size(0),
|
||||
_initial_young_size(0),
|
||||
_max_young_size(0),
|
||||
_gen_alignment(0),
|
||||
_min_old_size(0),
|
||||
_initial_old_size(0),
|
||||
_max_old_size(0),
|
||||
_generations(NULL)
|
||||
_gen_alignment(0),
|
||||
_young_gen_spec(NULL),
|
||||
_old_gen_spec(NULL)
|
||||
{}
|
||||
|
||||
size_t GenCollectorPolicy::scale_by_NewRatio_aligned(size_t base_size) {
|
||||
|
@ -912,9 +913,8 @@ void MarkSweepPolicy::initialize_alignments() {
|
|||
}
|
||||
|
||||
void MarkSweepPolicy::initialize_generations() {
|
||||
_generations = NEW_C_HEAP_ARRAY(GenerationSpecPtr, number_of_generations(), mtGC);
|
||||
_generations[0] = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size);
|
||||
_generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size);
|
||||
_young_gen_spec = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size, _gen_alignment);
|
||||
_old_gen_spec = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size, _gen_alignment);
|
||||
}
|
||||
|
||||
void MarkSweepPolicy::initialize_gc_policy_counters() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2015, 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
|
||||
|
@ -209,6 +209,7 @@ class ClearedAllSoftRefs : public StackObj {
|
|||
|
||||
class GenCollectorPolicy : public CollectorPolicy {
|
||||
friend class TestGenCollectorPolicy;
|
||||
friend class VMStructs;
|
||||
protected:
|
||||
size_t _min_young_size;
|
||||
size_t _initial_young_size;
|
||||
|
@ -221,7 +222,8 @@ friend class TestGenCollectorPolicy;
|
|||
// time. When using large pages they can differ.
|
||||
size_t _gen_alignment;
|
||||
|
||||
GenerationSpec **_generations;
|
||||
GenerationSpec* _young_gen_spec;
|
||||
GenerationSpec* _old_gen_spec;
|
||||
|
||||
// Return true if an allocation should be attempted in the older generation
|
||||
// if it fails in the younger generation. Return false, otherwise.
|
||||
|
@ -261,9 +263,14 @@ friend class TestGenCollectorPolicy;
|
|||
|
||||
int number_of_generations() { return 2; }
|
||||
|
||||
virtual GenerationSpec **generations() {
|
||||
assert(_generations != NULL, "Sanity check");
|
||||
return _generations;
|
||||
GenerationSpec* young_gen_spec() const {
|
||||
assert(_young_gen_spec != NULL, "_young_gen_spec should have been initialized");
|
||||
return _young_gen_spec;
|
||||
}
|
||||
|
||||
GenerationSpec* old_gen_spec() const {
|
||||
assert(_old_gen_spec != NULL, "_old_gen_spec should have been initialized");
|
||||
return _old_gen_spec;
|
||||
}
|
||||
|
||||
virtual GenCollectorPolicy* as_generation_policy() { return this; }
|
||||
|
|
|
@ -380,7 +380,7 @@ void DefNewGeneration::compute_new_size() {
|
|||
|
||||
int next_level = level() + 1;
|
||||
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
||||
assert(next_level < gch->_n_gens,
|
||||
assert(next_level < gch->n_gens(),
|
||||
"DefNewGeneration cannot be an oldest gen");
|
||||
|
||||
Generation* old_gen = gch->old_gen();
|
||||
|
|
|
@ -90,7 +90,6 @@ GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy) :
|
|||
jint GenCollectedHeap::initialize() {
|
||||
CollectedHeap::pre_initialize();
|
||||
|
||||
int i;
|
||||
_n_gens = gen_policy()->number_of_generations();
|
||||
assert(_n_gens == 2, "There is no support for more than two generations");
|
||||
|
||||
|
@ -101,16 +100,6 @@ jint GenCollectedHeap::initialize() {
|
|||
// HeapWordSize).
|
||||
guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
|
||||
|
||||
// The heap must be at least as aligned as generations.
|
||||
size_t gen_alignment = Generation::GenGrain;
|
||||
|
||||
_gen_specs = gen_policy()->generations();
|
||||
|
||||
// Make sure the sizes are all aligned.
|
||||
for (i = 0; i < _n_gens; i++) {
|
||||
_gen_specs[i]->align(gen_alignment);
|
||||
}
|
||||
|
||||
// Allocate space for the heap.
|
||||
|
||||
char* heap_address;
|
||||
|
@ -133,12 +122,12 @@ jint GenCollectedHeap::initialize() {
|
|||
|
||||
_gch = this;
|
||||
|
||||
ReservedSpace young_rs = heap_rs.first_part(_gen_specs[0]->max_size(), false, false);
|
||||
_young_gen = _gen_specs[0]->init(young_rs, 0, rem_set());
|
||||
heap_rs = heap_rs.last_part(_gen_specs[0]->max_size());
|
||||
ReservedSpace young_rs = heap_rs.first_part(gen_policy()->young_gen_spec()->max_size(), false, false);
|
||||
_young_gen = gen_policy()->young_gen_spec()->init(young_rs, 0, rem_set());
|
||||
heap_rs = heap_rs.last_part(gen_policy()->young_gen_spec()->max_size());
|
||||
|
||||
ReservedSpace old_rs = heap_rs.first_part(_gen_specs[1]->max_size(), false, false);
|
||||
_old_gen = _gen_specs[1]->init(old_rs, 1, rem_set());
|
||||
ReservedSpace old_rs = heap_rs.first_part(gen_policy()->old_gen_spec()->max_size(), false, false);
|
||||
_old_gen = gen_policy()->old_gen_spec()->init(old_rs, 1, rem_set());
|
||||
clear_incremental_collection_failed();
|
||||
|
||||
#if INCLUDE_ALL_GCS
|
||||
|
@ -155,21 +144,18 @@ jint GenCollectedHeap::initialize() {
|
|||
|
||||
char* GenCollectedHeap::allocate(size_t alignment,
|
||||
ReservedSpace* heap_rs){
|
||||
const char overflow_msg[] = "The size of the object heap + VM data exceeds "
|
||||
"the maximum representable size";
|
||||
|
||||
// Now figure out the total size.
|
||||
size_t total_reserved = 0;
|
||||
const size_t pageSize = UseLargePages ?
|
||||
os::large_page_size() : os::vm_page_size();
|
||||
|
||||
const size_t pageSize = UseLargePages ? os::large_page_size() : os::vm_page_size();
|
||||
assert(alignment % pageSize == 0, "Must be");
|
||||
|
||||
for (int i = 0; i < _n_gens; i++) {
|
||||
total_reserved += _gen_specs[i]->max_size();
|
||||
if (total_reserved < _gen_specs[i]->max_size()) {
|
||||
vm_exit_during_initialization(overflow_msg);
|
||||
}
|
||||
GenerationSpec* young_spec = gen_policy()->young_gen_spec();
|
||||
GenerationSpec* old_spec = gen_policy()->old_gen_spec();
|
||||
|
||||
// Check for overflow.
|
||||
size_t total_reserved = young_spec->max_size() + old_spec->max_size();
|
||||
if (total_reserved < young_spec->max_size()) {
|
||||
vm_exit_during_initialization("The size of the object heap + VM data exceeds "
|
||||
"the maximum representable size");
|
||||
}
|
||||
assert(total_reserved % alignment == 0,
|
||||
err_msg("Gen size; total_reserved=" SIZE_FORMAT ", alignment="
|
||||
|
|
|
@ -67,8 +67,6 @@ public:
|
|||
Generation* _young_gen;
|
||||
Generation* _old_gen;
|
||||
|
||||
GenerationSpec** _gen_specs;
|
||||
|
||||
// The singleton Gen Remembered Set.
|
||||
GenRemSet* _rem_set;
|
||||
|
||||
|
@ -145,8 +143,8 @@ public:
|
|||
return CollectedHeap::GenCollectedHeap;
|
||||
}
|
||||
|
||||
Generation* young_gen() { return _young_gen; }
|
||||
Generation* old_gen() { return _old_gen; }
|
||||
Generation* young_gen() const { return _young_gen; }
|
||||
Generation* old_gen() const { return _old_gen; }
|
||||
|
||||
// The generational collector policy.
|
||||
GenCollectorPolicy* gen_policy() const { return _gen_policy; }
|
||||
|
|
|
@ -63,8 +63,8 @@ Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
|
|||
|
||||
GenerationSpec* Generation::spec() {
|
||||
GenCollectedHeap* gch = GenCollectedHeap::heap();
|
||||
assert(0 <= level() && level() < gch->_n_gens, "Bad gen level");
|
||||
return gch->_gen_specs[level()];
|
||||
assert(level() == 0 || level() == 1, "Bad gen level");
|
||||
return level() == 0 ? gch->gen_policy()->young_gen_spec() : gch->gen_policy()->old_gen_spec();
|
||||
}
|
||||
|
||||
size_t Generation::max_capacity() const {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2015, 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
|
||||
|
@ -39,11 +39,11 @@ private:
|
|||
size_t _max_size;
|
||||
|
||||
public:
|
||||
GenerationSpec(Generation::Name name, size_t init_size, size_t max_size) {
|
||||
_name = name;
|
||||
_init_size = init_size;
|
||||
_max_size = max_size;
|
||||
}
|
||||
GenerationSpec(Generation::Name name, size_t init_size, size_t max_size, size_t alignment) :
|
||||
_name(name),
|
||||
_init_size(align_size_up(init_size, alignment)),
|
||||
_max_size(align_size_up(max_size, alignment))
|
||||
{ }
|
||||
|
||||
Generation* init(ReservedSpace rs, int level, GenRemSet* remset);
|
||||
|
||||
|
@ -53,12 +53,6 @@ public:
|
|||
void set_init_size(size_t size) { _init_size = size; }
|
||||
size_t max_size() const { return _max_size; }
|
||||
void set_max_size(size_t size) { _max_size = size; }
|
||||
|
||||
// Alignment
|
||||
void align(size_t alignment) {
|
||||
set_init_size(align_size_up(init_size(), alignment));
|
||||
set_max_size(align_size_up(max_size(), alignment));
|
||||
}
|
||||
};
|
||||
|
||||
typedef GenerationSpec* GenerationSpecPtr;
|
||||
|
|
|
@ -527,11 +527,11 @@ typedef CompactHashtable<Symbol*, char> SymbolCompactHashTable;
|
|||
nonstatic_field(CollectedHeap, _defer_initial_card_mark, bool) \
|
||||
nonstatic_field(CollectedHeap, _is_gc_active, bool) \
|
||||
nonstatic_field(CollectedHeap, _total_collections, unsigned int) \
|
||||
\
|
||||
nonstatic_field(CompactibleSpace, _compaction_top, HeapWord*) \
|
||||
nonstatic_field(CompactibleSpace, _first_dead, HeapWord*) \
|
||||
nonstatic_field(CompactibleSpace, _end_of_live, HeapWord*) \
|
||||
\
|
||||
\
|
||||
nonstatic_field(ContiguousSpace, _top, HeapWord*) \
|
||||
nonstatic_field(ContiguousSpace, _concurrent_iteration_safe_limit, HeapWord*) \
|
||||
nonstatic_field(ContiguousSpace, _saved_mark_word, HeapWord*) \
|
||||
|
@ -559,7 +559,9 @@ typedef CompactHashtable<Symbol*, char> SymbolCompactHashTable;
|
|||
nonstatic_field(GenCollectedHeap, _young_gen, Generation*) \
|
||||
nonstatic_field(GenCollectedHeap, _old_gen, Generation*) \
|
||||
nonstatic_field(GenCollectedHeap, _n_gens, int) \
|
||||
nonstatic_field(GenCollectedHeap, _gen_specs, GenerationSpec**) \
|
||||
\
|
||||
nonstatic_field(GenCollectorPolicy, _young_gen_spec, GenerationSpec*) \
|
||||
nonstatic_field(GenCollectorPolicy, _old_gen_spec, GenerationSpec*) \
|
||||
\
|
||||
nonstatic_field(HeapWord, i, char*) \
|
||||
\
|
||||
|
@ -1505,6 +1507,7 @@ typedef CompactHashtable<Symbol*, char> SymbolCompactHashTable;
|
|||
declare_type(DefNewGeneration, Generation) \
|
||||
declare_type(CardGeneration, Generation) \
|
||||
declare_type(TenuredGeneration, CardGeneration) \
|
||||
declare_toplevel_type(GenCollectorPolicy) \
|
||||
declare_toplevel_type(Space) \
|
||||
declare_toplevel_type(BitMap) \
|
||||
declare_type(CompactibleSpace, Space) \
|
||||
|
|
|
@ -130,8 +130,7 @@ void MemoryService::add_gen_collected_heap_info(GenCollectedHeap* heap) {
|
|||
|
||||
GenCollectorPolicy* gen_policy = policy->as_generation_policy();
|
||||
if (gen_policy != NULL) {
|
||||
GenerationSpec** specs = gen_policy->generations();
|
||||
Generation::Name kind = specs[0]->name();
|
||||
Generation::Name kind = gen_policy->young_gen_spec()->name();
|
||||
switch (kind) {
|
||||
case Generation::DefNew:
|
||||
_minor_gc_manager = MemoryManager::get_copy_memory_manager();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue