--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/GenCollectedHeap.java Thu Apr 02 16:37:29 2015 +0200
@@ -34,7 +34,6 @@
import sun.jvm.hotspot.utilities.*;
public class GenCollectedHeap extends CollectedHeap {
- private static CIntegerField nGensField;
private static AddressField youngGenField;
private static AddressField oldGenField;
@@ -54,7 +53,6 @@
private static synchronized void initialize(TypeDataBase db) {
Type type = db.lookupType("GenCollectedHeap");
- nGensField = type.getCIntegerField("_n_gens");
youngGenField = type.getAddressField("_young_gen");
oldGenField = type.getAddressField("_old_gen");
@@ -70,7 +68,7 @@
}
public int nGens() {
- return (int) nGensField.getValue(addr);
+ return 2; // Young + Old
}
public Generation getGen(int i) {
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu Apr 02 16:37:29 2015 +0200
@@ -596,8 +596,6 @@
// and handle marks.
ResourceMark rm;
HandleMark hm;
- // We would need multiple old-gen queues otherwise.
- assert(gch->n_gens() == 2, "Par young collection currently only works with one older gen.");
ParScanThreadState& par_scan_state = _state_set->thread_state(worker_id);
assert(_state_set->is_valid(worker_id), "Should not have been called");
@@ -922,8 +920,6 @@
workers->active_workers(),
Threads::number_of_non_daemon_threads());
workers->set_active_workers(active_workers);
- assert(gch->n_gens() == 2,
- "Par collection currently only works with single older gen.");
_old_gen = gch->old_gen();
// If the next generation is too full to accommodate worst-case promotion
--- a/hotspot/src/share/vm/memory/cardTableRS.cpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/memory/cardTableRS.cpp Thu Apr 02 16:37:29 2015 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2014, 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
@@ -42,12 +42,15 @@
_ct_bs = new CardTableModRefBSForCTRS(whole_heap);
_ct_bs->initialize();
set_bs(_ct_bs);
- _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, GenCollectedHeap::max_gens + 1,
+ // max_gens is really GenCollectedHeap::heap()->gen_policy()->number_of_generations()
+ // (which is always 2, young & old), but GenCollectedHeap has not been initialized yet.
+ uint max_gens = 2;
+ _last_cur_val_in_gen = NEW_C_HEAP_ARRAY3(jbyte, max_gens + 1,
mtGC, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
if (_last_cur_val_in_gen == NULL) {
vm_exit_during_initialization("Could not create last_cur_val_in_gen array.");
}
- for (int i = 0; i < GenCollectedHeap::max_gens + 1; i++) {
+ for (uint i = 0; i < max_gens + 1; i++) {
_last_cur_val_in_gen[i] = clean_card_val();
}
_ct_bs->set_CTRS(this);
--- a/hotspot/src/share/vm/memory/defNewGeneration.cpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp Thu Apr 02 16:37:29 2015 +0200
@@ -381,8 +381,7 @@
int next_level = level() + 1;
GenCollectedHeap* gch = GenCollectedHeap::heap();
- assert(next_level < gch->n_gens(),
- "DefNewGeneration cannot be an oldest gen");
+ assert(next_level == 1, "DefNewGeneration must be a young gen");
Generation* old_gen = gch->old_gen();
size_t old_size = old_gen->capacity();
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Thu Apr 02 16:37:29 2015 +0200
@@ -99,9 +99,6 @@
jint GenCollectedHeap::initialize() {
CollectedHeap::pre_initialize();
- _n_gens = gen_policy()->number_of_generations();
- assert(_n_gens == 2, "There is no support for more than two generations");
-
// While there are no constraints in the GC code that HeapWordSize
// be any particular value, there are multiple other areas in the
// system which believe this to be true (e.g. oop->object_size in some
@@ -209,8 +206,7 @@
// Save the "used_region" for generations level and lower.
void GenCollectedHeap::save_used_regions(int level) {
- assert(level >= 0, "Illegal level parameter");
- assert(level < _n_gens, "Illegal level parameter");
+ assert(level == 0 || level == 1, "Illegal level parameter");
if (level == 1) {
_old_gen->save_used_region();
}
@@ -426,7 +422,6 @@
assert(Heap_lock->is_locked(),
"the requesting thread should have the Heap_lock");
guarantee(!is_gc_active(), "collection is not reentrant");
- assert(max_level < n_gens(), "sanity check");
if (GC_locker::check_active_before_gc()) {
return; // GC is disabled (e.g. JNI GetXXXCritical operation)
@@ -444,7 +439,7 @@
{
FlagSetting fl(_is_gc_active, true);
- bool complete = full && (max_level == (n_gens()-1));
+ bool complete = full && (max_level == 1 /* old */);
const char* gc_cause_prefix = complete ? "Full GC" : "GC";
TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
// The PrintGCDetails logging starts before we have incremented the GC id. We will do that later
@@ -516,7 +511,7 @@
// Update "complete" boolean wrt what actually transpired --
// for instance, a promotion failure could have led to
// a whole heap collection.
- complete = complete || (max_level_collected == n_gens() - 1);
+ complete = complete || (max_level_collected == 1 /* old */);
if (complete) { // We did a "major" collection
// FIXME: See comment at pre_full_gc_dump call
@@ -533,7 +528,7 @@
}
// Adjust generation sizes.
- if (max_level_collected == 1) {
+ if (max_level_collected == 1 /* old */) {
_old_gen->compute_new_size();
}
_young_gen->compute_new_size();
@@ -782,19 +777,19 @@
#endif // INCLUDE_ALL_GCS
} else if (cause == GCCause::_wb_young_gc) {
// minor collection for WhiteBox API
- collect(cause, 0);
+ collect(cause, 0 /* young */);
} else {
#ifdef ASSERT
if (cause == GCCause::_scavenge_alot) {
// minor collection only
- collect(cause, 0);
+ collect(cause, 0 /* young */);
} else {
// Stop-the-world full collection
- collect(cause, n_gens() - 1);
+ collect(cause, 1 /* old */);
}
#else
// Stop-the-world full collection
- collect(cause, n_gens() - 1);
+ collect(cause, 1 /* old */);
#endif
}
}
@@ -809,7 +804,7 @@
void GenCollectedHeap::collect_locked(GCCause::Cause cause) {
// The caller has the Heap_lock
assert(Heap_lock->owned_by_self(), "this thread should own the Heap_lock");
- collect_locked(cause, n_gens() - 1);
+ collect_locked(cause, 1 /* old */);
}
// this is the private collection interface
@@ -865,7 +860,7 @@
#endif // INCLUDE_ALL_GCS
void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs) {
- do_full_collection(clear_all_soft_refs, _n_gens - 1);
+ do_full_collection(clear_all_soft_refs, 1 /* old */);
}
void GenCollectedHeap::do_full_collection(bool clear_all_soft_refs,
@@ -897,7 +892,7 @@
clear_all_soft_refs /* clear_all_soft_refs */,
0 /* size */,
false /* is_tlab */,
- n_gens() - 1 /* max_level */);
+ 1 /* old */ /* max_level */);
}
}
@@ -1123,9 +1118,7 @@
return _gch;
}
-
void GenCollectedHeap::prepare_for_compaction() {
- guarantee(_n_gens = 2, "Wrong number of generations");
// Start by compacting into same gen.
CompactPoint cp(_old_gen);
_old_gen->prepare_for_compaction(&cp);
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp Thu Apr 02 16:37:29 2015 +0200
@@ -52,10 +52,6 @@
friend class GCCauseSetter;
friend class VMStructs;
public:
- enum SomeConstants {
- max_gens = 10
- };
-
friend class VM_PopulateDumpSharedSpace;
protected:
@@ -63,8 +59,6 @@
static GenCollectedHeap* _gch;
private:
- int _n_gens;
-
Generation* _young_gen;
Generation* _old_gen;
@@ -373,11 +367,6 @@
// collection.
virtual bool is_maximal_no_gc() const;
- int n_gens() const {
- assert(_n_gens == gen_policy()->number_of_generations(), "Sanity");
- return _n_gens;
- }
-
// This function returns the "GenRemSet" object that allows us to scan
// generations in a fully generational heap.
GenRemSet* rem_set() { return _rem_set; }
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Thu Apr 02 16:37:29 2015 +0200
@@ -558,7 +558,6 @@
static_field(GenCollectedHeap, _gch, GenCollectedHeap*) \
nonstatic_field(GenCollectedHeap, _young_gen, Generation*) \
nonstatic_field(GenCollectedHeap, _old_gen, Generation*) \
- nonstatic_field(GenCollectedHeap, _n_gens, int) \
\
nonstatic_field(GenCollectorPolicy, _young_gen_spec, GenerationSpec*) \
nonstatic_field(GenCollectorPolicy, _old_gen_spec, GenerationSpec*) \
@@ -2256,8 +2255,6 @@
declare_constant(CollectedHeap::ParallelScavengeHeap) \
declare_constant(CollectedHeap::G1CollectedHeap) \
\
- declare_constant(GenCollectedHeap::max_gens) \
- \
/* constants from Generation::Name enum */ \
\
declare_constant(Generation::DefNew) \
--- a/hotspot/src/share/vm/services/memoryService.cpp Thu Apr 02 16:08:41 2015 +0200
+++ b/hotspot/src/share/vm/services/memoryService.cpp Thu Apr 02 16:37:29 2015 +0200
@@ -126,9 +126,8 @@
CollectorPolicy* policy = heap->collector_policy();
assert(policy->is_generation_policy(), "Only support two generations");
- guarantee(heap->n_gens() == 2, "Only support two-generation heap");
-
GenCollectorPolicy* gen_policy = policy->as_generation_policy();
+ guarantee(gen_policy->number_of_generations() == 2, "Only support two-generation heap");
if (gen_policy != NULL) {
Generation::Name kind = gen_policy->young_gen_spec()->name();
switch (kind) {