< prev index next >

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

Print this page




  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 "classfile/classLoaderData.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/universe.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 inline void MetadataVisitingOopIterateClosure::do_cld(ClassLoaderData* cld) {
  43   cld->oops_do(this, ClassLoaderData::_claim_strong);
  44 }
  45 
  46 inline void MetadataVisitingOopIterateClosure::do_klass(Klass* k) {
  47   ClassLoaderData* cld = k->class_loader_data();
  48   MetadataVisitingOopIterateClosure::do_cld(cld);
  49 }
  50 
  51 #ifdef ASSERT
  52 // This verification is applied to all visited oops.
  53 // The closures can turn is off by overriding should_verify_oops().
  54 template <typename T>
  55 void OopIterateClosure::verify(T* p) {
  56   if (should_verify_oops()) {
  57     T heap_oop = RawAccess<>::oop_load(p);
  58     if (!CompressedOops::is_null(heap_oop)) {
  59       oop o = CompressedOops::decode_not_null(heap_oop);


 254         _function[KlassType::ID] = &oop_oop_iterate<KlassType, oop>;
 255       }
 256     }
 257 
 258     template <typename KlassType>
 259     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
 260       set_resolve_function<KlassType>();
 261       _function[KlassType::ID](cl, obj, k);
 262     }
 263 
 264   public:
 265     void (*_function[KLASS_ID_COUNT])(OopClosureType*, oop, Klass*);
 266 
 267     Table(){
 268       set_init_function<InstanceKlass>();
 269       set_init_function<InstanceRefKlass>();
 270       set_init_function<InstanceMirrorKlass>();
 271       set_init_function<InstanceClassLoaderKlass>();
 272       set_init_function<ObjArrayKlass>();
 273       set_init_function<TypeArrayKlass>();

 274     }
 275   };
 276 
 277   static Table _table;
 278 public:
 279 
 280   static void (*function(Klass* klass))(OopClosureType*, oop, Klass*) {
 281     return _table._function[klass->id()];
 282   }
 283 };
 284 
 285 template <typename OopClosureType>
 286 typename OopOopIterateDispatch<OopClosureType>::Table OopOopIterateDispatch<OopClosureType>::_table;
 287 
 288 
 289 template <typename OopClosureType>
 290 class OopOopIterateBoundedDispatch {
 291 private:
 292   class Table {
 293   private:


 314         _function[KlassType::ID] = &oop_oop_iterate_bounded<KlassType, oop>;
 315       }
 316     }
 317 
 318     template <typename KlassType>
 319     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k, MemRegion mr) {
 320       set_resolve_function<KlassType>();
 321       _function[KlassType::ID](cl, obj, k, mr);
 322     }
 323 
 324   public:
 325     void (*_function[KLASS_ID_COUNT])(OopClosureType*, oop, Klass*, MemRegion);
 326 
 327     Table(){
 328       set_init_function<InstanceKlass>();
 329       set_init_function<InstanceRefKlass>();
 330       set_init_function<InstanceMirrorKlass>();
 331       set_init_function<InstanceClassLoaderKlass>();
 332       set_init_function<ObjArrayKlass>();
 333       set_init_function<TypeArrayKlass>();

 334     }
 335   };
 336 
 337   static Table _table;
 338 public:
 339 
 340   static void (*function(Klass* klass))(OopClosureType*, oop, Klass*, MemRegion) {
 341     return _table._function[klass->id()];
 342   }
 343 };
 344 
 345 template <typename OopClosureType>
 346 typename OopOopIterateBoundedDispatch<OopClosureType>::Table OopOopIterateBoundedDispatch<OopClosureType>::_table;
 347 
 348 
 349 template <typename OopClosureType>
 350 class OopOopIterateBackwardsDispatch {
 351 private:
 352   class Table {
 353   private:


 374         _function[KlassType::ID] = &oop_oop_iterate_backwards<KlassType, oop>;
 375       }
 376     }
 377 
 378     template <typename KlassType>
 379     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
 380       set_resolve_function<KlassType>();
 381       _function[KlassType::ID](cl, obj, k);
 382     }
 383 
 384   public:
 385     void (*_function[KLASS_ID_COUNT])(OopClosureType*, oop, Klass*);
 386 
 387     Table(){
 388       set_init_function<InstanceKlass>();
 389       set_init_function<InstanceRefKlass>();
 390       set_init_function<InstanceMirrorKlass>();
 391       set_init_function<InstanceClassLoaderKlass>();
 392       set_init_function<ObjArrayKlass>();
 393       set_init_function<TypeArrayKlass>();

 394     }
 395   };
 396 
 397   static Table _table;
 398 public:
 399 
 400   static void (*function(Klass* klass))(OopClosureType*, oop, Klass*) {
 401     return _table._function[klass->id()];
 402   }
 403 };
 404 
 405 template <typename OopClosureType>
 406 typename OopOopIterateBackwardsDispatch<OopClosureType>::Table OopOopIterateBackwardsDispatch<OopClosureType>::_table;
 407 
 408 
 409 template <typename OopClosureType>
 410 void OopIteratorClosureDispatch::oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass) {
 411   OopOopIterateDispatch<OopClosureType>::function(klass)(cl, obj, klass);
 412 }
 413 


  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 "classfile/classLoaderData.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "memory/universe.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 "oops/valueArrayKlass.inline.hpp"
  41 #include "utilities/debug.hpp"
  42 
  43 inline void MetadataVisitingOopIterateClosure::do_cld(ClassLoaderData* cld) {
  44   cld->oops_do(this, ClassLoaderData::_claim_strong);
  45 }
  46 
  47 inline void MetadataVisitingOopIterateClosure::do_klass(Klass* k) {
  48   ClassLoaderData* cld = k->class_loader_data();
  49   MetadataVisitingOopIterateClosure::do_cld(cld);
  50 }
  51 
  52 #ifdef ASSERT
  53 // This verification is applied to all visited oops.
  54 // The closures can turn is off by overriding should_verify_oops().
  55 template <typename T>
  56 void OopIterateClosure::verify(T* p) {
  57   if (should_verify_oops()) {
  58     T heap_oop = RawAccess<>::oop_load(p);
  59     if (!CompressedOops::is_null(heap_oop)) {
  60       oop o = CompressedOops::decode_not_null(heap_oop);


 255         _function[KlassType::ID] = &oop_oop_iterate<KlassType, oop>;
 256       }
 257     }
 258 
 259     template <typename KlassType>
 260     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
 261       set_resolve_function<KlassType>();
 262       _function[KlassType::ID](cl, obj, k);
 263     }
 264 
 265   public:
 266     void (*_function[KLASS_ID_COUNT])(OopClosureType*, oop, Klass*);
 267 
 268     Table(){
 269       set_init_function<InstanceKlass>();
 270       set_init_function<InstanceRefKlass>();
 271       set_init_function<InstanceMirrorKlass>();
 272       set_init_function<InstanceClassLoaderKlass>();
 273       set_init_function<ObjArrayKlass>();
 274       set_init_function<TypeArrayKlass>();
 275       set_init_function<ValueArrayKlass>();
 276     }
 277   };
 278 
 279   static Table _table;
 280 public:
 281 
 282   static void (*function(Klass* klass))(OopClosureType*, oop, Klass*) {
 283     return _table._function[klass->id()];
 284   }
 285 };
 286 
 287 template <typename OopClosureType>
 288 typename OopOopIterateDispatch<OopClosureType>::Table OopOopIterateDispatch<OopClosureType>::_table;
 289 
 290 
 291 template <typename OopClosureType>
 292 class OopOopIterateBoundedDispatch {
 293 private:
 294   class Table {
 295   private:


 316         _function[KlassType::ID] = &oop_oop_iterate_bounded<KlassType, oop>;
 317       }
 318     }
 319 
 320     template <typename KlassType>
 321     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k, MemRegion mr) {
 322       set_resolve_function<KlassType>();
 323       _function[KlassType::ID](cl, obj, k, mr);
 324     }
 325 
 326   public:
 327     void (*_function[KLASS_ID_COUNT])(OopClosureType*, oop, Klass*, MemRegion);
 328 
 329     Table(){
 330       set_init_function<InstanceKlass>();
 331       set_init_function<InstanceRefKlass>();
 332       set_init_function<InstanceMirrorKlass>();
 333       set_init_function<InstanceClassLoaderKlass>();
 334       set_init_function<ObjArrayKlass>();
 335       set_init_function<TypeArrayKlass>();
 336       set_init_function<ValueArrayKlass>();
 337     }
 338   };
 339 
 340   static Table _table;
 341 public:
 342 
 343   static void (*function(Klass* klass))(OopClosureType*, oop, Klass*, MemRegion) {
 344     return _table._function[klass->id()];
 345   }
 346 };
 347 
 348 template <typename OopClosureType>
 349 typename OopOopIterateBoundedDispatch<OopClosureType>::Table OopOopIterateBoundedDispatch<OopClosureType>::_table;
 350 
 351 
 352 template <typename OopClosureType>
 353 class OopOopIterateBackwardsDispatch {
 354 private:
 355   class Table {
 356   private:


 377         _function[KlassType::ID] = &oop_oop_iterate_backwards<KlassType, oop>;
 378       }
 379     }
 380 
 381     template <typename KlassType>
 382     void set_resolve_function_and_execute(OopClosureType* cl, oop obj, Klass* k) {
 383       set_resolve_function<KlassType>();
 384       _function[KlassType::ID](cl, obj, k);
 385     }
 386 
 387   public:
 388     void (*_function[KLASS_ID_COUNT])(OopClosureType*, oop, Klass*);
 389 
 390     Table(){
 391       set_init_function<InstanceKlass>();
 392       set_init_function<InstanceRefKlass>();
 393       set_init_function<InstanceMirrorKlass>();
 394       set_init_function<InstanceClassLoaderKlass>();
 395       set_init_function<ObjArrayKlass>();
 396       set_init_function<TypeArrayKlass>();
 397       set_init_function<ValueArrayKlass>();
 398     }
 399   };
 400 
 401   static Table _table;
 402 public:
 403 
 404   static void (*function(Klass* klass))(OopClosureType*, oop, Klass*) {
 405     return _table._function[klass->id()];
 406   }
 407 };
 408 
 409 template <typename OopClosureType>
 410 typename OopOopIterateBackwardsDispatch<OopClosureType>::Table OopOopIterateBackwardsDispatch<OopClosureType>::_table;
 411 
 412 
 413 template <typename OopClosureType>
 414 void OopIteratorClosureDispatch::oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass) {
 415   OopOopIterateDispatch<OopClosureType>::function(klass)(cl, obj, klass);
 416 }
 417 
< prev index next >