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");
749 else
750 st->print(" HC");
|
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(),
605 err_msg("humongous region "HR_FORMAT" should not have been added to collection set",
606 HR_FORMAT_PARAMS(this)));
607
608 HeapRegionRemSet* hrrs = rem_set();
609 hrrs->migrate_strong_code_roots();
610 }
611
612 void HeapRegion::strong_code_roots_do(CodeBlobClosure* blk) const {
613 HeapRegionRemSet* hrrs = rem_set();
614 hrrs->strong_code_roots_do(blk);
615 }
616
617 class VerifyStrongCodeRootOopClosure: public OopClosure {
618 const HeapRegion* _hr;
619 nmethod* _nm;
620 bool _failures;
621 bool _has_oops_in_region;
622
623 template <class T> void do_oop_work(T* p) {
624 T heap_oop = oopDesc::load_heap_oop(p);
625 if (!oopDesc::is_null(heap_oop)) {
626 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
707 // time.
708 assert(VerifyDuringGC, "only way to get here");
709 return;
710 }
711
712 HeapRegionRemSet* hrrs = rem_set();
713 int strong_code_roots_length = hrrs->strong_code_roots_list_length();
714
715 // if this region is empty then there should be no entries
716 // on its strong code root list
717 if (is_empty()) {
718 if (strong_code_roots_length > 0) {
719 gclog_or_tty->print_cr("region ["PTR_FORMAT","PTR_FORMAT"] is empty "
720 "but has "INT32_FORMAT" code root entries",
721 bottom(), end(), strong_code_roots_length);
722 *failures = true;
723 }
724 return;
725 }
726
727 if (continuesHumongous()) {
728 if (strong_code_roots_length > 0) {
729 gclog_or_tty->print_cr("region "HR_FORMAT" is a continuation of a humongous "
730 "region but has "INT32_FORMAT" code root entries",
731 HR_FORMAT_PARAMS(this), strong_code_roots_length);
732 *failures = true;
733 }
734 return;
735 }
736
737 VerifyStrongCodeRootCodeBlobClosure cb_cl(this);
738 strong_code_roots_do(&cb_cl);
739
740 if (cb_cl.failures()) {
741 *failures = true;
742 }
743 }
744
745 void HeapRegion::print() const { print_on(gclog_or_tty); }
746 void HeapRegion::print_on(outputStream* st) const {
747 if (isHumongous()) {
748 if (startsHumongous())
749 st->print(" HS");
750 else
751 st->print(" HC");
|