comparison 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
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
31 class Generation; 31 class Generation;
32 class HeapWord; 32 class HeapWord;
33 class CardTableRS; 33 class CardTableRS;
34 class CardTableModRefBS; 34 class CardTableModRefBS;
35 class DefNewGeneration; 35 class DefNewGeneration;
36 class KlassRemSet;
36 37
37 template<class E, MEMFLAGS F, unsigned int N> class GenericTaskQueue; 38 template<class E, MEMFLAGS F, unsigned int N> class GenericTaskQueue;
38 typedef GenericTaskQueue<oop, mtGC, TASKQUEUE_SIZE> OopTaskQueue; 39 typedef GenericTaskQueue<oop, mtGC, TASKQUEUE_SIZE> OopTaskQueue;
39 template<class T, MEMFLAGS F> class GenericTaskQueueSet; 40 template<class T, MEMFLAGS F> class GenericTaskQueueSet;
40 typedef GenericTaskQueueSet<OopTaskQueue, mtGC> OopTaskQueueSet; 41 typedef GenericTaskQueueSet<OopTaskQueue, mtGC> OopTaskQueueSet;
42 // Closure for iterating roots from a particular generation 43 // Closure for iterating roots from a particular generation
43 // Note: all classes deriving from this MUST call this do_barrier 44 // Note: all classes deriving from this MUST call this do_barrier
44 // method at the end of their own do_oop method! 45 // method at the end of their own do_oop method!
45 // Note: no do_oop defined, this is an abstract class. 46 // Note: no do_oop defined, this is an abstract class.
46 47
47 class OopsInGenClosure : public OopClosure { 48 class OopsInGenClosure : public ExtendedOopClosure {
48 private: 49 private:
49 Generation* _orig_gen; // generation originally set in ctor 50 Generation* _orig_gen; // generation originally set in ctor
50 Generation* _gen; // generation being scanned 51 Generation* _gen; // generation being scanned
51 52
52 protected: 53 protected:
64 65
65 // Version for use by closures that may be called in parallel code. 66 // Version for use by closures that may be called in parallel code.
66 template <class T> void par_do_barrier(T* p); 67 template <class T> void par_do_barrier(T* p);
67 68
68 public: 69 public:
69 OopsInGenClosure() : OopClosure(NULL), 70 OopsInGenClosure() : ExtendedOopClosure(NULL),
70 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {}; 71 _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
71 72
72 OopsInGenClosure(Generation* gen); 73 OopsInGenClosure(Generation* gen);
73 void set_generation(Generation* gen); 74 void set_generation(Generation* gen);
74 75
80 _orig_gen = gen; 81 _orig_gen = gen;
81 set_generation(gen); 82 set_generation(gen);
82 } 83 }
83 84
84 HeapWord* gen_boundary() { return _gen_boundary; } 85 HeapWord* gen_boundary() { return _gen_boundary; }
86
87 };
88
89 // Super class for scan closures. It contains code to dirty scanned Klasses.
90 class OopsInKlassOrGenClosure: public OopsInGenClosure {
91 Klass* _scanned_klass;
92 public:
93 OopsInKlassOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_klass(NULL) {}
94 void set_scanned_klass(Klass* k) {
95 assert(k == NULL || _scanned_klass == NULL, "Must be");
96 _scanned_klass = k;
97 }
98 bool is_scanning_a_klass() { return _scanned_klass != NULL; }
99 void do_klass_barrier();
85 }; 100 };
86 101
87 // Closure for scanning DefNewGeneration. 102 // Closure for scanning DefNewGeneration.
88 // 103 //
89 // This closure will perform barrier store calls for ALL 104 // This closure will perform barrier store calls for ALL
90 // pointers in scanned oops. 105 // pointers in scanned oops.
91 class ScanClosure: public OopsInGenClosure { 106 class ScanClosure: public OopsInKlassOrGenClosure {
92 protected: 107 protected:
93 DefNewGeneration* _g; 108 DefNewGeneration* _g;
94 HeapWord* _boundary; 109 HeapWord* _boundary;
95 bool _gc_barrier; 110 bool _gc_barrier;
96 template <class T> inline void do_oop_work(T* p); 111 template <class T> inline void do_oop_work(T* p);
98 ScanClosure(DefNewGeneration* g, bool gc_barrier); 113 ScanClosure(DefNewGeneration* g, bool gc_barrier);
99 virtual void do_oop(oop* p); 114 virtual void do_oop(oop* p);
100 virtual void do_oop(narrowOop* p); 115 virtual void do_oop(narrowOop* p);
101 inline void do_oop_nv(oop* p); 116 inline void do_oop_nv(oop* p);
102 inline void do_oop_nv(narrowOop* p); 117 inline void do_oop_nv(narrowOop* p);
103 bool do_header() { return false; }
104 Prefetch::style prefetch_style() { 118 Prefetch::style prefetch_style() {
105 return Prefetch::do_write; 119 return Prefetch::do_write;
106 } 120 }
107 }; 121 };
108 122
109 // Closure for scanning DefNewGeneration. 123 // Closure for scanning DefNewGeneration.
110 // 124 //
111 // This closure only performs barrier store calls on 125 // This closure only performs barrier store calls on
112 // pointers into the DefNewGeneration. This is less 126 // pointers into the DefNewGeneration. This is less
113 // precise, but faster, than a ScanClosure 127 // precise, but faster, than a ScanClosure
114 class FastScanClosure: public OopsInGenClosure { 128 class FastScanClosure: public OopsInKlassOrGenClosure {
115 protected: 129 protected:
116 DefNewGeneration* _g; 130 DefNewGeneration* _g;
117 HeapWord* _boundary; 131 HeapWord* _boundary;
118 bool _gc_barrier; 132 bool _gc_barrier;
119 template <class T> inline void do_oop_work(T* p); 133 template <class T> inline void do_oop_work(T* p);
121 FastScanClosure(DefNewGeneration* g, bool gc_barrier); 135 FastScanClosure(DefNewGeneration* g, bool gc_barrier);
122 virtual void do_oop(oop* p); 136 virtual void do_oop(oop* p);
123 virtual void do_oop(narrowOop* p); 137 virtual void do_oop(narrowOop* p);
124 inline void do_oop_nv(oop* p); 138 inline void do_oop_nv(oop* p);
125 inline void do_oop_nv(narrowOop* p); 139 inline void do_oop_nv(narrowOop* p);
126 bool do_header() { return false; }
127 Prefetch::style prefetch_style() { 140 Prefetch::style prefetch_style() {
128 return Prefetch::do_write; 141 return Prefetch::do_write;
129 } 142 }
130 }; 143 };
131 144
132 class FilteringClosure: public OopClosure { 145 class KlassScanClosure: public KlassClosure {
146 OopsInKlassOrGenClosure* _scavenge_closure;
147 // true if the the modified oops state should be saved.
148 bool _accumulate_modified_oops;
149 public:
150 KlassScanClosure(OopsInKlassOrGenClosure* scavenge_closure,
151 KlassRemSet* klass_rem_set_policy);
152 void do_klass(Klass* k);
153 };
154
155 class FilteringClosure: public ExtendedOopClosure {
133 private: 156 private:
134 HeapWord* _boundary; 157 HeapWord* _boundary;
135 OopClosure* _cl; 158 ExtendedOopClosure* _cl;
136 protected: 159 protected:
137 template <class T> inline void do_oop_work(T* p) { 160 template <class T> inline void do_oop_work(T* p) {
138 T heap_oop = oopDesc::load_heap_oop(p); 161 T heap_oop = oopDesc::load_heap_oop(p);
139 if (!oopDesc::is_null(heap_oop)) { 162 if (!oopDesc::is_null(heap_oop)) {
140 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); 163 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
142 _cl->do_oop(p); 165 _cl->do_oop(p);
143 } 166 }
144 } 167 }
145 } 168 }
146 public: 169 public:
147 FilteringClosure(HeapWord* boundary, OopClosure* cl) : 170 FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) :
148 OopClosure(cl->_ref_processor), _boundary(boundary), 171 ExtendedOopClosure(cl->_ref_processor), _boundary(boundary),
149 _cl(cl) {} 172 _cl(cl) {}
150 virtual void do_oop(oop* p); 173 virtual void do_oop(oop* p);
151 virtual void do_oop(narrowOop* p); 174 virtual void do_oop(narrowOop* p);
152 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); } 175 inline void do_oop_nv(oop* p) { FilteringClosure::do_oop_work(p); }
153 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); } 176 inline void do_oop_nv(narrowOop* p) { FilteringClosure::do_oop_work(p); }
154 bool do_header() { return false; } 177 virtual bool do_metadata() { return do_metadata_nv(); }
178 inline bool do_metadata_nv() { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
155 }; 179 };
156 180
157 // Closure for scanning DefNewGeneration's weak references. 181 // Closure for scanning DefNewGeneration's weak references.
158 // NOTE: very much like ScanClosure but not derived from 182 // NOTE: very much like ScanClosure but not derived from
159 // OopsInGenClosure -- weak references are processed all 183 // OopsInGenClosure -- weak references are processed all