hotspot/src/share/vm/memory/genCollectedHeap.hpp
changeset 27252 9703e3f1f92a
parent 27249 698a2dc8e83a
child 27687 3a6367d7110b
--- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Tue Oct 21 11:57:22 2014 +0200
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp	Wed Oct 22 16:40:43 2014 +0200
@@ -33,7 +33,7 @@
 class SubTasksDone;
 
 // A "GenCollectedHeap" is a SharedHeap that uses generational
-// collection.  It has two generations, young and old.
+// collection.  It is represented with a sequence of Generation's.
 class GenCollectedHeap : public SharedHeap {
   friend class GenCollectorPolicy;
   friend class Generation;
@@ -63,10 +63,7 @@
 
  private:
   int _n_gens;
-
-  Generation* _young_gen;
-  Generation* _old_gen;
-
+  Generation* _gens[max_gens];
   GenerationSpec** _gen_specs;
 
   // The generational collector policy.
@@ -85,9 +82,6 @@
   SubTasksDone* _gen_process_roots_tasks;
   SubTasksDone* gen_process_roots_tasks() { return _gen_process_roots_tasks; }
 
-  void collect_generation(Generation* gen, bool full, size_t size, bool is_tlab,
-                          bool run_verification, bool clear_soft_refs);
-
   // In block contents verification, the number of header words to skip
   NOT_PRODUCT(static size_t _skip_header_HeapWords;)
 
@@ -127,7 +121,6 @@
 
   // Returns JNI_OK on success
   virtual jint initialize();
-
   char* allocate(size_t alignment,
                  size_t* _total_reserved, int* _n_covered_regions,
                  ReservedSpace* heap_rs);
@@ -142,12 +135,8 @@
     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
@@ -317,17 +306,20 @@
   // 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 generations to "now".
+  // Update "time of last gc" for all constituent generations
+  // to "now".
   void update_time_of_last_gc(jlong now) {
-    _young_gen->update_time_of_last_gc(now);
-    _old_gen->update_time_of_last_gc(now);
+    for (int i = 0; i < _n_gens; i++) {
+      _gens[i]->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) {
-    _young_gen->update_gc_stats(current_level, full);
-    _old_gen->update_gc_stats(current_level, full);
+    for (int i = 0; i < _n_gens; i++) {
+      _gens[i]->update_gc_stats(current_level, full);
+    }
   }
 
   // Override.
@@ -372,21 +364,20 @@
   // Return the generation before "gen".
   Generation* prev_gen(Generation* gen) const {
     int l = gen->level();
-    guarantee(l == 1, "Out of bounds");
-    return _young_gen;
+    guarantee(l > 0, "Out of bounds");
+    return _gens[l-1];
   }
 
   // Return the generation after "gen".
   Generation* next_gen(Generation* gen) const {
     int l = gen->level() + 1;
-    guarantee(l == 1, "Out of bounds");
-    return _old_gen;
+    guarantee(l < _n_gens, "Out of bounds");
+    return _gens[l];
   }
 
   Generation* get_gen(int i) const {
     guarantee(i >= 0 && i < _n_gens, "Out of bounds");
-    if (i == 0) return _young_gen;
-    else return _old_gen;
+    return _gens[i];
   }
 
   int n_gens() const {