< prev index next >

src/hotspot/share/oops/instanceMirrorKlass.inline.hpp

Print this page




  34 #include "utilities/macros.hpp"
  35 
  36 template <typename T, class OopClosureType>
  37 void InstanceMirrorKlass::oop_oop_iterate_statics(oop obj, OopClosureType* closure) {
  38   T* p         = (T*)start_of_static_fields(obj);
  39   T* const end = p + java_lang_Class::static_oop_field_count_raw(obj);
  40 
  41   for (; p < end; ++p) {
  42     Devirtualizer::do_oop(closure, p);
  43   }
  44 }
  45 
  46 template <typename T, class OopClosureType>
  47 void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
  48   InstanceKlass::oop_oop_iterate<T>(obj, closure);
  49 
  50   if (Devirtualizer::do_metadata(closure)) {
  51     Klass* klass = java_lang_Class::as_Klass_raw(obj);
  52     // We'll get NULL for primitive mirrors.
  53     if (klass != NULL) {
  54       if (klass->is_instance_klass() &&
  55           InstanceKlass::cast(klass)->is_unsafe_anonymous()) {
  56         // An unsafe anonymous class doesn't have its own class loader, so
  57         // when handling the java mirror for the class we need to make sure its class
  58         // loader data is claimed, this is done by calling do_cld explicitly.
  59         // For non-anonymous classes the call to do_cld is made when the class
  60         // loader itself is handled.
  61         Devirtualizer::do_cld(closure, klass->class_loader_data());
  62       } else {
  63         Devirtualizer::do_klass(closure, klass);
  64       }
  65     } else {
  66       // We would like to assert here (as below) that if klass has been NULL, then
  67       // this has been a mirror for a primitive type that we do not need to follow
  68       // as they are always strong roots.
  69       // However, we might get across a klass that just changed during CMS concurrent
  70       // marking if allocation occurred in the old generation.
  71       // This is benign here, as we keep alive all CLDs that were loaded during the
  72       // CMS concurrent phase in the class loading, i.e. they will be iterated over
  73       // and kept alive during remark.
  74       // assert(java_lang_Class::is_primitive(obj), "Sanity check");
  75     }
  76   }
  77 




  34 #include "utilities/macros.hpp"
  35 
  36 template <typename T, class OopClosureType>
  37 void InstanceMirrorKlass::oop_oop_iterate_statics(oop obj, OopClosureType* closure) {
  38   T* p         = (T*)start_of_static_fields(obj);
  39   T* const end = p + java_lang_Class::static_oop_field_count_raw(obj);
  40 
  41   for (; p < end; ++p) {
  42     Devirtualizer::do_oop(closure, p);
  43   }
  44 }
  45 
  46 template <typename T, class OopClosureType>
  47 void InstanceMirrorKlass::oop_oop_iterate(oop obj, OopClosureType* closure) {
  48   InstanceKlass::oop_oop_iterate<T>(obj, closure);
  49 
  50   if (Devirtualizer::do_metadata(closure)) {
  51     Klass* klass = java_lang_Class::as_Klass_raw(obj);
  52     // We'll get NULL for primitive mirrors.
  53     if (klass != NULL) {
  54       if (klass->is_instance_klass() && klass->class_loader_data()->is_shortlived()) {
  55         // A weak nonfindable or an unsafe anonymous class doesn't have its own class loader,
  56         // so when handling the java mirror for the class we need to make sure its class

  57         // loader data is claimed, this is done by calling do_cld explicitly.
  58         // For non-anonymous classes the call to do_cld is made when the class
  59         // loader itself is handled.
  60         Devirtualizer::do_cld(closure, klass->class_loader_data());
  61       } else {
  62         Devirtualizer::do_klass(closure, klass);
  63       }
  64     } else {
  65       // We would like to assert here (as below) that if klass has been NULL, then
  66       // this has been a mirror for a primitive type that we do not need to follow
  67       // as they are always strong roots.
  68       // However, we might get across a klass that just changed during CMS concurrent
  69       // marking if allocation occurred in the old generation.
  70       // This is benign here, as we keep alive all CLDs that were loaded during the
  71       // CMS concurrent phase in the class loading, i.e. they will be iterated over
  72       // and kept alive during remark.
  73       // assert(java_lang_Class::is_primitive(obj), "Sanity check");
  74     }
  75   }
  76 


< prev index next >