< prev index next >

src/share/vm/gc_implementation/g1/heapRegion.cpp

Print this page
rev 7697 : imported patch 8069760-remove-duplicate-oop_iterate


 418   assert(cur <= start, "Postcondition");
 419 
 420   oop obj;
 421 
 422   HeapWord* next = cur;
 423   while (next <= start) {
 424     cur = next;
 425     obj = oop(cur);
 426     if (obj->klass_or_null() == NULL) {
 427       // Ran into an unparseable point.
 428       return cur;
 429     }
 430     // Otherwise...
 431     next = cur + block_size(cur);
 432   }
 433 
 434   // If we finish the above loop...We have a parseable object that
 435   // begins on or before the start of the memory region, and ends
 436   // inside or spans the entire region.
 437 
 438   assert(obj == oop(cur), "sanity");
 439   assert(cur <= start, "Loop postcondition");
 440   assert(obj->klass_or_null() != NULL, "Loop postcondition");
 441   assert((cur + block_size(cur)) > start, "Loop postcondition");
 442 
 443   if (!g1h->is_obj_dead(obj)) {
 444     obj->oop_iterate(cl, mr);
 445   }
 446 
 447   while (cur < end) {
 448     obj = oop(cur);
 449     if (obj->klass_or_null() == NULL) {
 450       // Ran into an unparseable point.
 451       return cur;
 452     };
 453 
 454     // Otherwise:
 455     next = cur + block_size(cur);
 456 
 457     if (!g1h->is_obj_dead(obj)) {
 458       if (next < end || !obj->is_objArray()) {
 459         // This object either does not span the MemRegion
 460         // boundary, or if it does it's not an array.
 461         // Apply closure to whole object.

 462         obj->oop_iterate(cl);
 463       } else {
 464         // This obj is an array that spans the boundary.
 465         // Stop at the boundary.
 466         obj->oop_iterate(cl, mr);
 467       }
 468     }
 469     cur = next;
 470   }

 471   return NULL;
 472 }
 473 
 474 // Code roots support
 475 
 476 void HeapRegion::add_strong_code_root(nmethod* nm) {
 477   HeapRegionRemSet* hrrs = rem_set();
 478   hrrs->add_strong_code_root(nm);
 479 }
 480 
 481 void HeapRegion::add_strong_code_root_locked(nmethod* nm) {
 482   assert_locked_or_safepoint(CodeCache_lock);
 483   HeapRegionRemSet* hrrs = rem_set();
 484   hrrs->add_strong_code_root_locked(nm);
 485 }
 486 
 487 void HeapRegion::remove_strong_code_root(nmethod* nm) {
 488   HeapRegionRemSet* hrrs = rem_set();
 489   hrrs->remove_strong_code_root(nm);
 490 }


 663   }
 664 
 665   bool failures() { return _failures; }
 666   int n_failures() { return _n_failures; }
 667 
 668   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 669   virtual void do_oop(      oop* p) { do_oop_work(p); }
 670 
 671   void print_object(outputStream* out, oop obj) {
 672 #ifdef PRODUCT
 673     Klass* k = obj->klass();
 674     const char* class_name = InstanceKlass::cast(k)->external_name();
 675     out->print_cr("class name %s", class_name);
 676 #else // PRODUCT
 677     obj->print_on(out);
 678 #endif // PRODUCT
 679   }
 680 
 681   template <class T>
 682   void do_oop_work(T* p) {

 683     assert(_containing_obj != NULL, "Precondition");
 684     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
 685            "Precondition");
 686     T heap_oop = oopDesc::load_heap_oop(p);
 687     if (!oopDesc::is_null(heap_oop)) {
 688       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 689       bool failed = false;
 690       if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
 691         MutexLockerEx x(ParGCRareEvent_lock,
 692                         Mutex::_no_safepoint_check_flag);
 693 
 694         if (!_failures) {
 695           gclog_or_tty->cr();
 696           gclog_or_tty->print_cr("----------");
 697         }
 698         if (!_g1h->is_in_closed_subset(obj)) {
 699           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 700           gclog_or_tty->print_cr("Field "PTR_FORMAT
 701                                  " of live obj "PTR_FORMAT" in region "
 702                                  "["PTR_FORMAT", "PTR_FORMAT")",




 418   assert(cur <= start, "Postcondition");
 419 
 420   oop obj;
 421 
 422   HeapWord* next = cur;
 423   while (next <= start) {
 424     cur = next;
 425     obj = oop(cur);
 426     if (obj->klass_or_null() == NULL) {
 427       // Ran into an unparseable point.
 428       return cur;
 429     }
 430     // Otherwise...
 431     next = cur + block_size(cur);
 432   }
 433 
 434   // If we finish the above loop...We have a parseable object that
 435   // begins on or before the start of the memory region, and ends
 436   // inside or spans the entire region.
 437 

 438   assert(cur <= start, "Loop postcondition");


 439 
 440   do {
 441     assert(obj->klass_or_null() != NULL, "Loop invariant");
 442     assert((cur + block_size(cur)) > (HeapWord*)obj, "Loop invariant");
 443     assert(obj == oop(cur), "Loop invariant");


 444     if (obj->klass_or_null() == NULL) {
 445       // Ran into an unparseable point.
 446       return cur;
 447     }
 448 
 449     // Advance the current pointer. "obj" still points to the object to iterate.
 450     cur = cur + block_size(cur);
 451 
 452     if (!g1h->is_obj_dead(obj)) {
 453       // Non-object arrays are sometimes marked imprecise at the object start. We
 454       // always need to iterate over them in full.
 455       // We only iterate over object arrays in full if they are completely contained
 456       // in the memory region.
 457       if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur < end)) {
 458         obj->oop_iterate(cl);
 459       } else {


 460         obj->oop_iterate(cl, mr);
 461       }
 462     }
 463     obj = oop(cur);
 464   } while (cur < end);
 465 
 466   return NULL;
 467 }
 468 
 469 // Code roots support
 470 
 471 void HeapRegion::add_strong_code_root(nmethod* nm) {
 472   HeapRegionRemSet* hrrs = rem_set();
 473   hrrs->add_strong_code_root(nm);
 474 }
 475 
 476 void HeapRegion::add_strong_code_root_locked(nmethod* nm) {
 477   assert_locked_or_safepoint(CodeCache_lock);
 478   HeapRegionRemSet* hrrs = rem_set();
 479   hrrs->add_strong_code_root_locked(nm);
 480 }
 481 
 482 void HeapRegion::remove_strong_code_root(nmethod* nm) {
 483   HeapRegionRemSet* hrrs = rem_set();
 484   hrrs->remove_strong_code_root(nm);
 485 }


 658   }
 659 
 660   bool failures() { return _failures; }
 661   int n_failures() { return _n_failures; }
 662 
 663   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 664   virtual void do_oop(      oop* p) { do_oop_work(p); }
 665 
 666   void print_object(outputStream* out, oop obj) {
 667 #ifdef PRODUCT
 668     Klass* k = obj->klass();
 669     const char* class_name = InstanceKlass::cast(k)->external_name();
 670     out->print_cr("class name %s", class_name);
 671 #else // PRODUCT
 672     obj->print_on(out);
 673 #endif // PRODUCT
 674   }
 675 
 676   template <class T>
 677   void do_oop_work(T* p) {
 678 //      gclog_or_tty->print_cr("Verifying address " PTR_FORMAT, p2i(p));
 679     assert(_containing_obj != NULL, "Precondition");
 680     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
 681            "Precondition");
 682     T heap_oop = oopDesc::load_heap_oop(p);
 683     if (!oopDesc::is_null(heap_oop)) {
 684       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 685       bool failed = false;
 686       if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
 687         MutexLockerEx x(ParGCRareEvent_lock,
 688                         Mutex::_no_safepoint_check_flag);
 689 
 690         if (!_failures) {
 691           gclog_or_tty->cr();
 692           gclog_or_tty->print_cr("----------");
 693         }
 694         if (!_g1h->is_in_closed_subset(obj)) {
 695           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 696           gclog_or_tty->print_cr("Field "PTR_FORMAT
 697                                  " of live obj "PTR_FORMAT" in region "
 698                                  "["PTR_FORMAT", "PTR_FORMAT")",


< prev index next >