src/hotspot/share/oops/instanceRefKlass.hpp
changeset 50752 9d62da00bf15
parent 49982 9042ffe5b7fe
child 50870 830b05ca7f58
equal deleted inserted replaced
50751:d9132bdf6c30 50752:9d62da00bf15
    23  */
    23  */
    24 
    24 
    25 #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    25 #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    26 #define SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    26 #define SHARE_VM_OOPS_INSTANCEREFKLASS_HPP
    27 
    27 
    28 #include "gc/shared/specialized_oop_closures.hpp"
       
    29 #include "oops/instanceKlass.hpp"
    28 #include "oops/instanceKlass.hpp"
    30 #include "utilities/macros.hpp"
    29 #include "utilities/macros.hpp"
    31 
    30 
    32 class ClassFileParser;
    31 class ClassFileParser;
    33 
    32 
    48 // and the pending list lock object in the same class is notified.
    47 // and the pending list lock object in the same class is notified.
    49 
    48 
    50 
    49 
    51 class InstanceRefKlass: public InstanceKlass {
    50 class InstanceRefKlass: public InstanceKlass {
    52   friend class InstanceKlass;
    51   friend class InstanceKlass;
       
    52  public:
       
    53   static const KlassID ID = InstanceRefKlassID;
       
    54 
    53  private:
    55  private:
    54   InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference) {}
    56   InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference, ID) {}
    55 
    57 
    56  public:
    58  public:
    57   InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
    59   InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
    58 
    60 
    59   // GC specific object visitors
    61   // GC specific object visitors
    65   void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
    67   void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
    66   void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
    68   void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
    67 #endif
    69 #endif
    68 
    70 
    69   // Oop fields (and metadata) iterators
    71   // Oop fields (and metadata) iterators
    70   //  [nv = true]  Use non-virtual calls to do_oop_nv.
       
    71   //  [nv = false] Use virtual calls to do_oop.
       
    72   //
    72   //
    73   // The InstanceRefKlass iterators also support reference processing.
    73   // The InstanceRefKlass iterators also support reference processing.
    74 
    74 
    75 
    75 
    76   // Forward iteration
    76   // Forward iteration
    77 private:
       
    78   // Iterate over all oop fields and metadata.
    77   // Iterate over all oop fields and metadata.
    79   template <bool nv, class OopClosureType>
    78   template <typename T, class OopClosureType>
    80   inline void oop_oop_iterate(oop obj, OopClosureType* closure);
    79   inline void oop_oop_iterate(oop obj, OopClosureType* closure);
    81 
    80 
    82   // Reverse iteration
    81   // Reverse iteration
    83 #if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
       
    84   // Iterate over all oop fields and metadata.
    82   // Iterate over all oop fields and metadata.
    85   template <bool nv, class OopClosureType>
    83   template <typename T, class OopClosureType>
    86   inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);
    84   inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure);
    87 #endif
       
    88 
    85 
    89   // Bounded range iteration
    86   // Bounded range iteration
    90   // Iterate over all oop fields and metadata.
    87   // Iterate over all oop fields and metadata.
    91   template <bool nv, class OopClosureType>
    88   template <typename T, class OopClosureType>
    92   inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr);
    89   inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr);
       
    90 
       
    91   private:
    93 
    92 
    94   // Reference processing part of the iterators.
    93   // Reference processing part of the iterators.
    95 
    94 
    96   // Specialized for [T = oop] or [T = narrowOop].
    95   template <typename T, class OopClosureType, class Contains>
    97   template <bool nv, typename T, class OopClosureType, class Contains>
    96   inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure, Contains& contains);
    98   inline void oop_oop_iterate_ref_processing_specialized(oop obj, OopClosureType* closure, Contains& contains);
       
    99 
    97 
   100   // Only perform reference processing if the referent object is within mr.
    98   // Only perform reference processing if the referent object is within mr.
   101   template <bool nv, class OopClosureType>
    99   template <typename T, class OopClosureType>
   102   inline void oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr);
   100   inline void oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr);
   103 
   101 
   104   // Reference processing
   102   // Reference processing
   105   template <bool nv, class OopClosureType>
   103   template <typename T, class OopClosureType>
   106   inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure);
   104   inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure);
   107 
   105 
   108   // Building blocks for specialized handling.
   106   // Building blocks for specialized handling.
   109   template <bool nv, typename T, class OopClosureType, class Contains>
   107   template <typename T, class OopClosureType, class Contains>
   110   static void do_referent(oop obj, OopClosureType* closure, Contains& contains);
   108   static void do_referent(oop obj, OopClosureType* closure, Contains& contains);
   111 
   109 
   112   template <bool nv, typename T, class OopClosureType, class Contains>
   110   template <typename T, class OopClosureType, class Contains>
   113   static void do_next(oop obj, OopClosureType* closure, Contains& contains);
   111   static void do_next(oop obj, OopClosureType* closure, Contains& contains);
   114 
   112 
   115   template <bool nv, typename T, class OopClosureType, class Contains>
   113   template <typename T, class OopClosureType, class Contains>
   116   static void do_discovered(oop obj, OopClosureType* closure, Contains& contains);
   114   static void do_discovered(oop obj, OopClosureType* closure, Contains& contains);
   117 
   115 
   118   template <typename T, class OopClosureType>
   116   template <typename T, class OopClosureType>
   119   static bool try_discover(oop obj, ReferenceType type, OopClosureType* closure);
   117   static bool try_discover(oop obj, ReferenceType type, OopClosureType* closure);
   120 
   118 
   121   // Do discovery while handling InstanceRefKlasses. Reference discovery
   119   // Do discovery while handling InstanceRefKlasses. Reference discovery
   122   // is only done if the closure provides a ReferenceProcessor.
   120   // is only done if the closure provides a ReferenceProcessor.
   123   template <bool nv, typename T, class OopClosureType, class Contains>
   121   template <typename T, class OopClosureType, class Contains>
   124   static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains);
   122   static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains);
   125 
   123 
   126   // Used for a special case in G1 where the closure needs to be applied
   124   // Used for a special case in G1 where the closure needs to be applied
   127   // to the discovered field. Reference discovery is also done if the
   125   // to the discovered field. Reference discovery is also done if the
   128   // closure provides a ReferenceProcessor.
   126   // closure provides a ReferenceProcessor.
   129   template <bool nv, typename T, class OopClosureType, class Contains>
   127   template <typename T, class OopClosureType, class Contains>
   130   static void oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains);
   128   static void oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains);
   131 
   129 
   132   // Apply the closure to all fields. No reference discovery is done.
   130   // Apply the closure to all fields. No reference discovery is done.
   133   template <bool nv, typename T, class OopClosureType, class Contains>
   131   template <typename T, class OopClosureType, class Contains>
   134   static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains);
   132   static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains);
   135 
   133 
   136   template <typename T>
   134   template <typename T>
   137   static void trace_reference_gc(const char *s, oop obj) NOT_DEBUG_RETURN;
   135   static void trace_reference_gc(const char *s, oop obj) NOT_DEBUG_RETURN;
   138 
   136 
   139  public:
   137  public:
   140 
       
   141   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
       
   142   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
       
   143 
       
   144 #if INCLUDE_OOP_OOP_ITERATE_BACKWARDS
       
   145   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
       
   146   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
       
   147 #endif
       
   148 
       
   149   // Update non-static oop maps so 'referent', 'nextPending' and
   138   // Update non-static oop maps so 'referent', 'nextPending' and
   150   // 'discovered' will look like non-oops
   139   // 'discovered' will look like non-oops
   151   static void update_nonstatic_oop_maps(Klass* k);
   140   static void update_nonstatic_oop_maps(Klass* k);
   152 
   141 
   153  public:
   142  public: