src/share/vm/gc_implementation/g1/g1OopClosures.hpp

Print this page
rev 6336 : 8040977: G1 crashes when run with -XX:-G1DeferredRSUpdate
Summary: When G1 is run with -XX:-G1DeferredRSUpdate, the VM crashes because of wrong initialization order of member variables. The change makes the initalization explicit, not relying on initialization order any more.
Reviewed-by: brutisso, mgerdin


  34 class CMMarkStack;
  35 class G1ParScanThreadState;
  36 class CMTask;
  37 class ReferenceProcessor;
  38 
  39 // A class that scans oops in a given heap region (much as OopsInGenClosure
  40 // scans oops in a generation.)
  41 class OopsInHeapRegionClosure: public ExtendedOopClosure {
  42 protected:
  43   HeapRegion* _from;
  44 public:
  45   void set_region(HeapRegion* from) { _from = from; }
  46 };
  47 
  48 class G1ParClosureSuper : public OopsInHeapRegionClosure {
  49 protected:
  50   G1CollectedHeap* _g1;
  51   G1ParScanThreadState* _par_scan_state;
  52   uint _worker_id;
  53 public:



  54   G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
  55   bool apply_to_weak_ref_discovered_field() { return true; }


  56 };
  57 
  58 class G1ParPushHeapRSClosure : public G1ParClosureSuper {
  59 public:
  60   G1ParPushHeapRSClosure(G1CollectedHeap* g1,
  61                          G1ParScanThreadState* par_scan_state):
  62     G1ParClosureSuper(g1, par_scan_state) { }
  63 
  64   template <class T> void do_oop_nv(T* p);
  65   virtual void do_oop(oop* p)          { do_oop_nv(p); }
  66   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
  67 };
  68 
  69 class G1ParScanClosure : public G1ParClosureSuper {
  70 public:
  71   G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
  72     G1ParClosureSuper(g1, par_scan_state)
  73   {
  74     assert(_ref_processor == NULL, "sanity");
  75     _ref_processor = rp;
  76   }
  77 
  78   template <class T> void do_oop_nv(T* p);
  79   virtual void do_oop(oop* p)          { do_oop_nv(p); }
  80   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
  81 };
  82 
  83 // Add back base class for metadata
  84 class G1ParCopyHelper : public G1ParClosureSuper {
  85 protected:
  86   Klass* _scanned_klass;
  87   ConcurrentMark* _cm;
  88 
  89   // Mark the object if it's not already marked. This is used to mark
  90   // objects pointed to by roots that are guaranteed not to move
  91   // during the GC (i.e., non-CSet objects). It is MT-safe.
  92   void mark_object(oop obj);
  93 




  34 class CMMarkStack;
  35 class G1ParScanThreadState;
  36 class CMTask;
  37 class ReferenceProcessor;
  38 
  39 // A class that scans oops in a given heap region (much as OopsInGenClosure
  40 // scans oops in a generation.)
  41 class OopsInHeapRegionClosure: public ExtendedOopClosure {
  42 protected:
  43   HeapRegion* _from;
  44 public:
  45   void set_region(HeapRegion* from) { _from = from; }
  46 };
  47 
  48 class G1ParClosureSuper : public OopsInHeapRegionClosure {
  49 protected:
  50   G1CollectedHeap* _g1;
  51   G1ParScanThreadState* _par_scan_state;
  52   uint _worker_id;
  53 public:
  54   // Initializes the instance, leaving _par_scan_state uninitialized. Must be done
  55   // later using the set_par_scan_thread_state() method.
  56   G1ParClosureSuper(G1CollectedHeap* g1);
  57   G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state);
  58   bool apply_to_weak_ref_discovered_field() { return true; }
  59 
  60   void set_par_scan_thread_state(G1ParScanThreadState* par_scan_state);
  61 };
  62 
  63 class G1ParPushHeapRSClosure : public G1ParClosureSuper {
  64 public:
  65   G1ParPushHeapRSClosure(G1CollectedHeap* g1,
  66                          G1ParScanThreadState* par_scan_state):
  67     G1ParClosureSuper(g1, par_scan_state) { }
  68 
  69   template <class T> void do_oop_nv(T* p);
  70   virtual void do_oop(oop* p)          { do_oop_nv(p); }
  71   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
  72 };
  73 
  74 class G1ParScanClosure : public G1ParClosureSuper {
  75 public:
  76   G1ParScanClosure(G1CollectedHeap* g1, ReferenceProcessor* rp) :
  77     G1ParClosureSuper(g1) {

  78     assert(_ref_processor == NULL, "sanity");
  79     _ref_processor = rp;
  80   }
  81 
  82   template <class T> void do_oop_nv(T* p);
  83   virtual void do_oop(oop* p)          { do_oop_nv(p); }
  84   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
  85 };
  86 
  87 // Add back base class for metadata
  88 class G1ParCopyHelper : public G1ParClosureSuper {
  89 protected:
  90   Klass* _scanned_klass;
  91   ConcurrentMark* _cm;
  92 
  93   // Mark the object if it's not already marked. This is used to mark
  94   // objects pointed to by roots that are guaranteed not to move
  95   // during the GC (i.e., non-CSet objects). It is MT-safe.
  96   void mark_object(oop obj);
  97