< prev index next >

src/hotspot/share/memory/iterator.inline.hpp

Print this page

  1 /*
  2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  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
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 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 "oops/access.inline.hpp"
 32 #include "oops/compressedOops.inline.hpp"
 33 #include "oops/klass.hpp"

 34 #include "oops/instanceKlass.inline.hpp"
 35 #include "oops/instanceMirrorKlass.inline.hpp"
 36 #include "oops/instanceClassLoaderKlass.inline.hpp"
 37 #include "oops/instanceRefKlass.inline.hpp"
 38 #include "oops/objArrayKlass.inline.hpp"
 39 #include "oops/typeArrayKlass.inline.hpp"
 40 #include "utilities/debug.hpp"
 41 
 42 // Defaults to strong claiming.
 43 inline MetadataVisitingOopIterateClosure::MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd) :
 44     ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_strong, rd) {}
 45 
 46 inline void ClaimMetadataVisitingOopIterateClosure::do_cld(ClassLoaderData* cld) {
 47   cld->oops_do(this, _claim);
 48 }
 49 
 50 inline void ClaimMetadataVisitingOopIterateClosure::do_klass(Klass* k) {
 51   ClassLoaderData* cld = k->class_loader_data();
 52   ClaimMetadataVisitingOopIterateClosure::do_cld(cld);
 53 }

237         _function[KlassType::ID] = &oop_oop_iterate<KlassType, oop>;
238       }
239     }
240 
241     template <typename KlassType>
242     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
243       set_resolve_function<KlassType>();
244       _function[KlassType::ID](cl, obj, k);
245     }
246 
247   public:
248     FunctionType _function[KLASS_ID_COUNT];
249 
250     Table(){
251       set_init_function<InstanceKlass>();
252       set_init_function<InstanceRefKlass>();
253       set_init_function<InstanceMirrorKlass>();
254       set_init_function<InstanceClassLoaderKlass>();
255       set_init_function<ObjArrayKlass>();
256       set_init_function<TypeArrayKlass>();

257     }
258   };
259 
260   static Table _table;
261 public:
262 
263   static FunctionType function(Klass* klass) {
264     return _table._function[klass->id()];
265   }
266 };
267 
268 template <typename OopClosureType>
269 typename OopOopIterateDispatch<OopClosureType>::Table OopOopIterateDispatch<OopClosureType>::_table;
270 
271 
272 template <typename OopClosureType>
273 class OopOopIterateBoundedDispatch {
274 private:
275   typedef void (*FunctionType)(OopClosureType*, oop, Klass*, MemRegion);
276 

299         _function[KlassType::ID] = &oop_oop_iterate_bounded<KlassType, oop>;
300       }
301     }
302 
303     template <typename KlassType>
304     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k, MemRegion mr) {
305       set_resolve_function<KlassType>();
306       _function[KlassType::ID](cl, obj, k, mr);
307     }
308 
309   public:
310     FunctionType _function[KLASS_ID_COUNT];
311 
312     Table(){
313       set_init_function<InstanceKlass>();
314       set_init_function<InstanceRefKlass>();
315       set_init_function<InstanceMirrorKlass>();
316       set_init_function<InstanceClassLoaderKlass>();
317       set_init_function<ObjArrayKlass>();
318       set_init_function<TypeArrayKlass>();

319     }
320   };
321 
322   static Table _table;
323 public:
324 
325   static FunctionType function(Klass* klass) {
326     return _table._function[klass->id()];
327   }
328 };
329 
330 template <typename OopClosureType>
331 typename OopOopIterateBoundedDispatch<OopClosureType>::Table OopOopIterateBoundedDispatch<OopClosureType>::_table;
332 
333 
334 template <typename OopClosureType>
335 class OopOopIterateBackwardsDispatch {
336 private:
337   typedef void (*FunctionType)(OopClosureType*, oop, Klass*);
338 

361         _function[KlassType::ID] = &oop_oop_iterate_backwards<KlassType, oop>;
362       }
363     }
364 
365     template <typename KlassType>
366     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
367       set_resolve_function<KlassType>();
368       _function[KlassType::ID](cl, obj, k);
369     }
370 
371   public:
372     FunctionType _function[KLASS_ID_COUNT];
373 
374     Table(){
375       set_init_function<InstanceKlass>();
376       set_init_function<InstanceRefKlass>();
377       set_init_function<InstanceMirrorKlass>();
378       set_init_function<InstanceClassLoaderKlass>();
379       set_init_function<ObjArrayKlass>();
380       set_init_function<TypeArrayKlass>();

381     }
382   };
383 
384   static Table _table;
385 public:
386 
387   static FunctionType function(Klass* klass) {
388     return _table._function[klass->id()];
389   }
390 };
391 
392 template <typename OopClosureType>
393 typename OopOopIterateBackwardsDispatch<OopClosureType>::Table OopOopIterateBackwardsDispatch<OopClosureType>::_table;
394 
395 
396 template <typename OopClosureType>
397 void OopIteratorClosureDispatch::oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass) {
398   OopOopIterateDispatch<OopClosureType>::function(klass)(cl, obj, klass);
399 }
400 

  1 /*
  2  * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  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
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 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 "oops/access.inline.hpp"
 32 #include "oops/compressedOops.inline.hpp"
 33 #include "oops/klass.hpp"
 34 #include "oops/flatArrayKlass.inline.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/objArrayKlass.inline.hpp"
 40 #include "oops/typeArrayKlass.inline.hpp"
 41 #include "utilities/debug.hpp"
 42 
 43 // Defaults to strong claiming.
 44 inline MetadataVisitingOopIterateClosure::MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd) :
 45     ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_strong, rd) {}
 46 
 47 inline void ClaimMetadataVisitingOopIterateClosure::do_cld(ClassLoaderData* cld) {
 48   cld->oops_do(this, _claim);
 49 }
 50 
 51 inline void ClaimMetadataVisitingOopIterateClosure::do_klass(Klass* k) {
 52   ClassLoaderData* cld = k->class_loader_data();
 53   ClaimMetadataVisitingOopIterateClosure::do_cld(cld);
 54 }

238         _function[KlassType::ID] = &oop_oop_iterate<KlassType, oop>;
239       }
240     }
241 
242     template <typename KlassType>
243     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
244       set_resolve_function<KlassType>();
245       _function[KlassType::ID](cl, obj, k);
246     }
247 
248   public:
249     FunctionType _function[KLASS_ID_COUNT];
250 
251     Table(){
252       set_init_function<InstanceKlass>();
253       set_init_function<InstanceRefKlass>();
254       set_init_function<InstanceMirrorKlass>();
255       set_init_function<InstanceClassLoaderKlass>();
256       set_init_function<ObjArrayKlass>();
257       set_init_function<TypeArrayKlass>();
258       set_init_function<FlatArrayKlass>();
259     }
260   };
261 
262   static Table _table;
263 public:
264 
265   static FunctionType function(Klass* klass) {
266     return _table._function[klass->id()];
267   }
268 };
269 
270 template <typename OopClosureType>
271 typename OopOopIterateDispatch<OopClosureType>::Table OopOopIterateDispatch<OopClosureType>::_table;
272 
273 
274 template <typename OopClosureType>
275 class OopOopIterateBoundedDispatch {
276 private:
277   typedef void (*FunctionType)(OopClosureType*, oop, Klass*, MemRegion);
278 

301         _function[KlassType::ID] = &oop_oop_iterate_bounded<KlassType, oop>;
302       }
303     }
304 
305     template <typename KlassType>
306     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k, MemRegion mr) {
307       set_resolve_function<KlassType>();
308       _function[KlassType::ID](cl, obj, k, mr);
309     }
310 
311   public:
312     FunctionType _function[KLASS_ID_COUNT];
313 
314     Table(){
315       set_init_function<InstanceKlass>();
316       set_init_function<InstanceRefKlass>();
317       set_init_function<InstanceMirrorKlass>();
318       set_init_function<InstanceClassLoaderKlass>();
319       set_init_function<ObjArrayKlass>();
320       set_init_function<TypeArrayKlass>();
321       set_init_function<FlatArrayKlass>();
322     }
323   };
324 
325   static Table _table;
326 public:
327 
328   static FunctionType function(Klass* klass) {
329     return _table._function[klass->id()];
330   }
331 };
332 
333 template <typename OopClosureType>
334 typename OopOopIterateBoundedDispatch<OopClosureType>::Table OopOopIterateBoundedDispatch<OopClosureType>::_table;
335 
336 
337 template <typename OopClosureType>
338 class OopOopIterateBackwardsDispatch {
339 private:
340   typedef void (*FunctionType)(OopClosureType*, oop, Klass*);
341 

364         _function[KlassType::ID] = &oop_oop_iterate_backwards<KlassType, oop>;
365       }
366     }
367 
368     template <typename KlassType>
369     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
370       set_resolve_function<KlassType>();
371       _function[KlassType::ID](cl, obj, k);
372     }
373 
374   public:
375     FunctionType _function[KLASS_ID_COUNT];
376 
377     Table(){
378       set_init_function<InstanceKlass>();
379       set_init_function<InstanceRefKlass>();
380       set_init_function<InstanceMirrorKlass>();
381       set_init_function<InstanceClassLoaderKlass>();
382       set_init_function<ObjArrayKlass>();
383       set_init_function<TypeArrayKlass>();
384       set_init_function<FlatArrayKlass>();
385     }
386   };
387 
388   static Table _table;
389 public:
390 
391   static FunctionType function(Klass* klass) {
392     return _table._function[klass->id()];
393   }
394 };
395 
396 template <typename OopClosureType>
397 typename OopOopIterateBackwardsDispatch<OopClosureType>::Table OopOopIterateBackwardsDispatch<OopClosureType>::_table;
398 
399 
400 template <typename OopClosureType>
401 void OopIteratorClosureDispatch::oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass) {
402   OopOopIterateDispatch<OopClosureType>::function(klass)(cl, obj, klass);
403 }
404 
< prev index next >