1586 add_to_statistics_locked(out); |
1586 add_to_statistics_locked(out); |
1587 } |
1587 } |
1588 |
1588 |
1589 /////////////// Unit tests /////////////// |
1589 /////////////// Unit tests /////////////// |
1590 |
1590 |
1591 #ifndef PRODUCT |
|
1592 |
|
1593 class TestMetaspaceUtilsTest : AllStatic { |
|
1594 public: |
|
1595 static void test_reserved() { |
|
1596 size_t reserved = MetaspaceUtils::reserved_bytes(); |
|
1597 |
|
1598 assert(reserved > 0, "assert"); |
|
1599 |
|
1600 size_t committed = MetaspaceUtils::committed_bytes(); |
|
1601 assert(committed <= reserved, "assert"); |
|
1602 |
|
1603 size_t reserved_metadata = MetaspaceUtils::reserved_bytes(Metaspace::NonClassType); |
|
1604 assert(reserved_metadata > 0, "assert"); |
|
1605 assert(reserved_metadata <= reserved, "assert"); |
|
1606 |
|
1607 if (UseCompressedClassPointers) { |
|
1608 size_t reserved_class = MetaspaceUtils::reserved_bytes(Metaspace::ClassType); |
|
1609 assert(reserved_class > 0, "assert"); |
|
1610 assert(reserved_class < reserved, "assert"); |
|
1611 } |
|
1612 } |
|
1613 |
|
1614 static void test_committed() { |
|
1615 size_t committed = MetaspaceUtils::committed_bytes(); |
|
1616 |
|
1617 assert(committed > 0, "assert"); |
|
1618 |
|
1619 size_t reserved = MetaspaceUtils::reserved_bytes(); |
|
1620 assert(committed <= reserved, "assert"); |
|
1621 |
|
1622 size_t committed_metadata = MetaspaceUtils::committed_bytes(Metaspace::NonClassType); |
|
1623 assert(committed_metadata > 0, "assert"); |
|
1624 assert(committed_metadata <= committed, "assert"); |
|
1625 |
|
1626 if (UseCompressedClassPointers) { |
|
1627 size_t committed_class = MetaspaceUtils::committed_bytes(Metaspace::ClassType); |
|
1628 assert(committed_class > 0, "assert"); |
|
1629 assert(committed_class < committed, "assert"); |
|
1630 } |
|
1631 } |
|
1632 |
|
1633 static void test_virtual_space_list_large_chunk() { |
|
1634 VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity()); |
|
1635 MutexLocker cl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag); |
|
1636 // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be |
|
1637 // vm_allocation_granularity aligned on Windows. |
|
1638 size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord)); |
|
1639 large_size += (os::vm_page_size()/BytesPerWord); |
|
1640 vs_list->get_new_chunk(large_size, 0); |
|
1641 } |
|
1642 |
|
1643 static void test() { |
|
1644 test_reserved(); |
|
1645 test_committed(); |
|
1646 test_virtual_space_list_large_chunk(); |
|
1647 } |
|
1648 }; |
|
1649 |
|
1650 void TestMetaspaceUtils_test() { |
|
1651 TestMetaspaceUtilsTest::test(); |
|
1652 } |
|
1653 |
|
1654 #endif // !PRODUCT |
|
1655 |
|
1656 struct chunkmanager_statistics_t { |
1591 struct chunkmanager_statistics_t { |
1657 int num_specialized_chunks; |
1592 int num_specialized_chunks; |
1658 int num_small_chunks; |
1593 int num_small_chunks; |
1659 int num_medium_chunks; |
1594 int num_medium_chunks; |
1660 int num_humongous_chunks; |
1595 int num_humongous_chunks; |