41 // During GC discovered reference objects are added (chained) to one 42 // of the four lists below, depending on the type of reference. 43 // The linked occurs through the next field in class java/lang/ref/Reference. 44 // 45 // Afterwards, the discovered references are processed in decreasing 46 // order of reachability. Reference objects eligible for notification 47 // are linked to the static pending_list in class java/lang/ref/Reference, 48 // and the pending list lock object in the same class is notified. 49 50 51 class InstanceRefKlass: public InstanceKlass { 52 friend class InstanceKlass; 53 private: 54 InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference) {} 55 56 public: 57 InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } 58 59 // GC specific object visitors 60 // 61 #if INCLUDE_ALL_GCS 62 // Parallel Scavenge 63 void oop_ps_push_contents( oop obj, PSPromotionManager* pm); 64 // Parallel Compact 65 void oop_pc_follow_contents(oop obj, ParCompactionManager* cm); 66 void oop_pc_update_pointers(oop obj, ParCompactionManager* cm); 67 #endif 68 69 // 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 // 73 // The InstanceRefKlass iterators also support reference processing. 74 75 76 // Forward iteration 77 private: 78 // Iterate over all oop fields and metadata. 79 template <bool nv, class OopClosureType> 80 inline void oop_oop_iterate(oop obj, OopClosureType* closure); 81 82 // Reverse iteration 83 #if INCLUDE_ALL_GCS 84 // Iterate over all oop fields and metadata. 85 template <bool nv, class OopClosureType> 86 inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure); 87 #endif // INCLUDE_ALL_GCS 88 89 // Bounded range iteration 90 // Iterate over all oop fields and metadata. 91 template <bool nv, class OopClosureType> 92 inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr); 93 94 // Reference processing part of the iterators. 95 96 // Specialized for [T = oop] or [T = narrowOop]. 97 template <bool nv, typename T, class OopClosureType, class Contains> 98 inline void oop_oop_iterate_ref_processing_specialized(oop obj, OopClosureType* closure, Contains& contains); 99 100 // Only perform reference processing if the referent object is within mr. 101 template <bool nv, class OopClosureType> 102 inline void oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr); 103 104 // Reference processing 105 template <bool nv, class OopClosureType> 106 inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure); 107 124 static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains); 125 126 // 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 128 // closure provides a ReferenceProcessor. 129 template <bool nv, typename T, class OopClosureType, class Contains> 130 static void oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains); 131 132 // Apply the closure to all fields. No reference discovery is done. 133 template <bool nv, typename T, class OopClosureType, class Contains> 134 static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains); 135 136 template <typename T> 137 static void trace_reference_gc(const char *s, oop obj) NOT_DEBUG_RETURN; 138 139 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_ALL_GCS 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 // INCLUDE_ALL_GCS 148 149 // Update non-static oop maps so 'referent', 'nextPending' and 150 // 'discovered' will look like non-oops 151 static void update_nonstatic_oop_maps(Klass* k); 152 153 public: 154 // Verification 155 void oop_verify_on(oop obj, outputStream* st); 156 }; 157 158 #endif // SHARE_VM_OOPS_INSTANCEREFKLASS_HPP | 41 // During GC discovered reference objects are added (chained) to one 42 // of the four lists below, depending on the type of reference. 43 // The linked occurs through the next field in class java/lang/ref/Reference. 44 // 45 // Afterwards, the discovered references are processed in decreasing 46 // order of reachability. Reference objects eligible for notification 47 // are linked to the static pending_list in class java/lang/ref/Reference, 48 // and the pending list lock object in the same class is notified. 49 50 51 class InstanceRefKlass: public InstanceKlass { 52 friend class InstanceKlass; 53 private: 54 InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference) {} 55 56 public: 57 InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); } 58 59 // GC specific object visitors 60 // 61 #if INCLUDE_PARALLELGC 62 // Parallel Scavenge 63 void oop_ps_push_contents( oop obj, PSPromotionManager* pm); 64 // Parallel Compact 65 void oop_pc_follow_contents(oop obj, ParCompactionManager* cm); 66 void oop_pc_update_pointers(oop obj, ParCompactionManager* cm); 67 #endif 68 69 // 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 // 73 // The InstanceRefKlass iterators also support reference processing. 74 75 76 // Forward iteration 77 private: 78 // Iterate over all oop fields and metadata. 79 template <bool nv, class OopClosureType> 80 inline void oop_oop_iterate(oop obj, OopClosureType* closure); 81 82 // Reverse iteration 83 #if INCLUDE_OOP_OOP_ITERATE_BACKWARDS 84 // Iterate over all oop fields and metadata. 85 template <bool nv, class OopClosureType> 86 inline void oop_oop_iterate_reverse(oop obj, OopClosureType* closure); 87 #endif 88 89 // Bounded range iteration 90 // Iterate over all oop fields and metadata. 91 template <bool nv, class OopClosureType> 92 inline void oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr); 93 94 // Reference processing part of the iterators. 95 96 // Specialized for [T = oop] or [T = narrowOop]. 97 template <bool nv, typename T, class OopClosureType, class Contains> 98 inline void oop_oop_iterate_ref_processing_specialized(oop obj, OopClosureType* closure, Contains& contains); 99 100 // Only perform reference processing if the referent object is within mr. 101 template <bool nv, class OopClosureType> 102 inline void oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr); 103 104 // Reference processing 105 template <bool nv, class OopClosureType> 106 inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure); 107 124 static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains); 125 126 // 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 128 // closure provides a ReferenceProcessor. 129 template <bool nv, typename T, class OopClosureType, class Contains> 130 static void oop_oop_iterate_discovered_and_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains); 131 132 // Apply the closure to all fields. No reference discovery is done. 133 template <bool nv, typename T, class OopClosureType, class Contains> 134 static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains); 135 136 template <typename T> 137 static void trace_reference_gc(const char *s, oop obj) NOT_DEBUG_RETURN; 138 139 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 150 // 'discovered' will look like non-oops 151 static void update_nonstatic_oop_maps(Klass* k); 152 153 public: 154 // Verification 155 void oop_verify_on(oop obj, outputStream* st); 156 }; 157 158 #endif // SHARE_VM_OOPS_INSTANCEREFKLASS_HPP |