< prev index next >

src/hotspot/share/gc/cms/parOopClosures.inline.hpp

Print this page




  27 
  28 #include "gc/cms/cmsHeap.hpp"
  29 #include "gc/cms/parNewGeneration.hpp"
  30 #include "gc/cms/parOopClosures.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genOopClosures.inline.hpp"
  33 #include "logging/log.hpp"
  34 #include "logging/logStream.hpp"
  35 #include "oops/access.inline.hpp"
  36 #include "oops/compressedOops.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 
  39 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
  40   oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
  41   // weak references are sometimes scanned twice; must check
  42   // that to-space doesn't already contain this object
  43   if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
  44     // we need to ensure that it is copied (see comment in
  45     // ParScanClosure::do_oop_work).
  46     Klass* objK = obj->klass();
  47     markWord m = obj->mark_raw();
  48     oop new_obj;
  49     if (m.is_marked()) { // Contains forwarding pointer.
  50       new_obj = ParNewGeneration::real_forwardee(obj);
  51     } else {
  52       size_t obj_sz = obj->size_given_klass(objK);
  53       new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
  54                                                                 obj, obj_sz, m);
  55     }
  56     RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
  57   }
  58 }
  59 
  60 inline void ParScanWeakRefClosure::do_oop(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
  61 inline void ParScanWeakRefClosure::do_oop(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
  62 
  63 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
  64   assert(generation()->is_in_reserved(p), "expected ref in generation");
  65   oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
  66   // If p points to a younger generation, mark the card.
  67   if ((HeapWord*)obj < gen_boundary()) {
  68     rs()->write_ref_field_gc_par(p, obj);
  69   }


  91         oop obj = oop(sp->block_start(p));
  92         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  93         log.error("Object: " PTR_FORMAT, p2i((void *)obj));
  94         log.error("-------");
  95         LogStream ls(log.error());
  96         obj->print_on(&ls);
  97         log.error("-----");
  98         log.error("Heap:");
  99         log.error("-----");
 100         heap->print_on(&ls);
 101         ShouldNotReachHere();
 102       }
 103 #endif
 104       // OK, we need to ensure that it is copied.
 105       // We read the klass and mark in this order, so that we can reliably
 106       // get the size of the object: if the mark we read is not a
 107       // forwarding pointer, then the klass is valid: the klass is only
 108       // overwritten with an overflow next pointer after the object is
 109       // forwarded.
 110       Klass* objK = obj->klass();
 111       markWord m = obj->mark_raw();
 112       oop new_obj;
 113       if (m.is_marked()) { // Contains forwarding pointer.
 114         new_obj = ParNewGeneration::real_forwardee(obj);
 115         RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
 116         log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
 117                                         "forwarded ",
 118                                         new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
 119       } else {
 120         size_t obj_sz = obj->size_given_klass(objK);
 121         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
 122         RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
 123         if (root_scan) {
 124           // This may have pushed an object.  If we have a root
 125           // category with a lot of roots, can't let the queue get too
 126           // full:
 127           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 128         }
 129       }
 130       if (is_scanning_a_cld()) {
 131         do_cld_barrier();
 132       } else if (gc_barrier) {
 133         // Now call parent closure


  27 
  28 #include "gc/cms/cmsHeap.hpp"
  29 #include "gc/cms/parNewGeneration.hpp"
  30 #include "gc/cms/parOopClosures.hpp"
  31 #include "gc/shared/cardTableRS.hpp"
  32 #include "gc/shared/genOopClosures.inline.hpp"
  33 #include "logging/log.hpp"
  34 #include "logging/logStream.hpp"
  35 #include "oops/access.inline.hpp"
  36 #include "oops/compressedOops.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 
  39 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
  40   oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
  41   // weak references are sometimes scanned twice; must check
  42   // that to-space doesn't already contain this object
  43   if ((HeapWord*)obj < _boundary && !_g->to()->is_in_reserved(obj)) {
  44     // we need to ensure that it is copied (see comment in
  45     // ParScanClosure::do_oop_work).
  46     Klass* objK = obj->klass();
  47     markOop m = obj->mark_raw();
  48     oop new_obj;
  49     if (m->is_marked()) { // Contains forwarding pointer.
  50       new_obj = ParNewGeneration::real_forwardee(obj);
  51     } else {
  52       size_t obj_sz = obj->size_given_klass(objK);
  53       new_obj = ((ParNewGeneration*)_g)->copy_to_survivor_space(_par_scan_state,
  54                                                                 obj, obj_sz, m);
  55     }
  56     RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
  57   }
  58 }
  59 
  60 inline void ParScanWeakRefClosure::do_oop(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
  61 inline void ParScanWeakRefClosure::do_oop(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
  62 
  63 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
  64   assert(generation()->is_in_reserved(p), "expected ref in generation");
  65   oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
  66   // If p points to a younger generation, mark the card.
  67   if ((HeapWord*)obj < gen_boundary()) {
  68     rs()->write_ref_field_gc_par(p, obj);
  69   }


  91         oop obj = oop(sp->block_start(p));
  92         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  93         log.error("Object: " PTR_FORMAT, p2i((void *)obj));
  94         log.error("-------");
  95         LogStream ls(log.error());
  96         obj->print_on(&ls);
  97         log.error("-----");
  98         log.error("Heap:");
  99         log.error("-----");
 100         heap->print_on(&ls);
 101         ShouldNotReachHere();
 102       }
 103 #endif
 104       // OK, we need to ensure that it is copied.
 105       // We read the klass and mark in this order, so that we can reliably
 106       // get the size of the object: if the mark we read is not a
 107       // forwarding pointer, then the klass is valid: the klass is only
 108       // overwritten with an overflow next pointer after the object is
 109       // forwarded.
 110       Klass* objK = obj->klass();
 111       markOop m = obj->mark_raw();
 112       oop new_obj;
 113       if (m->is_marked()) { // Contains forwarding pointer.
 114         new_obj = ParNewGeneration::real_forwardee(obj);
 115         RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
 116         log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
 117                                         "forwarded ",
 118                                         new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
 119       } else {
 120         size_t obj_sz = obj->size_given_klass(objK);
 121         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
 122         RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);
 123         if (root_scan) {
 124           // This may have pushed an object.  If we have a root
 125           // category with a lot of roots, can't let the queue get too
 126           // full:
 127           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 128         }
 129       }
 130       if (is_scanning_a_cld()) {
 131         do_cld_barrier();
 132       } else if (gc_barrier) {
 133         // Now call parent closure
< prev index next >