test/hotspot/gtest/metaspace/test_virtualspacenode.cpp
branchstuefe-new-metaspace-branch
changeset 59135 84464aa83a29
parent 58099 5aeb07390c74
equal deleted inserted replaced
59134:b67820888eb3 59135:84464aa83a29
   466 
   466 
   467 
   467 
   468 
   468 
   469 };
   469 };
   470 
   470 
       
   471 
       
   472 
       
   473 TEST_VM(metaspace, virtual_space_node_test_basics) {
       
   474 
       
   475   MutexLocker fcl(MetaspaceExpand_lock, Mutex::_no_safepoint_check_flag);
       
   476 
       
   477   const size_t word_size = metaspace::chklvl::MAX_CHUNK_WORD_SIZE * 10;
       
   478 
       
   479   SizeCounter scomm;
       
   480   SizeCounter sres;
       
   481   CommitLimiter cl (word_size * 2); // basically, no commit limiter.
       
   482 
       
   483   VirtualSpaceNode* node = VirtualSpaceNode::create_node(42, word_size, &cl, &sres, &scomm);
       
   484   ASSERT_NOT_NULL(node);
       
   485   ASSERT_EQ(node->committed_words(), (size_t)0);
       
   486   ASSERT_EQ(node->committed_words(), scomm.get());
       
   487   DEBUG_ONLY(node->verify(true);)
       
   488 
       
   489   bool b = node->ensure_range_is_committed(node->base(), node->word_size());
       
   490   ASSERT_TRUE(b);
       
   491   ASSERT_EQ(node->committed_words(), word_size);
       
   492   ASSERT_EQ(node->committed_words(), scomm.get());
       
   493   DEBUG_ONLY(node->verify(true);)
       
   494   zap_range(node->base(), node->word_size());
       
   495 
       
   496   node->uncommit_range(node->base(), node->word_size());
       
   497   ASSERT_EQ(node->committed_words(), (size_t)0);
       
   498   ASSERT_EQ(node->committed_words(), scomm.get());
       
   499   DEBUG_ONLY(node->verify(true);)
       
   500 
       
   501   const int num_granules = (int)(word_size / Settings::commit_granule_words());
       
   502   for (int i = 1; i < num_granules; i += 4) {
       
   503     b = node->ensure_range_is_committed(node->base(), i * Settings::commit_granule_words());
       
   504     ASSERT_TRUE(b);
       
   505     ASSERT_EQ(node->committed_words(), i * Settings::commit_granule_words());
       
   506     ASSERT_EQ(node->committed_words(), scomm.get());
       
   507     DEBUG_ONLY(node->verify(true);)
       
   508     zap_range(node->base(), i * Settings::commit_granule_words());
       
   509   }
       
   510 
       
   511   node->uncommit_range(node->base(), node->word_size());
       
   512   ASSERT_EQ(node->committed_words(), (size_t)0);
       
   513   ASSERT_EQ(node->committed_words(), scomm.get());
       
   514   DEBUG_ONLY(node->verify(true);)
       
   515 
       
   516 }
       
   517 
       
   518 
   471 // Note: we unfortunately need TEST_VM even though the system tested
   519 // Note: we unfortunately need TEST_VM even though the system tested
   472 // should be pretty independent since we need things like os::vm_page_size()
   520 // should be pretty independent since we need things like os::vm_page_size()
   473 // which in turn need OS layer initialization.
   521 // which in turn need OS layer initialization.
   474 TEST_VM(metaspace, virtual_space_node_test_1) {
   522 TEST_VM(metaspace, virtual_space_node_test_1) {
   475   VirtualSpaceNodeTest test(metaspace::chklvl::MAX_CHUNK_WORD_SIZE,
   523   VirtualSpaceNodeTest test(metaspace::chklvl::MAX_CHUNK_WORD_SIZE,
   506         metaspace::chklvl::MAX_CHUNK_WORD_SIZE);
   554         metaspace::chklvl::MAX_CHUNK_WORD_SIZE);
   507     test.test_split_and_merge_chunks();
   555     test.test_split_and_merge_chunks();
   508   }
   556   }
   509 }
   557 }
   510 
   558 
   511 TEST_VM(metaspace, virtual_space_node_test_6) {
   559 TEST_VM(metaspace, virtual_space_node_test_7) {
   512   // Test large allocation and freeing.
   560   // Test large allocation and freeing.
   513   {
   561   {
   514     VirtualSpaceNodeTest test(metaspace::chklvl::MAX_CHUNK_WORD_SIZE * 100,
   562     VirtualSpaceNodeTest test(metaspace::chklvl::MAX_CHUNK_WORD_SIZE * 100,
   515         metaspace::chklvl::MAX_CHUNK_WORD_SIZE * 100);
   563         metaspace::chklvl::MAX_CHUNK_WORD_SIZE * 100);
   516     test.test_exhaust_node();
   564     test.test_exhaust_node();