< prev index next >
src/share/vm/memory/generation.cpp
Print this page
rev 8333 : 8077842: Remove the level parameter passed around in GenCollectedHeap
Reviewed-by:
@@ -40,12 +40,11 @@
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
#include "utilities/copy.hpp"
#include "utilities/events.hpp"
-Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
- _level(level),
+Generation::Generation(ReservedSpace rs, size_t initial_size) :
_ref_processor(NULL) {
if (!_virtual_space.initialize(rs, initial_size)) {
vm_exit_during_initialization("Could not reserve enough space for "
"object heap");
}
@@ -59,12 +58,14 @@
(HeapWord*)_virtual_space.high_boundary());
}
GenerationSpec* Generation::spec() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- assert(level() == 0 || level() == 1, "Bad gen level");
- return level() == 0 ? gch->gen_policy()->young_gen_spec() : gch->gen_policy()->old_gen_spec();
+ if (this == gch->young_gen()) {
+ return gch->gen_policy()->young_gen_spec();
+ }
+ return gch->gen_policy()->old_gen_spec();
}
size_t Generation::max_capacity() const {
return reserved().byte_size();
}
@@ -109,13 +110,21 @@
void Generation::print_summary_info() { print_summary_info_on(tty); }
void Generation::print_summary_info_on(outputStream* st) {
StatRecord* sr = stat_record();
double time = sr->accumulated_time.seconds();
+ // I didn't want to change the logging when removing the level concept,
+ // but I guess this logging could say young/old or something instead of 0/1.
+ uint level;
+ if (this == GenCollectedHeap::heap()->young_gen()) {
+ level = 0;
+ } else {
+ level = 1;
+ }
st->print_cr("[Accumulated GC generation %d time %3.7f secs, "
- "%d GC's, avg GC time %3.7f]",
- level(), time, sr->invocations,
+ "%u GC's, avg GC time %3.7f]",
+ level, time, sr->invocations,
sr->invocations > 0 ? time / sr->invocations : 0.0);
}
// Utility iterator classes
@@ -147,29 +156,18 @@
GenerationIsInClosure blk(p);
((Generation*)this)->space_iterate(&blk);
return blk.sp != NULL;
}
-Generation* Generation::next_gen() const {
- GenCollectedHeap* gch = GenCollectedHeap::heap();
- if (level() == 0) {
- return gch->old_gen();
- } else {
- return NULL;
- }
-}
-
size_t Generation::max_contiguous_available() const {
// The largest number of contiguous free words in this or any higher generation.
- size_t max = 0;
- for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
- size_t avail = gen->contiguous_available();
- if (avail > max) {
- max = avail;
- }
+ size_t avail = contiguous_available();
+ size_t old_avail = 0;
+ if (this == GenCollectedHeap::heap()->young_gen()) {
+ old_avail = GenCollectedHeap::heap()->old_gen()->contiguous_available();
}
- return max;
+ return MAX2(avail, old_avail);
}
bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
size_t available = max_contiguous_available();
bool res = (available >= max_promotion_in_bytes);
< prev index next >