src/share/vm/memory/referenceProcessor.hpp

Print this page
rev 2518 : [mq]: g1-reference-processing

@@ -46,41 +46,80 @@
 // (with appropriate modifications) to any "non-convex interval".
 
 // forward references
 class ReferencePolicy;
 class AbstractRefProcTaskExecutor;
-class DiscoveredList;
+
+// List of discovered references.
+class DiscoveredList {
+ public:
+  DiscoveredList() : _len(0), _compressed_head(0), _oop_head(NULL) { }
+  oop head() const     {
+     return UseCompressedOops ?  oopDesc::decode_heap_oop_not_null(_compressed_head) :
+                                _oop_head;
+  }
+  HeapWord* adr_head() {
+    return UseCompressedOops ? (HeapWord*)&_compressed_head :
+                               (HeapWord*)&_oop_head;
+  }
+  void   set_head(oop o) {
+    if (UseCompressedOops) {
+      // Must compress the head ptr.
+      _compressed_head = oopDesc::encode_heap_oop_not_null(o);
+    } else {
+      _oop_head = o;
+    }
+  }
+
+  bool empty() const; 
+
+  size_t length()               { return _len; }
+  void   set_length(size_t len) { _len = len;  }
+  void   inc_length(size_t inc) { _len += inc; assert(_len > 0, "Error"); }
+  void   dec_length(size_t dec) { _len -= dec; }
+
+ private:
+  // Set value depending on UseCompressedOops. This could be a template class
+  // but then we have to fix all the instantiations and declarations that use this class.
+  oop       _oop_head;
+  narrowOop _compressed_head;
+  size_t _len;
+};
 
 class ReferenceProcessor : public CHeapObj {
  protected:
   // End of list marker
   static oop  _sentinelRef;
+
   MemRegion   _span; // (right-open) interval of heap
                      // subject to wkref discovery
+
   bool        _discovering_refs;      // true when discovery enabled
   bool        _discovery_is_atomic;   // if discovery is atomic wrt
                                       // other collectors in configuration
   bool        _discovery_is_mt;       // true if reference discovery is MT.
+
   // If true, setting "next" field of a discovered refs list requires
   // write barrier(s).  (Must be true if used in a collector in which
   // elements of a discovered list may be moved during discovery: for
   // example, a collector like Garbage-First that moves objects during a
   // long-term concurrent marking phase that does weak reference
   // discovery.)
   bool        _discovered_list_needs_barrier;
+
   BarrierSet* _bs;                    // Cached copy of BarrierSet.
   bool        _enqueuing_is_done;     // true if all weak references enqueued
   bool        _processing_is_mt;      // true during phases when
                                       // reference processing is MT.
   int         _next_id;               // round-robin mod _num_q counter in
                                       // support of work distribution
 
-  // For collectors that do not keep GC marking information
+  // For collectors that do not keep GC liveness information
   // in the object header, this field holds a closure that
   // helps the reference processor determine the reachability
   // of an oop (the field is currently initialized to NULL for
-  // all collectors but the CMS collector).
+  // all collectors but the CMS G1 collectors).
   BoolObjectClosure* _is_alive_non_header;
 
   // Soft ref clearing policies
   // . the default policy
   static ReferencePolicy*   _default_soft_ref_policy;

@@ -100,10 +139,12 @@
   DiscoveredList* _discoveredWeakRefs;
   DiscoveredList* _discoveredFinalRefs;
   DiscoveredList* _discoveredPhantomRefs;
 
  public:
+  static int subclasses_of_ref()         { return (REF_PHANTOM - REF_OTHER); }
+
   int num_q()                            { return _num_q; }
   int max_num_q()                        { return _max_num_q; }
   void set_active_mt_degree(int v)       { _num_q = v; }
   DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
   static oop  sentinel_ref()             { return _sentinelRef; }