828 AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
828 AOTCompiledMethod* aot = _code_to_aot[index]._aot; |
829 aot->do_oops(f); |
829 aot->do_oops(f); |
830 } |
830 } |
831 } |
831 } |
832 |
832 |
833 // Yes, this is faster than going through the relocations, |
833 // Scan only metaspace_got cells which should have only Klass*, |
834 // but there are two problems: |
834 // metadata_got cells are scanned only for alive AOT methods |
835 // 1) GOT slots are sometimes patched with non-Metadata values |
835 // by AOTCompiledMethod::metadata_do(). |
836 // 2) We don't want to scan metadata for dead methods |
|
837 // Unfortunately we don't know if the metadata belongs to |
|
838 // live aot methods or not, so process them all. If this |
|
839 // is for mark_on_stack, some old methods may stick around |
|
840 // forever instead of getting cleaned up. |
|
841 void AOTCodeHeap::got_metadata_do(void f(Metadata*)) { |
836 void AOTCodeHeap::got_metadata_do(void f(Metadata*)) { |
842 for (int i = 1; i < _metaspace_got_size; i++) { |
837 for (int i = 1; i < _metaspace_got_size; i++) { |
843 Metadata** p = &_metaspace_got[i]; |
838 Metadata** p = &_metaspace_got[i]; |
844 Metadata* md = *p; |
839 Metadata* md = *p; |
845 if (md == NULL) continue; // skip non-oops |
840 if (md == NULL) continue; // skip non-oops |
846 intptr_t meta = (intptr_t)md; |
|
847 if (meta == -1) continue; // skip non-oops |
|
848 if (Metaspace::contains(md)) { |
841 if (Metaspace::contains(md)) { |
849 f(md); |
842 f(md); |
850 } |
|
851 } |
|
852 for (int i = 1; i < _metadata_got_size; i++) { |
|
853 Metadata** p = &_metadata_got[i]; |
|
854 Metadata* md = *p; |
|
855 intptr_t meta = (intptr_t)md; |
|
856 if ((meta & 1) == 1) { |
|
857 // already resolved |
|
858 md = (Metadata*)(meta & ~1); |
|
859 } else { |
843 } else { |
860 continue; |
844 intptr_t meta = (intptr_t)md; |
861 } |
845 fatal("Invalid value in _metaspace_got[%d] = " INTPTR_FORMAT, i, meta); |
862 if (md == NULL) continue; // skip non-oops |
|
863 if (Metaspace::contains(md)) { |
|
864 f(md); |
|
865 } |
846 } |
866 } |
847 } |
867 } |
848 } |
868 |
849 |
869 void AOTCodeHeap::cleanup_inline_caches() { |
850 void AOTCodeHeap::cleanup_inline_caches() { |