< prev index next >

src/share/vm/oops/instanceRefKlass.hpp

Print this page
rev 12851 : 8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
Reviewed-by:
rev 12852 : [mq]: 8138737-remove-oop-ms-adjust-kbarrett-rev1
   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  33 
  34 // An InstanceRefKlass is a specialized InstanceKlass for Java
  35 // classes that are subclasses of java/lang/ref/Reference.
  36 //
  37 // These classes are used to implement soft/weak/final/phantom
  38 // references and finalization, and need special treatment by the
  39 // garbage collector.
  40 //
  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   template <bool nv, typename T, class OopClosureType, class Contains>
  54   friend class InstanceRefKlassSpecialized;
  55  private:
  56   InstanceRefKlass(const ClassFileParser& parser) : InstanceKlass(parser, InstanceKlass::_misc_kind_reference) {}
  57 
  58  public:
  59   InstanceRefKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
  60 
  61   // GC specific object visitors
  62   //
  63 #if INCLUDE_ALL_GCS
  64   // Parallel Scavenge
  65   void oop_ps_push_contents(  oop obj, PSPromotionManager* pm);
  66   // Parallel Compact
  67   void oop_pc_follow_contents(oop obj, ParCompactionManager* cm);
  68   void oop_pc_update_pointers(oop obj, ParCompactionManager* cm);
  69 #endif
  70 
  71   // Oop fields (and metadata) iterators
  72   //  [nv = true]  Use non-virtual calls to do_oop_nv.
  73   //  [nv = false] Use virtual calls to do_oop.
  74   //


 103   template <bool nv, class OopClosureType>
 104   inline void oop_oop_iterate_ref_processing_bounded(oop obj, OopClosureType* closure, MemRegion mr);
 105 
 106   // Reference processing
 107   template <bool nv, class OopClosureType>
 108   inline void oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure);
 109 
 110   // Building blocks for specialized handling.
 111   template <bool nv, typename T, class OopClosureType, class Contains>
 112   static void do_referent(oop obj, OopClosureType* closure, Contains& contains);
 113 
 114   template <bool nv, typename T, class OopClosureType, class Contains>
 115   static void do_next(oop obj, OopClosureType* closure, Contains& contains);
 116 
 117   template <bool nv, typename T, class OopClosureType, class Contains>
 118   static void do_discovered(oop obj, OopClosureType* closure, Contains& contains);
 119 
 120   template <typename T, class OopClosureType>
 121   static bool try_discover(oop obj, ReferenceType type, OopClosureType* closure);
 122 
 123   // Default way of handling instance ref klasses, does reference
 124   // processing if a ReferenceProcessor has been supplied.
 125   template <bool nv, typename T, class OopClosureType, class Contains>
 126   static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains);
 127 
 128   // Just handle the fields, don't care about reference processing.
 129   template <bool nv, typename T, class OopClosureType, class Contains>
 130   static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains);
 131 
 132 #ifdef ASSERT
 133   template <typename T>
 134   static void trace_reference_gc(const char *s, oop obj, T* referent_addr, T* next_addr, T* discovered_addr);
 135 #endif
 136 
 137  public:
 138 
 139   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
 140   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
 141 
 142 #if INCLUDE_ALL_GCS
 143   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
 144   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
 145 #endif // INCLUDE_ALL_GCS
 146 
 147   // Update non-static oop maps so 'referent', 'nextPending' and
 148   // 'discovered' will look like non-oops
 149   static void update_nonstatic_oop_maps(Klass* k);
 150 
 151  public:
 152   // Verification
 153   void oop_verify_on(oop obj, outputStream* st);
 154 };
 155 
   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  33 
  34 // An InstanceRefKlass is a specialized InstanceKlass for Java
  35 // classes that are subclasses of java/lang/ref/Reference.
  36 //
  37 // These classes are used to implement soft/weak/final/phantom
  38 // references and finalization, and need special treatment by the
  39 // garbage collector.
  40 //
  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   //


 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 
 108   // Building blocks for specialized handling.
 109   template <bool nv, typename T, class OopClosureType, class Contains>
 110   static void do_referent(oop obj, OopClosureType* closure, Contains& contains);
 111 
 112   template <bool nv, typename T, class OopClosureType, class Contains>
 113   static void do_next(oop obj, OopClosureType* closure, Contains& contains);
 114 
 115   template <bool nv, typename T, class OopClosureType, class Contains>
 116   static void do_discovered(oop obj, OopClosureType* closure, Contains& contains);
 117 
 118   template <typename T, class OopClosureType>
 119   static bool try_discover(oop obj, ReferenceType type, OopClosureType* closure);
 120 
 121   // Do discovery while handling instance ref klasses, does reference
 122   // processing only if a ReferenceProcessor has been supplied.
 123   template <bool nv, typename T, class OopClosureType, class Contains>
 124   static void oop_oop_iterate_discovery(oop obj, ReferenceType type, OopClosureType* closure, Contains& contains);
 125 
 126   // Handle the fields, don't care about reference processing.
 127   template <bool nv, typename T, class OopClosureType, class Contains>
 128   static void oop_oop_iterate_fields(oop obj, OopClosureType* closure, Contains& contains);
 129 

 130   template <typename T>
 131   static void trace_reference_gc(const char *s, oop obj, T* referent_addr, T* next_addr, T* discovered_addr) NOT_DEBUG_RETURN;

 132 
 133  public:
 134 
 135   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL)
 136   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL)
 137 
 138 #if INCLUDE_ALL_GCS
 139   ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_OOP_ITERATE_DECL_BACKWARDS)
 140   ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_OOP_ITERATE_DECL_BACKWARDS)
 141 #endif // INCLUDE_ALL_GCS
 142 
 143   // Update non-static oop maps so 'referent', 'nextPending' and
 144   // 'discovered' will look like non-oops
 145   static void update_nonstatic_oop_maps(Klass* k);
 146 
 147  public:
 148   // Verification
 149   void oop_verify_on(oop obj, outputStream* st);
 150 };
 151 
< prev index next >