hotspot/src/share/vm/oops/klass.hpp
changeset 30150 d9c940aa42ef
parent 28731 f7339cba0a6a
child 30764 fec48bf5a827
equal deleted inserted replaced
30149:c0f930abe5ed 30150:d9c940aa42ef
    23  */
    23  */
    24 
    24 
    25 #ifndef SHARE_VM_OOPS_KLASS_HPP
    25 #ifndef SHARE_VM_OOPS_KLASS_HPP
    26 #define SHARE_VM_OOPS_KLASS_HPP
    26 #define SHARE_VM_OOPS_KLASS_HPP
    27 
    27 
    28 #include "memory/genOopClosures.hpp"
       
    29 #include "memory/iterator.hpp"
    28 #include "memory/iterator.hpp"
    30 #include "memory/memRegion.hpp"
    29 #include "memory/memRegion.hpp"
    31 #include "memory/specialized_oop_closures.hpp"
    30 #include "memory/specialized_oop_closures.hpp"
    32 #include "oops/klassPS.hpp"
       
    33 #include "oops/metadata.hpp"
    31 #include "oops/metadata.hpp"
    34 #include "oops/oop.hpp"
    32 #include "oops/oop.hpp"
    35 #include "trace/traceMacros.hpp"
    33 #include "trace/traceMacros.hpp"
    36 #include "utilities/accessFlags.hpp"
    34 #include "utilities/accessFlags.hpp"
    37 #include "utilities/macros.hpp"
    35 #include "utilities/macros.hpp"
    38 #if INCLUDE_ALL_GCS
       
    39 #include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp"
       
    40 #include "gc_implementation/g1/g1OopClosures.hpp"
       
    41 #include "gc_implementation/parNew/parOopClosures.hpp"
       
    42 #endif // INCLUDE_ALL_GCS
       
    43 
    36 
    44 //
    37 //
    45 // A Klass provides:
    38 // A Klass provides:
    46 //  1: language level class object (method dictionary etc.)
    39 //  1: language level class object (method dictionary etc.)
    47 //  2: provide vm dispatch behavior for the object
    40 //  2: provide vm dispatch behavior for the object
    59 template <class T> class Array;
    52 template <class T> class Array;
    60 template <class T> class GrowableArray;
    53 template <class T> class GrowableArray;
    61 class ClassLoaderData;
    54 class ClassLoaderData;
    62 class klassVtable;
    55 class klassVtable;
    63 class ParCompactionManager;
    56 class ParCompactionManager;
       
    57 class PSPromotionManager;
    64 class KlassSizeStats;
    58 class KlassSizeStats;
    65 class fieldDescriptor;
    59 class fieldDescriptor;
    66 
    60 
    67 class Klass : public Metadata {
    61 class Klass : public Metadata {
    68   friend class VMStructs;
    62   friend class VMStructs;
   476   // For arrays, this returns the name of the element with a leading '['.
   470   // For arrays, this returns the name of the element with a leading '['.
   477   // For classes, this returns the name with a leading 'L' and a trailing ';'
   471   // For classes, this returns the name with a leading 'L' and a trailing ';'
   478   //     and the package separators as '/'.
   472   //     and the package separators as '/'.
   479   virtual const char* signature_name() const;
   473   virtual const char* signature_name() const;
   480 
   474 
   481   // garbage collection support
       
   482   virtual void oop_follow_contents(oop obj) = 0;
       
   483   virtual int  oop_adjust_pointers(oop obj) = 0;
       
   484 
       
   485   // Parallel Scavenge and Parallel Old
       
   486   PARALLEL_GC_DECLS_PV
       
   487 
       
   488   // type testing operations
   475   // type testing operations
   489  protected:
   476  protected:
   490   virtual bool oop_is_instance_slow()       const { return false; }
   477   virtual bool oop_is_instance_slow()       const { return false; }
   491   virtual bool oop_is_array_slow()          const { return false; }
   478   virtual bool oop_is_array_slow()          const { return false; }
   492   virtual bool oop_is_objArray_slow()       const { return false; }
   479   virtual bool oop_is_objArray_slow()       const { return false; }
   579   static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
   566   static void clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses = true);
   580   static void clean_subklass_tree(BoolObjectClosure* is_alive) {
   567   static void clean_subklass_tree(BoolObjectClosure* is_alive) {
   581     clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
   568     clean_weak_klass_links(is_alive, false /* clean_alive_klasses */);
   582   }
   569   }
   583 
   570 
   584   // iterators
   571   // GC specific object visitors
   585   virtual int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) = 0;
   572   //
   586   virtual int oop_oop_iterate_v(oop obj, ExtendedOopClosure* blk) {
   573   // Mark Sweep
   587     return oop_oop_iterate(obj, blk);
   574   virtual void oop_ms_follow_contents(oop obj) = 0;
   588   }
   575   virtual int  oop_ms_adjust_pointers(oop obj) = 0;
   589 
       
   590 #if INCLUDE_ALL_GCS
   576 #if INCLUDE_ALL_GCS
   591   // In case we don't have a specialized backward scanner use forward
   577   // Parallel Scavenge
   592   // iteration.
   578   virtual void oop_ps_push_contents(  oop obj, PSPromotionManager* pm)   = 0;
   593   virtual int oop_oop_iterate_backwards_v(oop obj, ExtendedOopClosure* blk) {
   579   // Parallel Compact
   594     return oop_oop_iterate_v(obj, blk);
   580   virtual void oop_pc_follow_contents(oop obj, ParCompactionManager* cm) = 0;
   595   }
   581   virtual void oop_pc_update_pointers(oop obj) = 0;
   596 #endif // INCLUDE_ALL_GCS
   582 #endif
   597 
   583 
   598   // Iterates "blk" over all the oops in "obj" (of type "this") within "mr".
   584   // Iterators specialized to particular subtypes
   599   // (I don't see why the _m should be required, but without it the Solaris
   585   // of ExtendedOopClosure, to avoid closure virtual calls.
   600   // C++ gives warning messages about overridings of the "oop_oop_iterate"
   586 #define Klass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                                      \
   601   // defined above "hiding" this virtual function.  (DLD, 6/20/00)) */
   587   virtual int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) = 0;                    \
   602   virtual int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) = 0;
   588   /* Iterates "closure" over all the oops in "obj" (of type "this") within "mr". */                \
   603   virtual int oop_oop_iterate_v_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
   589   virtual int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* closure, MemRegion mr) = 0;
   604     return oop_oop_iterate_m(obj, blk, mr);
   590 
   605   }
   591   ALL_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_DECL)
   606 
   592   ALL_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_DECL)
   607   // Versions of the above iterators specialized to particular subtypes
       
   608   // of OopClosure, to avoid closure virtual calls.
       
   609 #define Klass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)                \
       
   610   virtual int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk) {     \
       
   611     /* Default implementation reverts to general version. */                 \
       
   612     return oop_oop_iterate(obj, blk);                                        \
       
   613   }                                                                          \
       
   614                                                                              \
       
   615   /* Iterates "blk" over all the oops in "obj" (of type "this") within "mr". \
       
   616      (I don't see why the _m should be required, but without it the Solaris  \
       
   617      C++ gives warning messages about overridings of the "oop_oop_iterate"   \
       
   618      defined above "hiding" this virtual function.  (DLD, 6/20/00)) */       \
       
   619   virtual int oop_oop_iterate##nv_suffix##_m(oop obj,                        \
       
   620                                              OopClosureType* blk,            \
       
   621                                              MemRegion mr) {                 \
       
   622     return oop_oop_iterate_m(obj, blk, mr);                                  \
       
   623   }
       
   624 
       
   625   SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_DECL)
       
   626   SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_DECL)
       
   627 
   593 
   628 #if INCLUDE_ALL_GCS
   594 #if INCLUDE_ALL_GCS
   629 #define Klass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)      \
   595 #define Klass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix)                    \
   630   virtual int oop_oop_iterate_backwards##nv_suffix(oop obj,                  \
   596   virtual int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) = 0;
   631                                                    OopClosureType* blk) {    \
   597 
   632     /* Default implementation reverts to general version. */                 \
   598   ALL_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_BACKWARDS_DECL)
   633     return oop_oop_iterate_backwards_v(obj, blk);                            \
   599   ALL_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_BACKWARDS_DECL)
   634   }
       
   635 
       
   636   SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(Klass_OOP_OOP_ITERATE_BACKWARDS_DECL)
       
   637   SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(Klass_OOP_OOP_ITERATE_BACKWARDS_DECL)
       
   638 #endif // INCLUDE_ALL_GCS
   600 #endif // INCLUDE_ALL_GCS
   639 
   601 
   640   virtual void array_klasses_do(void f(Klass* k)) {}
   602   virtual void array_klasses_do(void f(Klass* k)) {}
   641 
   603 
   642   // Return self, except for abstract classes with exactly 1
   604   // Return self, except for abstract classes with exactly 1