equal
deleted
inserted
replaced
839 |
839 |
840 } // MetaspaceUtils::print_report() |
840 } // MetaspaceUtils::print_report() |
841 |
841 |
842 // Prints an ASCII representation of the given space. |
842 // Prints an ASCII representation of the given space. |
843 void MetaspaceUtils::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) { |
843 void MetaspaceUtils::print_metaspace_map(outputStream* out, Metaspace::MetadataType mdtype) { |
844 MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
844 MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
845 const bool for_class = mdtype == Metaspace::ClassType ? true : false; |
845 const bool for_class = mdtype == Metaspace::ClassType ? true : false; |
846 VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list(); |
846 VirtualSpaceList* const vsl = for_class ? Metaspace::class_space_list() : Metaspace::space_list(); |
847 if (vsl != NULL) { |
847 if (vsl != NULL) { |
848 if (for_class) { |
848 if (for_class) { |
849 if (!Metaspace::using_class_space()) { |
849 if (!Metaspace::using_class_space()) { |
904 #endif |
904 #endif |
905 } |
905 } |
906 |
906 |
907 // Utils to check if a pointer or range is part of a committed metaspace region. |
907 // Utils to check if a pointer or range is part of a committed metaspace region. |
908 metaspace::VirtualSpaceNode* MetaspaceUtils::find_enclosing_virtual_space(const void* p) { |
908 metaspace::VirtualSpaceNode* MetaspaceUtils::find_enclosing_virtual_space(const void* p) { |
909 MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
909 MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
910 VirtualSpaceNode* vsn = Metaspace::space_list()->find_enclosing_space(p); |
910 VirtualSpaceNode* vsn = Metaspace::space_list()->find_enclosing_space(p); |
911 if (Metaspace::using_class_space() && vsn == NULL) { |
911 if (Metaspace::using_class_space() && vsn == NULL) { |
912 vsn = Metaspace::class_space_list()->find_enclosing_space(p); |
912 vsn = Metaspace::class_space_list()->find_enclosing_space(p); |
913 } |
913 } |
914 return vsn; |
914 return vsn; |
1400 void Metaspace::purge(MetadataType mdtype) { |
1400 void Metaspace::purge(MetadataType mdtype) { |
1401 get_space_list(mdtype)->purge(get_chunk_manager(mdtype)); |
1401 get_space_list(mdtype)->purge(get_chunk_manager(mdtype)); |
1402 } |
1402 } |
1403 |
1403 |
1404 void Metaspace::purge() { |
1404 void Metaspace::purge() { |
1405 MutexLockerEx cl(MetaspaceExpand_lock, |
1405 MutexLocker cl(MetaspaceExpand_lock, |
1406 Mutex::_no_safepoint_check_flag); |
1406 Mutex::_no_safepoint_check_flag); |
1407 purge(NonClassType); |
1407 purge(NonClassType); |
1408 if (using_class_space()) { |
1408 if (using_class_space()) { |
1409 purge(ClassType); |
1409 purge(ClassType); |
1410 } |
1410 } |
1411 } |
1411 } |
1478 if (Metaspace::using_class_space()) { |
1478 if (Metaspace::using_class_space()) { |
1479 // Allocate SpaceManager for classes. |
1479 // Allocate SpaceManager for classes. |
1480 _class_vsm = new SpaceManager(Metaspace::ClassType, type, lock); |
1480 _class_vsm = new SpaceManager(Metaspace::ClassType, type, lock); |
1481 } |
1481 } |
1482 |
1482 |
1483 MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
1483 MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
1484 |
1484 |
1485 // Allocate chunk for metadata objects |
1485 // Allocate chunk for metadata objects |
1486 initialize_first_chunk(type, Metaspace::NonClassType); |
1486 initialize_first_chunk(type, Metaspace::NonClassType); |
1487 |
1487 |
1488 // Allocate chunk for class metadata objects |
1488 // Allocate chunk for class metadata objects |
1547 assert(!SafepointSynchronize::is_at_safepoint() |
1547 assert(!SafepointSynchronize::is_at_safepoint() |
1548 || Thread::current()->is_VM_thread(), "should be the VM thread"); |
1548 || Thread::current()->is_VM_thread(), "should be the VM thread"); |
1549 |
1549 |
1550 DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_external_deallocs)); |
1550 DEBUG_ONLY(Atomic::inc(&g_internal_statistics.num_external_deallocs)); |
1551 |
1551 |
1552 MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
1552 MutexLocker ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); |
1553 |
1553 |
1554 if (is_class && Metaspace::using_class_space()) { |
1554 if (is_class && Metaspace::using_class_space()) { |
1555 class_vsm()->deallocate(ptr, word_size); |
1555 class_vsm()->deallocate(ptr, word_size); |
1556 } else { |
1556 } else { |
1557 vsm()->deallocate(ptr, word_size); |
1557 vsm()->deallocate(ptr, word_size); |
1587 class_vsm()->add_to_statistics_locked(&out->class_sm_stats()); |
1587 class_vsm()->add_to_statistics_locked(&out->class_sm_stats()); |
1588 } |
1588 } |
1589 } |
1589 } |
1590 |
1590 |
1591 void ClassLoaderMetaspace::add_to_statistics(ClassLoaderMetaspaceStatistics* out) const { |
1591 void ClassLoaderMetaspace::add_to_statistics(ClassLoaderMetaspaceStatistics* out) const { |
1592 MutexLockerEx cl(lock(), Mutex::_no_safepoint_check_flag); |
1592 MutexLocker cl(lock(), Mutex::_no_safepoint_check_flag); |
1593 add_to_statistics_locked(out); |
1593 add_to_statistics_locked(out); |
1594 } |
1594 } |
1595 |
1595 |
1596 /////////////// Unit tests /////////////// |
1596 /////////////// Unit tests /////////////// |
1597 |
1597 |
1637 } |
1637 } |
1638 } |
1638 } |
1639 |
1639 |
1640 static void test_virtual_space_list_large_chunk() { |
1640 static void test_virtual_space_list_large_chunk() { |
1641 VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); |
1641 VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); |
1642 MutexLockerEx cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
1642 MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
1643 // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be |
1643 // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be |
1644 // vm_allocation_granularity aligned on Windows. |
1644 // vm_allocation_granularity aligned on Windows. |
1645 size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); |
1645 size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); |
1646 large_size += (os::vm_page_size()/BytesPerWord); |
1646 large_size += (os::vm_page_size()/BytesPerWord); |
1647 vs_list->get_new_chunk(large_size, 0); |
1647 vs_list->get_new_chunk(large_size, 0); |