src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/gc_implementation/parNew

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

Print this page




  62   if ((HeapWord*)obj < gen_boundary()) {
  63     rs()->write_ref_field_gc_par(p, obj);
  64   }
  65 }
  66 
  67 template <class T>
  68 inline void ParScanClosure::do_oop_work(T* p,
  69                                         bool gc_barrier,
  70                                         bool root_scan) {
  71   assert((!Universe::heap()->is_in_reserved(p) ||
  72           generation()->is_in_reserved(p))
  73          && (generation()->level() == 0 || gc_barrier),
  74          "The gen must be right, and we must be doing the barrier "
  75          "in older generations.");
  76   T heap_oop = oopDesc::load_heap_oop(p);
  77   if (!oopDesc::is_null(heap_oop)) {
  78     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  79     if ((HeapWord*)obj < _boundary) {
  80 #ifndef PRODUCT
  81       if (_g->to()->is_in_reserved(obj)) {
  82         tty->print_cr("Scanning field (" PTR_FORMAT ") twice?", p);
  83         GenCollectedHeap* gch =  (GenCollectedHeap*)Universe::heap();
  84         Space* sp = gch->space_containing(p);
  85         oop obj = oop(sp->block_start(p));
  86         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  87         tty->print_cr("Object: " PTR_FORMAT, (void *)obj);
  88         tty->print_cr("-------");
  89         obj->print();
  90         tty->print_cr("-----");
  91         tty->print_cr("Heap:");
  92         tty->print_cr("-----");
  93         gch->print();
  94         ShouldNotReachHere();
  95       }
  96 #endif
  97       // OK, we need to ensure that it is copied.
  98       // We read the klass and mark in this order, so that we can reliably
  99       // get the size of the object: if the mark we read is not a
 100       // forwarding pointer, then the klass is valid: the klass is only
 101       // overwritten with an overflow next pointer after the object is
 102       // forwarded.
 103       Klass* objK = obj->klass();
 104       markOop m = obj->mark();
 105       oop new_obj;
 106       if (m->is_marked()) { // Contains forwarding pointer.
 107         new_obj = ParNewGeneration::real_forwardee(obj);
 108         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 109 #ifndef PRODUCT
 110         if (TraceScavenge) {
 111           gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
 112              "forwarded ",
 113              new_obj->klass()->internal_name(), p, (void *)obj, (void *)new_obj, new_obj->size());
 114         }
 115 #endif
 116 
 117       } else {
 118         size_t obj_sz = obj->size_given_klass(objK);
 119         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
 120         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 121         if (root_scan) {
 122           // This may have pushed an object.  If we have a root
 123           // category with a lot of roots, can't let the queue get too
 124           // full:
 125           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 126         }
 127       }
 128       if (is_scanning_a_klass()) {
 129         do_klass_barrier();
 130       } else if (gc_barrier) {
 131         // Now call parent closure
 132         par_do_barrier(p);
 133       }


  62   if ((HeapWord*)obj < gen_boundary()) {
  63     rs()->write_ref_field_gc_par(p, obj);
  64   }
  65 }
  66 
  67 template <class T>
  68 inline void ParScanClosure::do_oop_work(T* p,
  69                                         bool gc_barrier,
  70                                         bool root_scan) {
  71   assert((!Universe::heap()->is_in_reserved(p) ||
  72           generation()->is_in_reserved(p))
  73          && (generation()->level() == 0 || gc_barrier),
  74          "The gen must be right, and we must be doing the barrier "
  75          "in older generations.");
  76   T heap_oop = oopDesc::load_heap_oop(p);
  77   if (!oopDesc::is_null(heap_oop)) {
  78     oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  79     if ((HeapWord*)obj < _boundary) {
  80 #ifndef PRODUCT
  81       if (_g->to()->is_in_reserved(obj)) {
  82         tty->print_cr("Scanning field (" PTR_FORMAT ") twice?", p2i(p));
  83         GenCollectedHeap* gch =  (GenCollectedHeap*)Universe::heap();
  84         Space* sp = gch->space_containing(p);
  85         oop obj = oop(sp->block_start(p));
  86         assert((HeapWord*)obj < (HeapWord*)p, "Error");
  87         tty->print_cr("Object: " PTR_FORMAT, p2i((void *)obj));
  88         tty->print_cr("-------");
  89         obj->print();
  90         tty->print_cr("-----");
  91         tty->print_cr("Heap:");
  92         tty->print_cr("-----");
  93         gch->print();
  94         ShouldNotReachHere();
  95       }
  96 #endif
  97       // OK, we need to ensure that it is copied.
  98       // We read the klass and mark in this order, so that we can reliably
  99       // get the size of the object: if the mark we read is not a
 100       // forwarding pointer, then the klass is valid: the klass is only
 101       // overwritten with an overflow next pointer after the object is
 102       // forwarded.
 103       Klass* objK = obj->klass();
 104       markOop m = obj->mark();
 105       oop new_obj;
 106       if (m->is_marked()) { // Contains forwarding pointer.
 107         new_obj = ParNewGeneration::real_forwardee(obj);
 108         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 109 #ifndef PRODUCT
 110         if (TraceScavenge) {
 111           gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
 112              "forwarded ",
 113              new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
 114         }
 115 #endif
 116 
 117       } else {
 118         size_t obj_sz = obj->size_given_klass(objK);
 119         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
 120         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
 121         if (root_scan) {
 122           // This may have pushed an object.  If we have a root
 123           // category with a lot of roots, can't let the queue get too
 124           // full:
 125           (void)_par_scan_state->trim_queues(10 * ParallelGCThreads);
 126         }
 127       }
 128       if (is_scanning_a_klass()) {
 129         do_klass_barrier();
 130       } else if (gc_barrier) {
 131         // Now call parent closure
 132         par_do_barrier(p);
 133       }
src/share/vm/gc_implementation/parNew/parOopClosures.inline.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File