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

Print this page




 584     }
 585     cur = next;
 586   }
 587   return NULL;
 588 }
 589 
 590 // Code roots support
 591 
 592 void HeapRegion::add_strong_code_root(nmethod* nm) {
 593   HeapRegionRemSet* hrrs = rem_set();
 594   hrrs->add_strong_code_root(nm);
 595 }
 596 
 597 void HeapRegion::remove_strong_code_root(nmethod* nm) {
 598   HeapRegionRemSet* hrrs = rem_set();
 599   hrrs->remove_strong_code_root(nm);
 600 }
 601 
 602 void HeapRegion::migrate_strong_code_roots() {
 603   assert(in_collection_set(), "only collection set regions");
 604   assert(!isHumongous(), "not humongous regions");
 605 
 606   HeapRegionRemSet* hrrs = rem_set();
 607   hrrs->migrate_strong_code_roots();
 608 }
 609 
 610 void HeapRegion::strong_code_roots_do(CodeBlobClosure* blk) const {
 611   HeapRegionRemSet* hrrs = rem_set();
 612   hrrs->strong_code_roots_do(blk);
 613 }
 614 
 615 class VerifyStrongCodeRootOopClosure: public OopClosure {
 616   const HeapRegion* _hr;
 617   nmethod* _nm;
 618   bool _failures;
 619   bool _has_oops_in_region;
 620 
 621   template <class T> void do_oop_work(T* p) {
 622     T heap_oop = oopDesc::load_heap_oop(p);
 623     if (!oopDesc::is_null(heap_oop)) {
 624       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);


 705     // time.
 706     assert(VerifyDuringGC, "only way to get here");
 707     return;
 708   }
 709 
 710   HeapRegionRemSet* hrrs = rem_set();
 711   int strong_code_roots_length = hrrs->strong_code_roots_list_length();
 712 
 713   // if this region is empty then there should be no entries
 714   // on its strong code root list
 715   if (is_empty()) {
 716     if (strong_code_roots_length > 0) {
 717       gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is empty "
 718                              "but has "INT32_FORMAT" code root entries",
 719                              bottom(), end(), strong_code_roots_length);
 720       *failures = true;
 721     }
 722     return;
 723   }
 724 
 725   // An H-region should have an empty strong code root list
 726   if (isHumongous()) {
 727     if (strong_code_roots_length > 0) {
 728       gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is humongous "
 729                              "but has "INT32_FORMAT" code root entries",
 730                              bottom(), end(), strong_code_roots_length);
 731       *failures = true;
 732     }
 733     return;
 734   }
 735 
 736   VerifyStrongCodeRootCodeBlobClosure cb_cl(this);
 737   strong_code_roots_do(&cb_cl);
 738 
 739   if (cb_cl.failures()) {
 740     *failures = true;
 741   }
 742 }
 743 
 744 void HeapRegion::print() const { print_on(gclog_or_tty); }
 745 void HeapRegion::print_on(outputStream* st) const {
 746   if (isHumongous()) {
 747     if (startsHumongous())
 748       st->print(" HS");




 584     }
 585     cur = next;
 586   }
 587   return NULL;
 588 }
 589 
 590 // Code roots support
 591 
 592 void HeapRegion::add_strong_code_root(nmethod* nm) {
 593   HeapRegionRemSet* hrrs = rem_set();
 594   hrrs->add_strong_code_root(nm);
 595 }
 596 
 597 void HeapRegion::remove_strong_code_root(nmethod* nm) {
 598   HeapRegionRemSet* hrrs = rem_set();
 599   hrrs->remove_strong_code_root(nm);
 600 }
 601 
 602 void HeapRegion::migrate_strong_code_roots() {
 603   assert(in_collection_set(), "only collection set regions");
 604   assert(!isHumongous(), "humongous region moved?");
 605 
 606   HeapRegionRemSet* hrrs = rem_set();
 607   hrrs->migrate_strong_code_roots();
 608 }
 609 
 610 void HeapRegion::strong_code_roots_do(CodeBlobClosure* blk) const {
 611   HeapRegionRemSet* hrrs = rem_set();
 612   hrrs->strong_code_roots_do(blk);
 613 }
 614 
 615 class VerifyStrongCodeRootOopClosure: public OopClosure {
 616   const HeapRegion* _hr;
 617   nmethod* _nm;
 618   bool _failures;
 619   bool _has_oops_in_region;
 620 
 621   template <class T> void do_oop_work(T* p) {
 622     T heap_oop = oopDesc::load_heap_oop(p);
 623     if (!oopDesc::is_null(heap_oop)) {
 624       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);


 705     // time.
 706     assert(VerifyDuringGC, "only way to get here");
 707     return;
 708   }
 709 
 710   HeapRegionRemSet* hrrs = rem_set();
 711   int strong_code_roots_length = hrrs->strong_code_roots_list_length();
 712 
 713   // if this region is empty then there should be no entries
 714   // on its strong code root list
 715   if (is_empty()) {
 716     if (strong_code_roots_length > 0) {
 717       gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is empty "
 718                              "but has "INT32_FORMAT" code root entries",
 719                              bottom(), end(), strong_code_roots_length);
 720       *failures = true;
 721     }
 722     return;
 723   }
 724 
 725   // An H-region continuation should have an empty strong code root list
 726   if (continuesHumongous()) {
 727     if (strong_code_roots_length > 0) {
 728       gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is a humongous continuation "
 729                              "but has "INT32_FORMAT" code root entries",
 730                              bottom(), end(), strong_code_roots_length);
 731       *failures = true;
 732     }
 733     return;
 734   }
 735 
 736   VerifyStrongCodeRootCodeBlobClosure cb_cl(this);
 737   strong_code_roots_do(&cb_cl);
 738 
 739   if (cb_cl.failures()) {
 740     *failures = true;
 741   }
 742 }
 743 
 744 void HeapRegion::print() const { print_on(gclog_or_tty); }
 745 void HeapRegion::print_on(outputStream* st) const {
 746   if (isHumongous()) {
 747     if (startsHumongous())
 748       st->print(" HS");