src/share/vm/memory/generation.hpp

Print this page
rev 6796 : [mq]: templateOopIterate

@@ -112,16 +112,23 @@
   CollectorCounters* _gc_counters;
 
   // Statistics for garbage collection
   GCStats* _gc_stats;
 
+  enum {
+    _dispatch_index_generation_cms,
+    _dispatch_index_generation_def_new,
+    _dispatch_index_generation_one_contig
+  };
+  const jbyte _dispatch_index;
+
   // Returns the next generation in the configuration, or else NULL if this
   // is the highest generation.
   Generation* next_gen() const;
 
   // Initialize the generation.
-  Generation(ReservedSpace rs, size_t initial_byte_size, int level);
+  Generation(ReservedSpace rs, size_t initial_byte_size, int level, jbyte dispatch_index);
 
   // Apply "cl->do_oop" to (the address of) (exactly) all the ref fields in
   // "sp" that point into younger generations.
   // The iteration is only over objects allocated at the start of the
   // iterations; objects allocated as a result of applying the closure are

@@ -477,28 +484,19 @@
 
   // This function is "true" iff any no allocations have occurred in the
   // generation since the last call to "save_marks".
   virtual bool no_allocs_since_save_marks() = 0;
 
-  // Apply "cl->apply" to (the addresses of) all reference fields in objects
-  // allocated in the current generation since the last call to "save_marks".
-  // If more objects are allocated in this generation as a result of applying
-  // the closure, iterates over reference fields in those objects as well.
-  // Calls "save_marks" at the end of the iteration.
-  // General signature...
-  virtual void oop_since_save_marks_iterate_v(OopsInGenClosure* cl) = 0;
   // ...and specializations for de-virtualization.  (The general
   // implementation of the _nv versions call the virtual version.
   // Note that the _nv suffix is not really semantically necessary,
   // but it avoids some not-so-useful warnings on Solaris.)
-#define Generation_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix)             \
-  virtual void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl) {    \
-    oop_since_save_marks_iterate_v((OopsInGenClosure*)cl);                      \
-  }
-  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(Generation_SINCE_SAVE_MARKS_DECL)
+  template <typename OopClosureType>
+  void oop_since_save_marks_iterate(OopClosureType* cl);
 
-#undef Generation_SINCE_SAVE_MARKS_DECL
+  template <bool nv, typename OopClosureType>
+  void oop_since_save_marks_iterate_disp(OopClosureType* cl);
 
   // The "requestor" generation is performing some garbage collection
   // action for which it would be useful to have scratch space.  If
   // the target is not the requestor, no gc actions will be required
   // of the target.  The requestor promises to allocate no more than

@@ -637,11 +635,11 @@
   // to control growing/shrinking policy in spite of promotions.
   size_t _capacity_at_prologue;
   size_t _used_at_prologue;
 
   CardGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
-                 GenRemSet* remset);
+                 GenRemSet* remset, jbyte dispatch_index);
 
  public:
 
   // Attempt to expand the generation by "bytes".  Expand by at a
   // minimum "expand_bytes".  Return true if some amount (not

@@ -696,11 +694,11 @@
 
  public:
   OneContigSpaceCardGeneration(ReservedSpace rs, size_t initial_byte_size,
                                int level, GenRemSet* remset,
                                ContiguousSpace* space) :
-    CardGeneration(rs, initial_byte_size, level, remset),
+    CardGeneration(rs, initial_byte_size, level, remset, _dispatch_index_generation_one_contig),
     _the_space(space)
   {}
 
   inline bool is_in(const void* p) const;
 

@@ -727,14 +725,12 @@
 
   // Accessing marks
   inline WaterMark top_mark();
   inline WaterMark bottom_mark();
 
-#define OneContig_SINCE_SAVE_MARKS_DECL(OopClosureType, nv_suffix)      \
-  void oop_since_save_marks_iterate##nv_suffix(OopClosureType* cl);
-  OneContig_SINCE_SAVE_MARKS_DECL(OopsInGenClosure,_v)
-  SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(OneContig_SINCE_SAVE_MARKS_DECL)
+  template <bool nv, typename OopClosureType>
+  void oop_since_save_marks_iterate(OopClosureType* cl);
 
   void save_marks();
   void reset_saved_marks();
   bool no_allocs_since_save_marks();