< prev index next >

src/hotspot/share/memory/metaspace.cpp

Print this page
rev 52233 : [mq]: 8177711

@@ -1626,169 +1626,10 @@
 
 void TestMetaspaceUtils_test() {
   TestMetaspaceUtilsTest::test();
 }
 
-class TestVirtualSpaceNodeTest {
-  static void chunk_up(size_t words_left, size_t& num_medium_chunks,
-                                          size_t& num_small_chunks,
-                                          size_t& num_specialized_chunks) {
-    num_medium_chunks = words_left / MediumChunk;
-    words_left = words_left % MediumChunk;
-
-    num_small_chunks = words_left / SmallChunk;
-    words_left = words_left % SmallChunk;
-    // how many specialized chunks can we get?
-    num_specialized_chunks = words_left / SpecializedChunk;
-    assert(words_left % SpecializedChunk == 0, "should be nothing left");
-  }
-
- public:
-  static void test() {
-    MutexLockerEx ml(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
-    const size_t vsn_test_size_words = MediumChunk  * 4;
-    const size_t vsn_test_size_bytes = vsn_test_size_words * BytesPerWord;
-
-    // The chunk sizes must be multiples of eachother, or this will fail
-    STATIC_ASSERT(MediumChunk % SmallChunk == 0);
-    STATIC_ASSERT(SmallChunk % SpecializedChunk == 0);
-
-    { // No committed memory in VSN
-      ChunkManager cm(false);
-      VirtualSpaceNode vsn(false, vsn_test_size_bytes);
-      vsn.initialize();
-      vsn.retire(&cm);
-      assert(cm.sum_free_chunks_count() == 0, "did not commit any memory in the VSN");
-    }
-
-    { // All of VSN is committed, half is used by chunks
-      ChunkManager cm(false);
-      VirtualSpaceNode vsn(false, vsn_test_size_bytes);
-      vsn.initialize();
-      vsn.expand_by(vsn_test_size_words, vsn_test_size_words);
-      vsn.get_chunk_vs(MediumChunk);
-      vsn.get_chunk_vs(MediumChunk);
-      vsn.retire(&cm);
-      assert(cm.sum_free_chunks_count() == 2, "should have been memory left for 2 medium chunks");
-      assert(cm.sum_free_chunks() == 2*MediumChunk, "sizes should add up");
-    }
-
-    const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord;
-    // This doesn't work for systems with vm_page_size >= 16K.
-    if (page_chunks < MediumChunk) {
-      // 4 pages of VSN is committed, some is used by chunks
-      ChunkManager cm(false);
-      VirtualSpaceNode vsn(false, vsn_test_size_bytes);
-
-      vsn.initialize();
-      vsn.expand_by(page_chunks, page_chunks);
-      vsn.get_chunk_vs(SmallChunk);
-      vsn.get_chunk_vs(SpecializedChunk);
-      vsn.retire(&cm);
-
-      // committed - used = words left to retire
-      const size_t words_left = page_chunks - SmallChunk - SpecializedChunk;
-
-      size_t num_medium_chunks, num_small_chunks, num_spec_chunks;
-      chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks);
-
-      assert(num_medium_chunks == 0, "should not get any medium chunks");
-      assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks");
-      assert(cm.sum_free_chunks() == words_left, "sizes should add up");
-    }
-
-    { // Half of VSN is committed, a humongous chunk is used
-      ChunkManager cm(false);
-      VirtualSpaceNode vsn(false, vsn_test_size_bytes);
-      vsn.initialize();
-      vsn.expand_by(MediumChunk * 2, MediumChunk * 2);
-      vsn.get_chunk_vs(MediumChunk + SpecializedChunk); // Humongous chunks will be aligned up to MediumChunk + SpecializedChunk
-      vsn.retire(&cm);
-
-      const size_t words_left = MediumChunk * 2 - (MediumChunk + SpecializedChunk);
-      size_t num_medium_chunks, num_small_chunks, num_spec_chunks;
-      chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks);
-
-      assert(num_medium_chunks == 0, "should not get any medium chunks");
-      assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks");
-      assert(cm.sum_free_chunks() == words_left, "sizes should add up");
-    }
-
-  }
-
-#define assert_is_available_positive(word_size) \
-  assert(vsn.is_available(word_size), \
-         #word_size ": " PTR_FORMAT " bytes were not available in " \
-         "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
-         (uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end()));
-
-#define assert_is_available_negative(word_size) \
-  assert(!vsn.is_available(word_size), \
-         #word_size ": " PTR_FORMAT " bytes should not be available in " \
-         "VirtualSpaceNode [" PTR_FORMAT ", " PTR_FORMAT ")", \
-         (uintptr_t)(word_size * BytesPerWord), p2i(vsn.bottom()), p2i(vsn.end()));
-
-  static void test_is_available_positive() {
-    // Reserve some memory.
-    VirtualSpaceNode vsn(false, os::vm_allocation_granularity());
-    assert(vsn.initialize(), "Failed to setup VirtualSpaceNode");
-
-    // Commit some memory.
-    size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord;
-    bool expanded = vsn.expand_by(commit_word_size, commit_word_size);
-    assert(expanded, "Failed to commit");
-
-    // Check that is_available accepts the committed size.
-    assert_is_available_positive(commit_word_size);
-
-    // Check that is_available accepts half the committed size.
-    size_t expand_word_size = commit_word_size / 2;
-    assert_is_available_positive(expand_word_size);
-  }
-
-  static void test_is_available_negative() {
-    // Reserve some memory.
-    VirtualSpaceNode vsn(false, os::vm_allocation_granularity());
-    assert(vsn.initialize(), "Failed to setup VirtualSpaceNode");
-
-    // Commit some memory.
-    size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord;
-    bool expanded = vsn.expand_by(commit_word_size, commit_word_size);
-    assert(expanded, "Failed to commit");
-
-    // Check that is_available doesn't accept a too large size.
-    size_t two_times_commit_word_size = commit_word_size * 2;
-    assert_is_available_negative(two_times_commit_word_size);
-  }
-
-  static void test_is_available_overflow() {
-    // Reserve some memory.
-    VirtualSpaceNode vsn(false, os::vm_allocation_granularity());
-    assert(vsn.initialize(), "Failed to setup VirtualSpaceNode");
-
-    // Commit some memory.
-    size_t commit_word_size = os::vm_allocation_granularity() / BytesPerWord;
-    bool expanded = vsn.expand_by(commit_word_size, commit_word_size);
-    assert(expanded, "Failed to commit");
-
-    // Calculate a size that will overflow the virtual space size.
-    void* virtual_space_max = (void*)(uintptr_t)-1;
-    size_t bottom_to_max = pointer_delta(virtual_space_max, vsn.bottom(), 1);
-    size_t overflow_size = bottom_to_max + BytesPerWord;
-    size_t overflow_word_size = overflow_size / BytesPerWord;
-
-    // Check that is_available can handle the overflow.
-    assert_is_available_negative(overflow_word_size);
-  }
-
-  static void test_is_available() {
-    TestVirtualSpaceNodeTest::test_is_available_positive();
-    TestVirtualSpaceNodeTest::test_is_available_negative();
-    TestVirtualSpaceNodeTest::test_is_available_overflow();
-  }
-};
-
 #endif // !PRODUCT
 
 struct chunkmanager_statistics_t {
   int num_specialized_chunks;
   int num_small_chunks;
< prev index next >