< prev index next >

src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp

Print this page
rev 8070 : imported patch gencollected_heap_cleanup


  53   }
  54 }
  55 
  56 inline void ParScanWeakRefClosure::do_oop_nv(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
  57 inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
  58 
  59 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
  60   assert(generation()->is_in_reserved(p), "expected ref in generation");
  61   assert(!oopDesc::is_null(*p), "expected non-null object");
  62   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  63   // If p points to a younger generation, mark the card.
  64   if ((HeapWord*)obj < gen_boundary()) {
  65     rs()->write_ref_field_gc_par(p, obj);
  66   }
  67 }
  68 
  69 template <class T>
  70 inline void ParScanClosure::do_oop_work(T* p,
  71                                         bool gc_barrier,
  72                                         bool root_scan) {
  73   assert((!Universe::heap()->is_in_reserved(p) ||
  74           generation()->is_in_reserved(p))
  75          && (generation()->level() == 0 || gc_barrier),
  76          "The gen must be right, and we must be doing the barrier "
  77          "in older generations.");
  78   T heap_oop = oopDesc::load_heap_oop(p);
  79   if (!oopDesc::is_null(heap_oop)) {
  80     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  81     if ((HeapWord*)obj < _boundary) {
  82 #ifndef PRODUCT
  83       if (_g->to()->is_in_reserved(obj)) {
  84         tty->print_cr("Scanning field (" PTR_FORMAT ") twice?", p2i(p));
  85         GenCollectedHeap* gch =  (GenCollectedHeap*)Universe::heap();
  86         Space* sp = gch->space_containing(p);
  87         oop obj = oop(sp->block_start(p));
  88         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  89         tty->print_cr("Object: " PTR_FORMAT, p2i((void *)obj));
  90         tty->print_cr("-------");
  91         obj->print();
  92         tty->print_cr("-----");
  93         tty->print_cr("Heap:");
  94         tty->print_cr("-----");
  95         gch->print();
  96         ShouldNotReachHere();
  97       }
  98 #endif
  99       // OK, we need to ensure that it is copied.
 100       // We read the klass and mark in this order, so that we can reliably
 101       // get the size of the object: if the mark we read is not a
 102       // forwarding pointer, then the klass is valid: the klass is only
 103       // overwritten with an overflow next pointer after the object is
 104       // forwarded.
 105       Klass* objK = obj->klass();




  53   }
  54 }
  55 
  56 inline void ParScanWeakRefClosure::do_oop_nv(oop* p)       { ParScanWeakRefClosure::do_oop_work(p); }
  57 inline void ParScanWeakRefClosure::do_oop_nv(narrowOop* p) { ParScanWeakRefClosure::do_oop_work(p); }
  58 
  59 template <class T> inline void ParScanClosure::par_do_barrier(T* p) {
  60   assert(generation()->is_in_reserved(p), "expected ref in generation");
  61   assert(!oopDesc::is_null(*p), "expected non-null object");
  62   oop obj = oopDesc::load_decode_heap_oop_not_null(p);
  63   // If p points to a younger generation, mark the card.
  64   if ((HeapWord*)obj < gen_boundary()) {
  65     rs()->write_ref_field_gc_par(p, obj);
  66   }
  67 }
  68 
  69 template <class T>
  70 inline void ParScanClosure::do_oop_work(T* p,
  71                                         bool gc_barrier,
  72                                         bool root_scan) {
  73   assert((!GenCollectedHeap::heap()->is_in_reserved(p) ||
  74           generation()->is_in_reserved(p))
  75          && (generation()->level() == 0 || gc_barrier),
  76          "The gen must be right, and we must be doing the barrier "
  77          "in older generations.");
  78   T heap_oop = oopDesc::load_heap_oop(p);
  79   if (!oopDesc::is_null(heap_oop)) {
  80     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  81     if ((HeapWord*)obj < _boundary) {
  82 #ifndef PRODUCT
  83       if (_g->to()->is_in_reserved(obj)) {
  84         tty->print_cr("Scanning field (" PTR_FORMAT ") twice?", p2i(p));
  85         GenCollectedHeap* gch = GenCollectedHeap::heap();
  86         Space* sp = gch->space_containing(p);
  87         oop obj = oop(sp->block_start(p));
  88         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  89         tty->print_cr("Object: " PTR_FORMAT, p2i((void *)obj));
  90         tty->print_cr("-------");
  91         obj->print();
  92         tty->print_cr("-----");
  93         tty->print_cr("Heap:");
  94         tty->print_cr("-----");
  95         gch->print();
  96         ShouldNotReachHere();
  97       }
  98 #endif
  99       // OK, we need to ensure that it is copied.
 100       // We read the klass and mark in this order, so that we can reliably
 101       // get the size of the object: if the mark we read is not a
 102       // forwarding pointer, then the klass is valid: the klass is only
 103       // overwritten with an overflow next pointer after the object is
 104       // forwarded.
 105       Klass* objK = obj->klass();


< prev index next >