src/share/vm/oops/instanceRefKlass.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 7090259 Sdiff src/share/vm/oops

src/share/vm/oops/instanceRefKlass.cpp

Print this page




  28 #include "gc_implementation/shared/markSweep.inline.hpp"
  29 #include "gc_interface/collectedHeap.hpp"
  30 #include "gc_interface/collectedHeap.inline.hpp"
  31 #include "memory/genCollectedHeap.hpp"
  32 #include "memory/genOopClosures.inline.hpp"
  33 #include "oops/instanceRefKlass.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "utilities/preserveException.hpp"
  36 #ifndef SERIALGC
  37 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  38 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  39 #include "gc_implementation/g1/g1RemSet.inline.hpp"
  40 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
  41 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
  42 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
  43 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
  44 #include "oops/oop.pcgc.inline.hpp"
  45 #endif
  46 
  47 template <class T>
  48 static void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
  49   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
  50   T heap_oop = oopDesc::load_heap_oop(referent_addr);
  51   debug_only(
  52     if(TraceReferenceGC && PrintGCDetails) {
  53       gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
  54     }
  55   )
  56   if (!oopDesc::is_null(heap_oop)) {
  57     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
  58     if (!referent->is_gc_marked() &&
  59         MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) {
  60       // reference was discovered, referent will be traversed later
  61       ref->instanceKlass::oop_follow_contents(obj);
  62       debug_only(
  63         if(TraceReferenceGC && PrintGCDetails) {
  64           gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
  65         }
  66       )
  67       return;
  68     } else {


  82     T  next_oop = oopDesc::load_heap_oop(next_addr);
  83     if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
  84       T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
  85       debug_only(
  86         if(TraceReferenceGC && PrintGCDetails) {
  87           gclog_or_tty->print_cr("   Process discovered as normal "
  88                                  INTPTR_FORMAT, discovered_addr);
  89         }
  90       )
  91       MarkSweep::mark_and_push(discovered_addr);
  92     }
  93   } else {
  94 #ifdef ASSERT
  95     // In the case of older JDKs which do not use the discovered
  96     // field for the pending list, an inactive ref (next != NULL)
  97     // must always have a NULL discovered field.
  98     oop next = oopDesc::load_decode_heap_oop(next_addr);
  99     oop discovered = java_lang_ref_Reference::discovered(obj);
 100     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
 101            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
 102                    obj));
 103 #endif
 104   }
 105   // treat next as normal oop.  next is a link in the reference queue.
 106   debug_only(
 107     if(TraceReferenceGC && PrintGCDetails) {
 108       gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
 109     }
 110   )
 111   MarkSweep::mark_and_push(next_addr);
 112   ref->instanceKlass::oop_follow_contents(obj);
 113 }
 114 
 115 void instanceRefKlass::oop_follow_contents(oop obj) {
 116   if (UseCompressedOops) {
 117     specialized_oop_follow_contents<narrowOop>(this, obj);
 118   } else {
 119     specialized_oop_follow_contents<oop>(this, obj);
 120   }
 121 }
 122 


 162     T  next_oop = oopDesc::load_heap_oop(next_addr);
 163     if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
 164       T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
 165       debug_only(
 166         if(TraceReferenceGC && PrintGCDetails) {
 167           gclog_or_tty->print_cr("   Process discovered as normal "
 168                                  INTPTR_FORMAT, discovered_addr);
 169         }
 170       )
 171       PSParallelCompact::mark_and_push(cm, discovered_addr);
 172     }
 173   } else {
 174 #ifdef ASSERT
 175     // In the case of older JDKs which do not use the discovered
 176     // field for the pending list, an inactive ref (next != NULL)
 177     // must always have a NULL discovered field.
 178     T next = oopDesc::load_heap_oop(next_addr);
 179     oop discovered = java_lang_ref_Reference::discovered(obj);
 180     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
 181            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
 182                    obj));
 183 #endif
 184   }
 185   PSParallelCompact::mark_and_push(cm, next_addr);
 186   ref->instanceKlass::oop_follow_contents(cm, obj);
 187 }
 188 
 189 void instanceRefKlass::oop_follow_contents(ParCompactionManager* cm,
 190                                            oop obj) {
 191   if (UseCompressedOops) {
 192     specialized_oop_follow_contents<narrowOop>(this, cm, obj);
 193   } else {
 194     specialized_oop_follow_contents<oop>(this, cm, obj);
 195   }
 196 }
 197 #endif // SERIALGC
 198 
 199 #ifdef ASSERT
 200 template <class T> void trace_reference_gc(const char *s, oop obj,
 201                                            T* referent_addr,
 202                                            T* next_addr,


 268     if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {                   \
 269         /* i.e. ref is not "active" */                                          \
 270       debug_only(                                                               \
 271         if(TraceReferenceGC && PrintGCDetails) {                                \
 272           gclog_or_tty->print_cr("   Process discovered as normal "             \
 273                                  INTPTR_FORMAT, disc_addr);                     \
 274         }                                                                       \
 275       )                                                                         \
 276       SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
 277       closure->do_oop##nv_suffix(disc_addr);                                    \
 278     }                                                                           \
 279   } else {                                                                      \
 280     /* In the case of older JDKs which do not use the discovered field for  */  \
 281     /* the pending list, an inactive ref (next != NULL) must always have a  */  \
 282     /* NULL discovered field. */                                                \
 283     debug_only(                                                                 \
 284       T next_oop = oopDesc::load_heap_oop(next_addr);                           \
 285       T disc_oop = oopDesc::load_heap_oop(disc_addr);                           \
 286       assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop),          \
 287            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL" \
 288                    "discovered field", obj));                                   \
 289     )                                                                           \
 290   }                                                                             \
 291   /* treat next as normal oop */                                                \
 292   if (contains(next_addr)) {                                                    \
 293     SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
 294     closure->do_oop##nv_suffix(next_addr);                                      \
 295   }                                                                             \
 296   return size;                                                                  \
 297 
 298 
 299 template <class T> bool contains(T *t) { return true; }
 300 
 301 // Macro to define instanceRefKlass::oop_oop_iterate for virtual/nonvirtual for
 302 // all closures.  Macros calling macros above for each oop size.
 303 
 304 #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)        \
 305                                                                                 \
 306 int instanceRefKlass::                                                          \
 307 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {                  \
 308   /* Get size before changing pointers */                                       \


 386       T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
 387       debug_only(
 388         if(TraceReferenceGC && PrintGCDetails) {
 389           gclog_or_tty->print_cr("   Process discovered as normal "
 390                                  INTPTR_FORMAT, discovered_addr);
 391         }
 392       )
 393       if (PSScavenge::should_scavenge(discovered_addr)) {
 394         pm->claim_or_forward_depth(discovered_addr);
 395       }
 396     }
 397   } else {
 398 #ifdef ASSERT
 399     // In the case of older JDKs which do not use the discovered
 400     // field for the pending list, an inactive ref (next != NULL)
 401     // must always have a NULL discovered field.
 402     oop next = oopDesc::load_decode_heap_oop(next_addr);
 403     oop discovered = java_lang_ref_Reference::discovered(obj);
 404     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
 405            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
 406                    obj));
 407 #endif
 408   }
 409 
 410   // Treat next as normal oop;  next is a link in the reference queue.
 411   if (PSScavenge::should_scavenge(next_addr)) {
 412     pm->claim_or_forward_depth(next_addr);
 413   }
 414   ref->instanceKlass::oop_push_contents(pm, obj);
 415 }
 416 
 417 void instanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
 418   if (UseCompressedOops) {
 419     specialized_oop_push_contents<narrowOop>(this, pm, obj);
 420   } else {
 421     specialized_oop_push_contents<oop>(this, pm, obj);
 422   }
 423 }
 424 
 425 template <class T>
 426 void specialized_oop_update_pointers(instanceRefKlass *ref,




  28 #include "gc_implementation/shared/markSweep.inline.hpp"
  29 #include "gc_interface/collectedHeap.hpp"
  30 #include "gc_interface/collectedHeap.inline.hpp"
  31 #include "memory/genCollectedHeap.hpp"
  32 #include "memory/genOopClosures.inline.hpp"
  33 #include "oops/instanceRefKlass.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "utilities/preserveException.hpp"
  36 #ifndef SERIALGC
  37 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
  38 #include "gc_implementation/g1/g1OopClosures.inline.hpp"
  39 #include "gc_implementation/g1/g1RemSet.inline.hpp"
  40 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
  41 #include "gc_implementation/parNew/parOopClosures.inline.hpp"
  42 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
  43 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
  44 #include "oops/oop.pcgc.inline.hpp"
  45 #endif
  46 
  47 template <class T>
  48 void specialized_oop_follow_contents(instanceRefKlass* ref, oop obj) {
  49   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
  50   T heap_oop = oopDesc::load_heap_oop(referent_addr);
  51   debug_only(
  52     if(TraceReferenceGC && PrintGCDetails) {
  53       gclog_or_tty->print_cr("instanceRefKlass::oop_follow_contents " INTPTR_FORMAT, obj);
  54     }
  55   )
  56   if (!oopDesc::is_null(heap_oop)) {
  57     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
  58     if (!referent->is_gc_marked() &&
  59         MarkSweep::ref_processor()->discover_reference(obj, ref->reference_type())) {
  60       // reference was discovered, referent will be traversed later
  61       ref->instanceKlass::oop_follow_contents(obj);
  62       debug_only(
  63         if(TraceReferenceGC && PrintGCDetails) {
  64           gclog_or_tty->print_cr("       Non NULL enqueued " INTPTR_FORMAT, obj);
  65         }
  66       )
  67       return;
  68     } else {


  82     T  next_oop = oopDesc::load_heap_oop(next_addr);
  83     if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
  84       T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
  85       debug_only(
  86         if(TraceReferenceGC && PrintGCDetails) {
  87           gclog_or_tty->print_cr("   Process discovered as normal "
  88                                  INTPTR_FORMAT, discovered_addr);
  89         }
  90       )
  91       MarkSweep::mark_and_push(discovered_addr);
  92     }
  93   } else {
  94 #ifdef ASSERT
  95     // In the case of older JDKs which do not use the discovered
  96     // field for the pending list, an inactive ref (next != NULL)
  97     // must always have a NULL discovered field.
  98     oop next = oopDesc::load_decode_heap_oop(next_addr);
  99     oop discovered = java_lang_ref_Reference::discovered(obj);
 100     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
 101            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
 102                    (oopDesc*)obj));
 103 #endif
 104   }
 105   // treat next as normal oop.  next is a link in the reference queue.
 106   debug_only(
 107     if(TraceReferenceGC && PrintGCDetails) {
 108       gclog_or_tty->print_cr("   Process next as normal " INTPTR_FORMAT, next_addr);
 109     }
 110   )
 111   MarkSweep::mark_and_push(next_addr);
 112   ref->instanceKlass::oop_follow_contents(obj);
 113 }
 114 
 115 void instanceRefKlass::oop_follow_contents(oop obj) {
 116   if (UseCompressedOops) {
 117     specialized_oop_follow_contents<narrowOop>(this, obj);
 118   } else {
 119     specialized_oop_follow_contents<oop>(this, obj);
 120   }
 121 }
 122 


 162     T  next_oop = oopDesc::load_heap_oop(next_addr);
 163     if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
 164       T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
 165       debug_only(
 166         if(TraceReferenceGC && PrintGCDetails) {
 167           gclog_or_tty->print_cr("   Process discovered as normal "
 168                                  INTPTR_FORMAT, discovered_addr);
 169         }
 170       )
 171       PSParallelCompact::mark_and_push(cm, discovered_addr);
 172     }
 173   } else {
 174 #ifdef ASSERT
 175     // In the case of older JDKs which do not use the discovered
 176     // field for the pending list, an inactive ref (next != NULL)
 177     // must always have a NULL discovered field.
 178     T next = oopDesc::load_heap_oop(next_addr);
 179     oop discovered = java_lang_ref_Reference::discovered(obj);
 180     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
 181            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
 182                    (oopDesc*)obj));
 183 #endif
 184   }
 185   PSParallelCompact::mark_and_push(cm, next_addr);
 186   ref->instanceKlass::oop_follow_contents(cm, obj);
 187 }
 188 
 189 void instanceRefKlass::oop_follow_contents(ParCompactionManager* cm,
 190                                            oop obj) {
 191   if (UseCompressedOops) {
 192     specialized_oop_follow_contents<narrowOop>(this, cm, obj);
 193   } else {
 194     specialized_oop_follow_contents<oop>(this, cm, obj);
 195   }
 196 }
 197 #endif // SERIALGC
 198 
 199 #ifdef ASSERT
 200 template <class T> void trace_reference_gc(const char *s, oop obj,
 201                                            T* referent_addr,
 202                                            T* next_addr,


 268     if (!oopDesc::is_null(next_oop) && contains(disc_addr)) {                   \
 269         /* i.e. ref is not "active" */                                          \
 270       debug_only(                                                               \
 271         if(TraceReferenceGC && PrintGCDetails) {                                \
 272           gclog_or_tty->print_cr("   Process discovered as normal "             \
 273                                  INTPTR_FORMAT, disc_addr);                     \
 274         }                                                                       \
 275       )                                                                         \
 276       SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk);\
 277       closure->do_oop##nv_suffix(disc_addr);                                    \
 278     }                                                                           \
 279   } else {                                                                      \
 280     /* In the case of older JDKs which do not use the discovered field for  */  \
 281     /* the pending list, an inactive ref (next != NULL) must always have a  */  \
 282     /* NULL discovered field. */                                                \
 283     debug_only(                                                                 \
 284       T next_oop = oopDesc::load_heap_oop(next_addr);                           \
 285       T disc_oop = oopDesc::load_heap_oop(disc_addr);                           \
 286       assert(oopDesc::is_null(next_oop) || oopDesc::is_null(disc_oop),          \
 287            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL" \
 288                    "discovered field", (oopDesc*)obj));                                   \
 289     )                                                                           \
 290   }                                                                             \
 291   /* treat next as normal oop */                                                \
 292   if (contains(next_addr)) {                                                    \
 293     SpecializationStats::record_do_oop_call##nv_suffix(SpecializationStats::irk); \
 294     closure->do_oop##nv_suffix(next_addr);                                      \
 295   }                                                                             \
 296   return size;                                                                  \
 297 
 298 
 299 template <class T> bool contains(T *t) { return true; }
 300 
 301 // Macro to define instanceRefKlass::oop_oop_iterate for virtual/nonvirtual for
 302 // all closures.  Macros calling macros above for each oop size.
 303 
 304 #define InstanceRefKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)        \
 305                                                                                 \
 306 int instanceRefKlass::                                                          \
 307 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {                  \
 308   /* Get size before changing pointers */                                       \


 386       T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
 387       debug_only(
 388         if(TraceReferenceGC && PrintGCDetails) {
 389           gclog_or_tty->print_cr("   Process discovered as normal "
 390                                  INTPTR_FORMAT, discovered_addr);
 391         }
 392       )
 393       if (PSScavenge::should_scavenge(discovered_addr)) {
 394         pm->claim_or_forward_depth(discovered_addr);
 395       }
 396     }
 397   } else {
 398 #ifdef ASSERT
 399     // In the case of older JDKs which do not use the discovered
 400     // field for the pending list, an inactive ref (next != NULL)
 401     // must always have a NULL discovered field.
 402     oop next = oopDesc::load_decode_heap_oop(next_addr);
 403     oop discovered = java_lang_ref_Reference::discovered(obj);
 404     assert(oopDesc::is_null(next) || oopDesc::is_null(discovered),
 405            err_msg("Found an inactive reference " PTR_FORMAT " with a non-NULL discovered field",
 406                    (oopDesc*)obj));
 407 #endif
 408   }
 409 
 410   // Treat next as normal oop;  next is a link in the reference queue.
 411   if (PSScavenge::should_scavenge(next_addr)) {
 412     pm->claim_or_forward_depth(next_addr);
 413   }
 414   ref->instanceKlass::oop_push_contents(pm, obj);
 415 }
 416 
 417 void instanceRefKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
 418   if (UseCompressedOops) {
 419     specialized_oop_push_contents<narrowOop>(this, pm, obj);
 420   } else {
 421     specialized_oop_push_contents<oop>(this, pm, obj);
 422   }
 423 }
 424 
 425 template <class T>
 426 void specialized_oop_update_pointers(instanceRefKlass *ref,


src/share/vm/oops/instanceRefKlass.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File