diff src/share/vm/memory/genOopClosures.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children 78bbf4d43a14
line wrap: on
line diff
--- a/src/share/vm/memory/genOopClosures.hpp	Fri Aug 31 16:39:35 2012 -0700
+++ b/src/share/vm/memory/genOopClosures.hpp	Sat Sep 01 13:25:18 2012 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 class CardTableRS;
 class CardTableModRefBS;
 class DefNewGeneration;
+class KlassRemSet;
 
 template<class E, MEMFLAGS F, unsigned int N> class GenericTaskQueue;
 typedef GenericTaskQueue<oop, mtGC, TASKQUEUE_SIZE> OopTaskQueue;
@@ -44,7 +45,7 @@
 // method at the end of their own do_oop method!
 // Note: no do_oop defined, this is an abstract class.
 
-class OopsInGenClosure : public OopClosure {
+class OopsInGenClosure : public ExtendedOopClosure {
  private:
   Generation*  _orig_gen;     // generation originally set in ctor
   Generation*  _gen;          // generation being scanned
@@ -66,7 +67,7 @@
   template <class T> void par_do_barrier(T* p);
 
  public:
-  OopsInGenClosure() : OopClosure(NULL),
+  OopsInGenClosure() : ExtendedOopClosure(NULL),
     _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
 
   OopsInGenClosure(Generation* gen);
@@ -82,13 +83,27 @@
   }
 
   HeapWord* gen_boundary() { return _gen_boundary; }
+
+};
+
+// Super class for scan closures. It contains code to dirty scanned Klasses.
+class OopsInKlassOrGenClosure: public OopsInGenClosure {
+  Klass* _scanned_klass;
+ public:
+  OopsInKlassOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_klass(NULL) {}
+  void set_scanned_klass(Klass* k) {
+    assert(k == NULL || _scanned_klass == NULL, "Must be");
+    _scanned_klass = k;
+  }
+  bool is_scanning_a_klass() { return _scanned_klass != NULL; }
+  void do_klass_barrier();
 };
 
 // Closure for scanning DefNewGeneration.
 //
 // This closure will perform barrier store calls for ALL
 // pointers in scanned oops.
-class ScanClosure: public OopsInGenClosure {
+class ScanClosure: public OopsInKlassOrGenClosure {
  protected:
   DefNewGeneration* _g;
   HeapWord*         _boundary;
@@ -100,7 +115,6 @@
   virtual void do_oop(narrowOop* p);
   inline void do_oop_nv(oop* p);
   inline void do_oop_nv(narrowOop* p);
-  bool do_header() { return false; }
   Prefetch::style prefetch_style() {
     return Prefetch::do_write;
   }
@@ -111,7 +125,7 @@
 // This closure only performs barrier store calls on
 // pointers into the DefNewGeneration. This is less
 // precise, but faster, than a ScanClosure
-class FastScanClosure: public OopsInGenClosure {
+class FastScanClosure: public OopsInKlassOrGenClosure {
  protected:
   DefNewGeneration* _g;
   HeapWord*         _boundary;
@@ -123,16 +137,25 @@
   virtual void do_oop(narrowOop* p);
   inline void do_oop_nv(oop* p);
   inline void do_oop_nv(narrowOop* p);
-  bool do_header() { return false; }
   Prefetch::style prefetch_style() {
     return Prefetch::do_write;
   }
 };
 
-class FilteringClosure: public OopClosure {
+class KlassScanClosure: public KlassClosure {
+  OopsInKlassOrGenClosure* _scavenge_closure;
+  // true if the the modified oops state should be saved.
+  bool                     _accumulate_modified_oops;
+ public:
+  KlassScanClosure(OopsInKlassOrGenClosure* scavenge_closure,
+                   KlassRemSet* klass_rem_set_policy);
+  void do_klass(Klass* k);
+};
+
+class FilteringClosure: public ExtendedOopClosure {
  private:
   HeapWord*   _boundary;
-  OopClosure* _cl;
+  ExtendedOopClosure* _cl;
  protected:
   template <class T> inline void do_oop_work(T* p) {
     T heap_oop = oopDesc::load_heap_oop(p);
@@ -144,14 +167,15 @@
     }
   }
  public:
-  FilteringClosure(HeapWord* boundary, OopClosure* cl) :
-    OopClosure(cl->_ref_processor), _boundary(boundary),
+  FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) :
+    ExtendedOopClosure(cl->_ref_processor), _boundary(boundary),
     _cl(cl) {}
   virtual void do_oop(oop* p);
   virtual void do_oop(narrowOop* p);
   inline void do_oop_nv(oop* p)       { FilteringClosure::do_oop_work(p); }
   inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
-  bool do_header() { return false; }
+  virtual bool do_metadata()          { return do_metadata_nv(); }
+  inline bool do_metadata_nv()        { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
 };
 
 // Closure for scanning DefNewGeneration's weak references.