681 FOR_ALL_ALLOCABLE_HEAPS(heap) { |
681 FOR_ALL_ALLOCABLE_HEAPS(heap) { |
682 FOR_ALL_BLOBS(cb, *heap) { |
682 FOR_ALL_BLOBS(cb, *heap) { |
683 if (cb->is_alive()) { |
683 if (cb->is_alive()) { |
684 f->do_code_blob(cb); |
684 f->do_code_blob(cb); |
685 #ifdef ASSERT |
685 #ifdef ASSERT |
686 if (cb->is_nmethod()) |
686 if (cb->is_nmethod()) { |
687 ((nmethod*)cb)->verify_scavenge_root_oops(); |
687 Universe::heap()->verify_nmethod((nmethod*)cb); |
|
688 } |
688 #endif //ASSERT |
689 #endif //ASSERT |
689 } |
690 } |
690 } |
691 } |
691 } |
692 } |
692 } |
693 } |
693 |
694 |
694 // Walk the list of methods which might contain non-perm oops. |
695 // Walk the list of methods which might contain oops to the java heap. |
695 void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) { |
696 void CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure* f) { |
696 assert_locked_or_safepoint(CodeCache_lock); |
697 assert_locked_or_safepoint(CodeCache_lock); |
697 |
|
698 if (UseG1GC) { |
|
699 return; |
|
700 } |
|
701 |
698 |
702 const bool fix_relocations = f->fix_relocations(); |
699 const bool fix_relocations = f->fix_relocations(); |
703 debug_only(mark_scavenge_root_nmethods()); |
700 debug_only(mark_scavenge_root_nmethods()); |
704 |
701 |
705 nmethod* prev = NULL; |
702 nmethod* prev = NULL; |
733 |
730 |
734 // Check for stray marks. |
731 // Check for stray marks. |
735 debug_only(verify_perm_nmethods(NULL)); |
732 debug_only(verify_perm_nmethods(NULL)); |
736 } |
733 } |
737 |
734 |
|
735 void CodeCache::register_scavenge_root_nmethod(nmethod* nm) { |
|
736 assert_locked_or_safepoint(CodeCache_lock); |
|
737 if (!nm->on_scavenge_root_list() && nm->detect_scavenge_root_oops()) { |
|
738 add_scavenge_root_nmethod(nm); |
|
739 } |
|
740 } |
|
741 |
|
742 void CodeCache::verify_scavenge_root_nmethod(nmethod* nm) { |
|
743 nm->verify_scavenge_root_oops(); |
|
744 } |
|
745 |
738 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { |
746 void CodeCache::add_scavenge_root_nmethod(nmethod* nm) { |
739 assert_locked_or_safepoint(CodeCache_lock); |
747 assert_locked_or_safepoint(CodeCache_lock); |
740 |
|
741 if (UseG1GC) { |
|
742 return; |
|
743 } |
|
744 |
748 |
745 nm->set_on_scavenge_root_list(); |
749 nm->set_on_scavenge_root_list(); |
746 nm->set_scavenge_root_link(_scavenge_root_nmethods); |
750 nm->set_scavenge_root_link(_scavenge_root_nmethods); |
747 set_scavenge_root_nmethods(nm); |
751 set_scavenge_root_nmethods(nm); |
748 print_trace("add_scavenge_root", nm); |
752 print_trace("add_scavenge_root", nm); |
751 void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) { |
755 void CodeCache::unlink_scavenge_root_nmethod(nmethod* nm, nmethod* prev) { |
752 assert_locked_or_safepoint(CodeCache_lock); |
756 assert_locked_or_safepoint(CodeCache_lock); |
753 |
757 |
754 assert((prev == NULL && scavenge_root_nmethods() == nm) || |
758 assert((prev == NULL && scavenge_root_nmethods() == nm) || |
755 (prev != NULL && prev->scavenge_root_link() == nm), "precondition"); |
759 (prev != NULL && prev->scavenge_root_link() == nm), "precondition"); |
756 |
|
757 assert(!UseG1GC, "G1 does not use the scavenge_root_nmethods list"); |
|
758 |
760 |
759 print_trace("unlink_scavenge_root", nm); |
761 print_trace("unlink_scavenge_root", nm); |
760 if (prev == NULL) { |
762 if (prev == NULL) { |
761 set_scavenge_root_nmethods(nm->scavenge_root_link()); |
763 set_scavenge_root_nmethods(nm->scavenge_root_link()); |
762 } else { |
764 } else { |
766 nm->clear_on_scavenge_root_list(); |
768 nm->clear_on_scavenge_root_list(); |
767 } |
769 } |
768 |
770 |
769 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { |
771 void CodeCache::drop_scavenge_root_nmethod(nmethod* nm) { |
770 assert_locked_or_safepoint(CodeCache_lock); |
772 assert_locked_or_safepoint(CodeCache_lock); |
771 |
|
772 if (UseG1GC) { |
|
773 return; |
|
774 } |
|
775 |
773 |
776 print_trace("drop_scavenge_root", nm); |
774 print_trace("drop_scavenge_root", nm); |
777 nmethod* prev = NULL; |
775 nmethod* prev = NULL; |
778 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
776 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
779 if (cur == nm) { |
777 if (cur == nm) { |
785 assert(false, "should have been on list"); |
783 assert(false, "should have been on list"); |
786 } |
784 } |
787 |
785 |
788 void CodeCache::prune_scavenge_root_nmethods() { |
786 void CodeCache::prune_scavenge_root_nmethods() { |
789 assert_locked_or_safepoint(CodeCache_lock); |
787 assert_locked_or_safepoint(CodeCache_lock); |
790 |
|
791 if (UseG1GC) { |
|
792 return; |
|
793 } |
|
794 |
788 |
795 debug_only(mark_scavenge_root_nmethods()); |
789 debug_only(mark_scavenge_root_nmethods()); |
796 |
790 |
797 nmethod* last = NULL; |
791 nmethod* last = NULL; |
798 nmethod* cur = scavenge_root_nmethods(); |
792 nmethod* cur = scavenge_root_nmethods(); |
818 debug_only(verify_perm_nmethods(NULL)); |
812 debug_only(verify_perm_nmethods(NULL)); |
819 } |
813 } |
820 |
814 |
821 #ifndef PRODUCT |
815 #ifndef PRODUCT |
822 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { |
816 void CodeCache::asserted_non_scavengable_nmethods_do(CodeBlobClosure* f) { |
823 if (UseG1GC) { |
|
824 return; |
|
825 } |
|
826 |
|
827 // While we are here, verify the integrity of the list. |
817 // While we are here, verify the integrity of the list. |
828 mark_scavenge_root_nmethods(); |
818 mark_scavenge_root_nmethods(); |
829 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
819 for (nmethod* cur = scavenge_root_nmethods(); cur != NULL; cur = cur->scavenge_root_link()) { |
830 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
820 assert(cur->on_scavenge_root_list(), "else shouldn't be on this list"); |
831 cur->clear_scavenge_root_marked(); |
821 cur->clear_scavenge_root_marked(); |
832 } |
822 } |
833 verify_perm_nmethods(f); |
823 verify_perm_nmethods(f); |
834 } |
824 } |
835 |
825 |
836 // Temporarily mark nmethods that are claimed to be on the non-perm list. |
826 // Temporarily mark nmethods that are claimed to be on the scavenge list. |
837 void CodeCache::mark_scavenge_root_nmethods() { |
827 void CodeCache::mark_scavenge_root_nmethods() { |
838 NMethodIterator iter; |
828 NMethodIterator iter; |
839 while(iter.next_alive()) { |
829 while(iter.next_alive()) { |
840 nmethod* nm = iter.method(); |
830 nmethod* nm = iter.method(); |
841 assert(nm->scavenge_root_not_marked(), "clean state"); |
831 assert(nm->scavenge_root_not_marked(), "clean state"); |
852 nmethod* nm = iter.method(); |
842 nmethod* nm = iter.method(); |
853 bool call_f = (f_or_null != NULL); |
843 bool call_f = (f_or_null != NULL); |
854 assert(nm->scavenge_root_not_marked(), "must be already processed"); |
844 assert(nm->scavenge_root_not_marked(), "must be already processed"); |
855 if (nm->on_scavenge_root_list()) |
845 if (nm->on_scavenge_root_list()) |
856 call_f = false; // don't show this one to the client |
846 call_f = false; // don't show this one to the client |
857 nm->verify_scavenge_root_oops(); |
847 Universe::heap()->verify_nmethod(nm); |
858 if (call_f) f_or_null->do_code_blob(nm); |
848 if (call_f) f_or_null->do_code_blob(nm); |
859 } |
849 } |
860 } |
850 } |
861 #endif //PRODUCT |
851 #endif //PRODUCT |
862 |
852 |
1638 st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" |
1628 st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'" |
1639 " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'", |
1629 " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'", |
1640 blob_count(), nmethod_count(), adapter_count(), |
1630 blob_count(), nmethod_count(), adapter_count(), |
1641 unallocated_capacity()); |
1631 unallocated_capacity()); |
1642 } |
1632 } |
1643 |
|