< prev index next >
src/share/vm/memory/genCollectedHeap.hpp
Print this page
rev 7696 : 8061802: REDO - Remove the generations array
Summary: The _gens array is removed and replaced by explicit _young_gen and _old_gen variables.
Reviewed-by:
@@ -31,11 +31,11 @@
#include "memory/sharedHeap.hpp"
class SubTasksDone;
// A "GenCollectedHeap" is a SharedHeap that uses generational
-// collection. It is represented with a sequence of Generation's.
+// collection. It has two generations, young and old.
class GenCollectedHeap : public SharedHeap {
friend class GenCollectorPolicy;
friend class Generation;
friend class DefNewGeneration;
friend class TenuredGeneration;
@@ -61,11 +61,14 @@
// Fields:
static GenCollectedHeap* _gch;
private:
int _n_gens;
- Generation* _gens[max_gens];
+
+ Generation* _young_gen;
+ Generation* _old_gen;
+
GenerationSpec** _gen_specs;
// The singleton Gen Remembered Set.
GenRemSet* _rem_set;
@@ -83,10 +86,15 @@
// Data structure for claiming the (potentially) parallel tasks in
// (gen-specific) roots processing.
SubTasksDone* _gen_process_roots_tasks;
SubTasksDone* gen_process_roots_tasks() { return _gen_process_roots_tasks; }
+ // Collects the given generation.
+ void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
+ bool run_verification, bool clear_soft_refs,
+ bool restore_marks_for_biased_locking);
+
// In block contents verification, the number of header words to skip
NOT_PRODUCT(static size_t _skip_header_HeapWords;)
protected:
// Helper functions for allocation
@@ -122,10 +130,11 @@
GCStats* gc_stats(int level) const;
// Returns JNI_OK on success
virtual jint initialize();
+
char* allocate(size_t alignment, size_t* _total_reserved, ReservedSpace* heap_rs);
// Does operations required after initialization has been done.
void post_initialize();
@@ -134,12 +143,16 @@
virtual CollectedHeap::Name kind() const {
return CollectedHeap::GenCollectedHeap;
}
+ Generation* young_gen() { return _young_gen; }
+ Generation* old_gen() { return _old_gen; }
+
// The generational collector policy.
GenCollectorPolicy* gen_policy() const { return _gen_policy; }
+
virtual CollectorPolicy* collector_policy() const { return (CollectorPolicy*) gen_policy(); }
// Adaptive size policy
virtual AdaptiveSizePolicy* size_policy() {
return gen_policy()->size_policy();
@@ -305,24 +318,21 @@
// Update above counter, as appropriate, at the end of a stop-world GC cycle
unsigned int update_full_collections_completed();
// Update above counter, as appropriate, at the end of a concurrent GC cycle
unsigned int update_full_collections_completed(unsigned int count);
- // Update "time of last gc" for all constituent generations
- // to "now".
+ // Update "time of last gc" for all generations to "now".
void update_time_of_last_gc(jlong now) {
- for (int i = 0; i < _n_gens; i++) {
- _gens[i]->update_time_of_last_gc(now);
- }
+ _young_gen->update_time_of_last_gc(now);
+ _old_gen->update_time_of_last_gc(now);
}
// Update the gc statistics for each generation.
// "level" is the level of the latest collection.
void update_gc_stats(int current_level, bool full) {
- for (int i = 0; i < _n_gens; i++) {
- _gens[i]->update_gc_stats(current_level, full);
- }
+ _young_gen->update_gc_stats(current_level, full);
+ _old_gen->update_gc_stats(current_level, full);
}
// Override.
bool no_gc_in_progress() { return !is_gc_active(); }
@@ -362,25 +372,27 @@
// collection.
virtual bool is_maximal_no_gc() const;
// Return the generation before "gen".
Generation* prev_gen(Generation* gen) const {
- int l = gen->level();
- guarantee(l > 0, "Out of bounds");
- return _gens[l-1];
+ guarantee(gen->level() == 1, "Out of bounds");
+ return _young_gen;
}
// Return the generation after "gen".
Generation* next_gen(Generation* gen) const {
- int l = gen->level() + 1;
- guarantee(l < _n_gens, "Out of bounds");
- return _gens[l];
+ guarantee(gen->level() == 0, "Out of bounds");
+ return _old_gen;
}
Generation* get_gen(int i) const {
guarantee(i >= 0 && i < _n_gens, "Out of bounds");
- return _gens[i];
+ if (i == 0) {
+ return _young_gen;
+ } else {
+ return _old_gen;
+ }
}
int n_gens() const {
assert(_n_gens == gen_policy()->number_of_generations(), "Sanity");
return _n_gens;
< prev index next >