15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_MEMORY_ITERATOR_INLINE_HPP
26 #define SHARE_MEMORY_ITERATOR_INLINE_HPP
27
28 #include "memory/iterator.hpp"
29
30 #include "classfile/classLoaderData.hpp"
31 #include "code/nmethod.hpp"
32 #include "oops/access.inline.hpp"
33 #include "oops/compressedOops.inline.hpp"
34 #include "oops/klass.hpp"
35 #include "oops/instanceKlass.inline.hpp"
36 #include "oops/instanceMirrorKlass.inline.hpp"
37 #include "oops/instanceClassLoaderKlass.inline.hpp"
38 #include "oops/instanceRefKlass.inline.hpp"
39 #include "oops/instanceStackChunkKlass.inline.hpp"
40 #include "oops/objArrayKlass.inline.hpp"
41 #include "oops/typeArrayKlass.inline.hpp"
42 #include "utilities/debug.hpp"
43
44 // Defaults to strong claiming.
45 inline MetadataVisitingOopIterateClosure::MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd) :
46 ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_strong, rd) {}
47
48 inline void ClaimMetadataVisitingOopIterateClosure::do_cld(ClassLoaderData* cld) {
49 cld->oops_do(this, _claim);
50 }
51
52 inline void ClaimMetadataVisitingOopIterateClosure::do_klass(Klass* k) {
53 ClassLoaderData* cld = k->class_loader_data();
54 ClaimMetadataVisitingOopIterateClosure::do_cld(cld);
126 // when functions pointers are updated.
127 STATIC_ASSERT(sizeof(_function[0]) == sizeof(void*));
128 if (UseCompressedOops) {
129 _function[KlassType::Kind] = &oop_oop_iterate<KlassType, narrowOop>;
130 } else {
131 _function[KlassType::Kind] = &oop_oop_iterate<KlassType, oop>;
132 }
133 }
134
135 template <typename KlassType>
136 void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
137 set_resolve_function<KlassType>();
138 _function[KlassType::Kind](cl, obj, k);
139 }
140
141 public:
142 FunctionType _function[Klass::KLASS_KIND_COUNT];
143
144 Table(){
145 set_init_function<InstanceKlass>();
146 set_init_function<InstanceRefKlass>();
147 set_init_function<InstanceMirrorKlass>();
148 set_init_function<InstanceClassLoaderKlass>();
149 set_init_function<InstanceStackChunkKlass>();
150 set_init_function<ObjArrayKlass>();
151 set_init_function<TypeArrayKlass>();
152 }
153 };
154
155 static Table _table;
156 public:
157
158 static FunctionType function(Klass* klass) {
159 return _table._function[klass->kind()];
160 }
161 };
162
163 template <typename OopClosureType>
164 typename OopOopIterateDispatch<OopClosureType>::Table OopOopIterateDispatch<OopClosureType>::_table;
165
166
167 template <typename OopClosureType>
168 class OopOopIterateBoundedDispatch {
169 private:
170 typedef void (*FunctionType)(OopClosureType*, oop, Klass*, MemRegion);
171
189 template <typename KlassType>
190 void set_resolve_function() {
191 if (UseCompressedOops) {
192 _function[KlassType::Kind] = &oop_oop_iterate_bounded<KlassType, narrowOop>;
193 } else {
194 _function[KlassType::Kind] = &oop_oop_iterate_bounded<KlassType, oop>;
195 }
196 }
197
198 template <typename KlassType>
199 void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k, MemRegion mr) {
200 set_resolve_function<KlassType>();
201 _function[KlassType::Kind](cl, obj, k, mr);
202 }
203
204 public:
205 FunctionType _function[Klass::KLASS_KIND_COUNT];
206
207 Table(){
208 set_init_function<InstanceKlass>();
209 set_init_function<InstanceRefKlass>();
210 set_init_function<InstanceMirrorKlass>();
211 set_init_function<InstanceClassLoaderKlass>();
212 set_init_function<InstanceStackChunkKlass>();
213 set_init_function<ObjArrayKlass>();
214 set_init_function<TypeArrayKlass>();
215 }
216 };
217
218 static Table _table;
219 public:
220
221 static FunctionType function(Klass* klass) {
222 return _table._function[klass->kind()];
223 }
224 };
225
226 template <typename OopClosureType>
227 typename OopOopIterateBoundedDispatch<OopClosureType>::Table OopOopIterateBoundedDispatch<OopClosureType>::_table;
228
229
230 template <typename OopClosureType>
231 class OopOopIterateBackwardsDispatch {
232 private:
233 typedef void (*FunctionType)(OopClosureType*, oop, Klass*);
234
252 template <typename KlassType>
253 void set_resolve_function() {
254 if (UseCompressedOops) {
255 _function[KlassType::Kind] = &oop_oop_iterate_backwards<KlassType, narrowOop>;
256 } else {
257 _function[KlassType::Kind] = &oop_oop_iterate_backwards<KlassType, oop>;
258 }
259 }
260
261 template <typename KlassType>
262 void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
263 set_resolve_function<KlassType>();
264 _function[KlassType::Kind](cl, obj, k);
265 }
266
267 public:
268 FunctionType _function[Klass::KLASS_KIND_COUNT];
269
270 Table(){
271 set_init_function<InstanceKlass>();
272 set_init_function<InstanceRefKlass>();
273 set_init_function<InstanceMirrorKlass>();
274 set_init_function<InstanceClassLoaderKlass>();
275 set_init_function<InstanceStackChunkKlass>();
276 set_init_function<ObjArrayKlass>();
277 set_init_function<TypeArrayKlass>();
278 }
279 };
280
281 static Table _table;
282 public:
283
284 static FunctionType function(Klass* klass) {
285 return _table._function[klass->kind()];
286 }
287 };
288
289 template <typename OopClosureType>
290 typename OopOopIterateBackwardsDispatch<OopClosureType>::Table OopOopIterateBackwardsDispatch<OopClosureType>::_table;
291
292
293 template <typename OopClosureType>
294 void OopIteratorClosureDispatch::oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass) {
295 OopOopIterateDispatch<OopClosureType>::function(klass)(cl, obj, klass);
296 }
297
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_MEMORY_ITERATOR_INLINE_HPP
26 #define SHARE_MEMORY_ITERATOR_INLINE_HPP
27
28 #include "memory/iterator.hpp"
29
30 #include "classfile/classLoaderData.hpp"
31 #include "code/nmethod.hpp"
32 #include "oops/access.inline.hpp"
33 #include "oops/compressedOops.inline.hpp"
34 #include "oops/klass.hpp"
35 #include "oops/flatArrayKlass.inline.hpp"
36 #include "oops/instanceKlass.inline.hpp"
37 #include "oops/instanceMirrorKlass.inline.hpp"
38 #include "oops/instanceClassLoaderKlass.inline.hpp"
39 #include "oops/instanceRefKlass.inline.hpp"
40 #include "oops/instanceStackChunkKlass.inline.hpp"
41 #include "oops/objArrayKlass.inline.hpp"
42 #include "oops/typeArrayKlass.inline.hpp"
43 #include "utilities/debug.hpp"
44
45 // Defaults to strong claiming.
46 inline MetadataVisitingOopIterateClosure::MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd) :
47 ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_strong, rd) {}
48
49 inline void ClaimMetadataVisitingOopIterateClosure::do_cld(ClassLoaderData* cld) {
50 cld->oops_do(this, _claim);
51 }
52
53 inline void ClaimMetadataVisitingOopIterateClosure::do_klass(Klass* k) {
54 ClassLoaderData* cld = k->class_loader_data();
55 ClaimMetadataVisitingOopIterateClosure::do_cld(cld);
127 // when functions pointers are updated.
128 STATIC_ASSERT(sizeof(_function[0]) == sizeof(void*));
129 if (UseCompressedOops) {
130 _function[KlassType::Kind] = &oop_oop_iterate<KlassType, narrowOop>;
131 } else {
132 _function[KlassType::Kind] = &oop_oop_iterate<KlassType, oop>;
133 }
134 }
135
136 template <typename KlassType>
137 void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
138 set_resolve_function<KlassType>();
139 _function[KlassType::Kind](cl, obj, k);
140 }
141
142 public:
143 FunctionType _function[Klass::KLASS_KIND_COUNT];
144
145 Table(){
146 set_init_function<InstanceKlass>();
147 set_init_function<InlineKlass>();
148 set_init_function<InstanceRefKlass>();
149 set_init_function<InstanceMirrorKlass>();
150 set_init_function<InstanceClassLoaderKlass>();
151 set_init_function<InstanceStackChunkKlass>();
152 set_init_function<ObjArrayKlass>();
153 set_init_function<TypeArrayKlass>();
154 set_init_function<FlatArrayKlass>();
155 }
156 };
157
158 static Table _table;
159 public:
160
161 static FunctionType function(Klass* klass) {
162 return _table._function[klass->kind()];
163 }
164 };
165
166 template <typename OopClosureType>
167 typename OopOopIterateDispatch<OopClosureType>::Table OopOopIterateDispatch<OopClosureType>::_table;
168
169
170 template <typename OopClosureType>
171 class OopOopIterateBoundedDispatch {
172 private:
173 typedef void (*FunctionType)(OopClosureType*, oop, Klass*, MemRegion);
174
192 template <typename KlassType>
193 void set_resolve_function() {
194 if (UseCompressedOops) {
195 _function[KlassType::Kind] = &oop_oop_iterate_bounded<KlassType, narrowOop>;
196 } else {
197 _function[KlassType::Kind] = &oop_oop_iterate_bounded<KlassType, oop>;
198 }
199 }
200
201 template <typename KlassType>
202 void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k, MemRegion mr) {
203 set_resolve_function<KlassType>();
204 _function[KlassType::Kind](cl, obj, k, mr);
205 }
206
207 public:
208 FunctionType _function[Klass::KLASS_KIND_COUNT];
209
210 Table(){
211 set_init_function<InstanceKlass>();
212 set_init_function<InlineKlass>();
213 set_init_function<InstanceRefKlass>();
214 set_init_function<InstanceMirrorKlass>();
215 set_init_function<InstanceClassLoaderKlass>();
216 set_init_function<InstanceStackChunkKlass>();
217 set_init_function<ObjArrayKlass>();
218 set_init_function<TypeArrayKlass>();
219 set_init_function<FlatArrayKlass>();
220 }
221 };
222
223 static Table _table;
224 public:
225
226 static FunctionType function(Klass* klass) {
227 return _table._function[klass->kind()];
228 }
229 };
230
231 template <typename OopClosureType>
232 typename OopOopIterateBoundedDispatch<OopClosureType>::Table OopOopIterateBoundedDispatch<OopClosureType>::_table;
233
234
235 template <typename OopClosureType>
236 class OopOopIterateBackwardsDispatch {
237 private:
238 typedef void (*FunctionType)(OopClosureType*, oop, Klass*);
239
257 template <typename KlassType>
258 void set_resolve_function() {
259 if (UseCompressedOops) {
260 _function[KlassType::Kind] = &oop_oop_iterate_backwards<KlassType, narrowOop>;
261 } else {
262 _function[KlassType::Kind] = &oop_oop_iterate_backwards<KlassType, oop>;
263 }
264 }
265
266 template <typename KlassType>
267 void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
268 set_resolve_function<KlassType>();
269 _function[KlassType::Kind](cl, obj, k);
270 }
271
272 public:
273 FunctionType _function[Klass::KLASS_KIND_COUNT];
274
275 Table(){
276 set_init_function<InstanceKlass>();
277 set_init_function<InlineKlass>();
278 set_init_function<InstanceRefKlass>();
279 set_init_function<InstanceMirrorKlass>();
280 set_init_function<InstanceClassLoaderKlass>();
281 set_init_function<InstanceStackChunkKlass>();
282 set_init_function<ObjArrayKlass>();
283 set_init_function<TypeArrayKlass>();
284 set_init_function<FlatArrayKlass>();
285 }
286 };
287
288 static Table _table;
289 public:
290
291 static FunctionType function(Klass* klass) {
292 return _table._function[klass->kind()];
293 }
294 };
295
296 template <typename OopClosureType>
297 typename OopOopIterateBackwardsDispatch<OopClosureType>::Table OopOopIterateBackwardsDispatch<OopClosureType>::_table;
298
299
300 template <typename OopClosureType>
301 void OopIteratorClosureDispatch::oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass) {
302 OopOopIterateDispatch<OopClosureType>::function(klass)(cl, obj, klass);
303 }
304
|