< prev index next >

src/share/vm/oops/instanceRefKlass.inline.hpp

Print this page




  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  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP
  26 #define SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP
  27 
  28 #include "classfile/javaClasses.hpp"
  29 #include "gc/shared/referenceProcessor.hpp"

  30 #include "oops/instanceKlass.inline.hpp"
  31 #include "oops/instanceRefKlass.hpp"
  32 #include "oops/oop.inline.hpp"
  33 #include "utilities/debug.hpp"
  34 #include "utilities/globalDefinitions.hpp"
  35 #include "utilities/macros.hpp"
  36 
  37 template <bool nv, typename T, class OopClosureType, class Contains>
  38 void InstanceRefKlass::oop_oop_iterate_ref_processing_specialized(oop obj, OopClosureType* closure, Contains& contains) {
  39   T* disc_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
  40   if (closure->apply_to_weak_ref_discovered_field()) {
  41     Devirtualizer<nv>::do_oop(closure, disc_addr);
  42   }
  43 
  44   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
  45   T heap_oop = oopDesc::load_heap_oop(referent_addr);
  46   ReferenceProcessor* rp = closure->ref_processor();
  47   if (!oopDesc::is_null(heap_oop)) {
  48     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
  49     if (!referent->is_gc_marked() && (rp != NULL) &&
  50         rp->discover_reference(obj, reference_type())) {
  51       return;
  52     } else if (contains(referent_addr)) {
  53       // treat referent as normal oop
  54       Devirtualizer<nv>::do_oop(closure, referent_addr);
  55     }
  56   }
  57   T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
  58   T next_oop  = oopDesc::load_heap_oop(next_addr);
  59   // Treat discovered as normal oop, if ref is not "active" (next non-NULL)
  60   if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {
  61     // i.e. ref is not "active"
  62     debug_only(
  63       if(TraceReferenceGC && PrintGCDetails) {
  64         gclog_or_tty->print_cr("   Process discovered as normal "
  65                                PTR_FORMAT, p2i(disc_addr));
  66       }
  67     )
  68     Devirtualizer<nv>::do_oop(closure, disc_addr);
  69   }
  70   // treat next as normal oop
  71   if (contains(next_addr)) {
  72     Devirtualizer<nv>::do_oop(closure, next_addr);
  73   }
  74 }
  75 
  76 class AlwaysContains {
  77  public:
  78   template <typename T> bool operator()(T* p) const { return true; }
  79 };
  80 
  81 template <bool nv, class OopClosureType>
  82 void InstanceRefKlass::oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure) {
  83   AlwaysContains always_contains;
  84   if (UseCompressedOops) {
  85     oop_oop_iterate_ref_processing_specialized<nv, narrowOop>(obj, closure, always_contains);
  86   } else {
  87     oop_oop_iterate_ref_processing_specialized<nv, oop>(obj, closure, always_contains);




  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  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP
  26 #define SHARE_VM_OOPS_INSTANCEREFKLASS_INLINE_HPP
  27 
  28 #include "classfile/javaClasses.hpp"
  29 #include "gc/shared/referenceProcessor.hpp"
  30 #include "logging/log.hpp"
  31 #include "oops/instanceKlass.inline.hpp"
  32 #include "oops/instanceRefKlass.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "utilities/debug.hpp"
  35 #include "utilities/globalDefinitions.hpp"
  36 #include "utilities/macros.hpp"
  37 
  38 template <bool nv, typename T, class OopClosureType, class Contains>
  39 void InstanceRefKlass::oop_oop_iterate_ref_processing_specialized(oop obj, OopClosureType* closure, Contains& contains) {
  40   T* disc_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
  41   if (closure->apply_to_weak_ref_discovered_field()) {
  42     Devirtualizer<nv>::do_oop(closure, disc_addr);
  43   }
  44 
  45   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
  46   T heap_oop = oopDesc::load_heap_oop(referent_addr);
  47   ReferenceProcessor* rp = closure->ref_processor();
  48   if (!oopDesc::is_null(heap_oop)) {
  49     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
  50     if (!referent->is_gc_marked() && (rp != NULL) &&
  51         rp->discover_reference(obj, reference_type())) {
  52       return;
  53     } else if (contains(referent_addr)) {
  54       // treat referent as normal oop
  55       Devirtualizer<nv>::do_oop(closure, referent_addr);
  56     }
  57   }
  58   T* next_addr = (T*)java_lang_ref_Reference::next_addr(obj);
  59   T next_oop  = oopDesc::load_heap_oop(next_addr);
  60   // Treat discovered as normal oop, if ref is not "active" (next non-NULL)
  61   if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {
  62     // i.e. ref is not "active"
  63     log_develop_trace(gc, ref)("   Process discovered as normal " PTR_FORMAT, p2i(disc_addr));





  64     Devirtualizer<nv>::do_oop(closure, disc_addr);
  65   }
  66   // treat next as normal oop
  67   if (contains(next_addr)) {
  68     Devirtualizer<nv>::do_oop(closure, next_addr);
  69   }
  70 }
  71 
  72 class AlwaysContains {
  73  public:
  74   template <typename T> bool operator()(T* p) const { return true; }
  75 };
  76 
  77 template <bool nv, class OopClosureType>
  78 void InstanceRefKlass::oop_oop_iterate_ref_processing(oop obj, OopClosureType* closure) {
  79   AlwaysContains always_contains;
  80   if (UseCompressedOops) {
  81     oop_oop_iterate_ref_processing_specialized<nv, narrowOop>(obj, closure, always_contains);
  82   } else {
  83     oop_oop_iterate_ref_processing_specialized<nv, oop>(obj, closure, always_contains);


< prev index next >