< prev index next >
src/share/vm/gc/shared/generation.cpp
Print this page
rev 8393 : 8077842: Remove the level parameter passed around in GenCollectedHeap
Reviewed-by:
*** 40,51 ****
#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),
_ref_processor(NULL) {
if (!_virtual_space.initialize(rs, initial_size)) {
vm_exit_during_initialization("Could not reserve enough space for "
"object heap");
}
--- 40,50 ----
#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) :
_ref_processor(NULL) {
if (!_virtual_space.initialize(rs, initial_size)) {
vm_exit_during_initialization("Could not reserve enough space for "
"object heap");
}
*** 59,70 ****
(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();
}
size_t Generation::max_capacity() const {
return reserved().byte_size();
}
--- 58,71 ----
(HeapWord*)_virtual_space.high_boundary());
}
GenerationSpec* Generation::spec() {
GenCollectedHeap* gch = GenCollectedHeap::heap();
! 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,121 ****
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();
st->print_cr("[Accumulated GC generation %d time %3.7f secs, "
! "%d GC's, avg GC time %3.7f]",
! level(), time, sr->invocations,
sr->invocations > 0 ? time / sr->invocations : 0.0);
}
// Utility iterator classes
--- 110,130 ----
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, "
! "%u GC's, avg GC time %3.7f]",
! level, time, sr->invocations,
sr->invocations > 0 ? time / sr->invocations : 0.0);
}
// Utility iterator classes
*** 147,175 ****
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;
! }
}
! return max;
}
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);
--- 156,173 ----
GenerationIsInClosure blk(p);
((Generation*)this)->space_iterate(&blk);
return blk.sp != NULL;
}
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 (this == GenCollectedHeap::heap()->young_gen()) {
! old_avail = GenCollectedHeap::heap()->old_gen()->contiguous_available();
}
! 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 >