hotspot/src/share/vm/memory/iterator.hpp
changeset 32606 fdaa30d06ada
parent 30880 efe35e08179f
child 33226 19cb9b844190
equal deleted inserted replaced
32605:dab0de4ff7ff 32606:fdaa30d06ada
    59   // If the do_metadata functions return "true",
    59   // If the do_metadata functions return "true",
    60   // we invoke the following when running oop_iterate():
    60   // we invoke the following when running oop_iterate():
    61   //
    61   //
    62   // 1) do_klass on the header klass pointer.
    62   // 1) do_klass on the header klass pointer.
    63   // 2) do_klass on the klass pointer in the mirrors.
    63   // 2) do_klass on the klass pointer in the mirrors.
    64   // 3) do_class_loader_data on the class loader data in class loaders.
    64   // 3) do_cld   on the class loader data in class loaders.
    65   //
    65   //
    66   // The virtual (without suffix) and the non-virtual (with _nv suffix) need
    66   // The virtual (without suffix) and the non-virtual (with _nv suffix) need
    67   // to be updated together, or else the devirtualization will break.
    67   // to be updated together, or else the devirtualization will break.
    68   //
    68   //
    69   // Providing default implementations of the _nv functions unfortunately
    69   // Providing default implementations of the _nv functions unfortunately
    70   // removes the compile-time safeness, but reduces the clutter for the
    70   // removes the compile-time safeness, but reduces the clutter for the
    71   // ExtendedOopClosures that don't need to walk the metadata.
    71   // ExtendedOopClosures that don't need to walk the metadata.
    72   // Currently, only CMS and G1 need these.
    72   // Currently, only CMS and G1 need these.
    73 
    73 
       
    74   bool do_metadata_nv()      { return false; }
    74   virtual bool do_metadata() { return do_metadata_nv(); }
    75   virtual bool do_metadata() { return do_metadata_nv(); }
    75   bool do_metadata_nv()      { return false; }
    76 
    76 
    77   void do_klass_nv(Klass* k)      { ShouldNotReachHere(); }
    77   virtual void do_klass(Klass* k)   { do_klass_nv(k); }
    78   virtual void do_klass(Klass* k) { do_klass_nv(k); }
    78   void do_klass_nv(Klass* k)        { ShouldNotReachHere(); }
    79 
    79 
    80   void do_cld_nv(ClassLoaderData* cld)      { ShouldNotReachHere(); }
    80   virtual void do_class_loader_data(ClassLoaderData* cld) { ShouldNotReachHere(); }
    81   virtual void do_cld(ClassLoaderData* cld) { do_cld_nv(cld); }
    81 
    82 
    82   // True iff this closure may be safely applied more than once to an oop
    83   // True iff this closure may be safely applied more than once to an oop
    83   // location without an intervening "major reset" (like the end of a GC).
    84   // location without an intervening "major reset" (like the end of a GC).
    84   virtual bool idempotent() { return false; }
    85   virtual bool idempotent() { return false; }
    85   virtual bool apply_to_weak_ref_discovered_field() { return false; }
    86   virtual bool apply_to_weak_ref_discovered_field() { return false; }
   178   }
   179   }
   179   MetadataAwareOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) {
   180   MetadataAwareOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) {
   180     _klass_closure.initialize(this);
   181     _klass_closure.initialize(this);
   181   }
   182   }
   182 
   183 
   183   virtual bool do_metadata()    { return do_metadata_nv(); }
   184   bool do_metadata_nv()      { return true; }
   184   inline  bool do_metadata_nv() { return true; }
   185   virtual bool do_metadata() { return do_metadata_nv(); }
   185 
   186 
   186   virtual void do_klass(Klass* k);
       
   187   void do_klass_nv(Klass* k);
   187   void do_klass_nv(Klass* k);
   188 
   188   virtual void do_klass(Klass* k) { do_klass_nv(k); }
   189   virtual void do_class_loader_data(ClassLoaderData* cld);
   189 
       
   190   void do_cld_nv(ClassLoaderData* cld);
       
   191   virtual void do_cld(ClassLoaderData* cld) { do_cld_nv(cld); }
   190 };
   192 };
   191 
   193 
   192 // ObjectClosure is used for iterating through an object space
   194 // ObjectClosure is used for iterating through an object space
   193 
   195 
   194 class ObjectClosure : public Closure {
   196 class ObjectClosure : public Closure {
   368 // Dispatches to the non-virtual functions.
   370 // Dispatches to the non-virtual functions.
   369 template <> class Devirtualizer<true> {
   371 template <> class Devirtualizer<true> {
   370  public:
   372  public:
   371   template <class OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
   373   template <class OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
   372   template <class OopClosureType>             static void do_klass(OopClosureType* closure, Klass* k);
   374   template <class OopClosureType>             static void do_klass(OopClosureType* closure, Klass* k);
       
   375   template <class OopClosureType>             static void do_cld(OopClosureType* closure, ClassLoaderData* cld);
   373   template <class OopClosureType>             static bool do_metadata(OopClosureType* closure);
   376   template <class OopClosureType>             static bool do_metadata(OopClosureType* closure);
   374 };
   377 };
   375 
   378 
   376 // Dispatches to the virtual functions.
   379 // Dispatches to the virtual functions.
   377 template <> class Devirtualizer<false> {
   380 template <> class Devirtualizer<false> {
   378  public:
   381  public:
   379   template <class OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
   382   template <class OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
   380   template <class OopClosureType>             static void do_klass(OopClosureType* closure, Klass* k);
   383   template <class OopClosureType>             static void do_klass(OopClosureType* closure, Klass* k);
       
   384   template <class OopClosureType>             static void do_cld(OopClosureType* closure, ClassLoaderData* cld);
   381   template <class OopClosureType>             static bool do_metadata(OopClosureType* closure);
   385   template <class OopClosureType>             static bool do_metadata(OopClosureType* closure);
   382 };
   386 };
   383 
   387 
   384 #endif // SHARE_VM_MEMORY_ITERATOR_HPP
   388 #endif // SHARE_VM_MEMORY_ITERATOR_HPP