1.1 --- a/src/share/vm/memory/genOopClosures.hpp Fri Apr 11 09:56:35 2008 -0400 1.2 +++ b/src/share/vm/memory/genOopClosures.hpp Sun Apr 13 17:43:42 2008 -0400 1.3 @@ -28,6 +28,11 @@ 1.4 class CardTableModRefBS; 1.5 class DefNewGeneration; 1.6 1.7 +template<class E> class GenericTaskQueue; 1.8 +typedef GenericTaskQueue<oop> OopTaskQueue; 1.9 +template<class E> class GenericTaskQueueSet; 1.10 +typedef GenericTaskQueueSet<oop> OopTaskQueueSet; 1.11 + 1.12 // Closure for iterating roots from a particular generation 1.13 // Note: all classes deriving from this MUST call this do_barrier 1.14 // method at the end of their own do_oop method! 1.15 @@ -35,13 +40,13 @@ 1.16 1.17 class OopsInGenClosure : public OopClosure { 1.18 private: 1.19 - Generation* _orig_gen; // generation originally set in ctor 1.20 - Generation* _gen; // generation being scanned 1.21 + Generation* _orig_gen; // generation originally set in ctor 1.22 + Generation* _gen; // generation being scanned 1.23 1.24 protected: 1.25 // Some subtypes need access. 1.26 - HeapWord* _gen_boundary; // start of generation 1.27 - CardTableRS* _rs; // remembered set 1.28 + HeapWord* _gen_boundary; // start of generation 1.29 + CardTableRS* _rs; // remembered set 1.30 1.31 // For assertions 1.32 Generation* generation() { return _gen; } 1.33 @@ -49,7 +54,7 @@ 1.34 1.35 // Derived classes that modify oops so that they might be old-to-young 1.36 // pointers must call the method below. 1.37 - void do_barrier(oop* p); 1.38 + template <class T> void do_barrier(T* p); 1.39 1.40 public: 1.41 OopsInGenClosure() : OopClosure(NULL), 1.42 @@ -75,14 +80,17 @@ 1.43 // This closure will perform barrier store calls for ALL 1.44 // pointers in scanned oops. 1.45 class ScanClosure: public OopsInGenClosure { 1.46 -protected: 1.47 + protected: 1.48 DefNewGeneration* _g; 1.49 - HeapWord* _boundary; 1.50 - bool _gc_barrier; 1.51 -public: 1.52 + HeapWord* _boundary; 1.53 + bool _gc_barrier; 1.54 + template <class T> inline void do_oop_work(T* p); 1.55 + public: 1.56 ScanClosure(DefNewGeneration* g, bool gc_barrier); 1.57 - void do_oop(oop* p); 1.58 - void do_oop_nv(oop* p); 1.59 + virtual void do_oop(oop* p); 1.60 + virtual void do_oop(narrowOop* p); 1.61 + inline void do_oop_nv(oop* p); 1.62 + inline void do_oop_nv(narrowOop* p); 1.63 bool do_header() { return false; } 1.64 Prefetch::style prefetch_style() { 1.65 return Prefetch::do_write; 1.66 @@ -95,14 +103,17 @@ 1.67 // pointers into the DefNewGeneration. This is less 1.68 // precise, but faster, than a ScanClosure 1.69 class FastScanClosure: public OopsInGenClosure { 1.70 -protected: 1.71 + protected: 1.72 DefNewGeneration* _g; 1.73 - HeapWord* _boundary; 1.74 - bool _gc_barrier; 1.75 -public: 1.76 + HeapWord* _boundary; 1.77 + bool _gc_barrier; 1.78 + template <class T> inline void do_oop_work(T* p); 1.79 + public: 1.80 FastScanClosure(DefNewGeneration* g, bool gc_barrier); 1.81 - void do_oop(oop* p); 1.82 - void do_oop_nv(oop* p); 1.83 + virtual void do_oop(oop* p); 1.84 + virtual void do_oop(narrowOop* p); 1.85 + inline void do_oop_nv(oop* p); 1.86 + inline void do_oop_nv(narrowOop* p); 1.87 bool do_header() { return false; } 1.88 Prefetch::style prefetch_style() { 1.89 return Prefetch::do_write; 1.90 @@ -110,19 +121,27 @@ 1.91 }; 1.92 1.93 class FilteringClosure: public OopClosure { 1.94 - HeapWord* _boundary; 1.95 + private: 1.96 + HeapWord* _boundary; 1.97 OopClosure* _cl; 1.98 -public: 1.99 + protected: 1.100 + template <class T> inline void do_oop_work(T* p) { 1.101 + T heap_oop = oopDesc::load_heap_oop(p); 1.102 + if (!oopDesc::is_null(heap_oop)) { 1.103 + oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 1.104 + if ((HeapWord*)obj < _boundary) { 1.105 + _cl->do_oop(p); 1.106 + } 1.107 + } 1.108 + } 1.109 + public: 1.110 FilteringClosure(HeapWord* boundary, OopClosure* cl) : 1.111 OopClosure(cl->_ref_processor), _boundary(boundary), 1.112 _cl(cl) {} 1.113 - void do_oop(oop* p); 1.114 - void do_oop_nv(oop* p) { 1.115 - oop obj = *p; 1.116 - if ((HeapWord*)obj < _boundary && obj != NULL) { 1.117 - _cl->do_oop(p); 1.118 - } 1.119 - } 1.120 + virtual void do_oop(oop* p); 1.121 + virtual void do_oop(narrowOop* p); 1.122 + inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); } 1.123 + inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); } 1.124 bool do_header() { return false; } 1.125 }; 1.126 1.127 @@ -131,19 +150,26 @@ 1.128 // OopsInGenClosure -- weak references are processed all 1.129 // at once, with no notion of which generation they were in. 1.130 class ScanWeakRefClosure: public OopClosure { 1.131 -protected: 1.132 - DefNewGeneration* _g; 1.133 - HeapWord* _boundary; 1.134 -public: 1.135 + protected: 1.136 + DefNewGeneration* _g; 1.137 + HeapWord* _boundary; 1.138 + template <class T> inline void do_oop_work(T* p); 1.139 + public: 1.140 ScanWeakRefClosure(DefNewGeneration* g); 1.141 - void do_oop(oop* p); 1.142 - void do_oop_nv(oop* p); 1.143 + virtual void do_oop(oop* p); 1.144 + virtual void do_oop(narrowOop* p); 1.145 + inline void do_oop_nv(oop* p); 1.146 + inline void do_oop_nv(narrowOop* p); 1.147 }; 1.148 1.149 class VerifyOopClosure: public OopClosure { 1.150 -public: 1.151 - void do_oop(oop* p) { 1.152 - guarantee((*p)->is_oop_or_null(), "invalid oop"); 1.153 + protected: 1.154 + template <class T> inline void do_oop_work(T* p) { 1.155 + oop obj = oopDesc::load_decode_heap_oop(p); 1.156 + guarantee(obj->is_oop_or_null(), "invalid oop"); 1.157 } 1.158 + public: 1.159 + virtual void do_oop(oop* p); 1.160 + virtual void do_oop(narrowOop* p); 1.161 static VerifyOopClosure verify_oop; 1.162 };