8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly
authorbrutisso
Wed, 25 Sep 2013 17:23:41 +0200
changeset 20084 a61ec6d55abc
parent 20083 df032615dd00
child 20085 f27fdaa8f89a
child 20305 af013cf4a5e6
8025228: assert(new_entry->reserved_words() == vs_word_size) fails in nightly Reviewed-by: mgerdin, tschatzl, jmasa
hotspot/src/share/vm/memory/metaspace.cpp
hotspot/src/share/vm/prims/jni.cpp
--- a/hotspot/src/share/vm/memory/metaspace.cpp	Wed Sep 25 13:25:24 2013 +0200
+++ b/hotspot/src/share/vm/memory/metaspace.cpp	Wed Sep 25 17:23:41 2013 +0200
@@ -1095,7 +1095,7 @@
   }
   // Reserve the space
   size_t vs_byte_size = vs_word_size * BytesPerWord;
-  assert(vs_byte_size % os::vm_page_size() == 0, "Not aligned");
+  assert(vs_byte_size % os::vm_allocation_granularity() == 0, "Not aligned");
 
   // Allocate the meta virtual space and initialize it.
   VirtualSpaceNode* new_entry = new VirtualSpaceNode(vs_byte_size);
@@ -1167,12 +1167,14 @@
       // being used for CompressedHeaders, don't allocate a new virtualspace.
       if (can_grow() && MetaspaceGC::should_expand(this, word_size)) {
         // Get another virtual space.
-          size_t grow_vs_words =
-            MAX2((size_t)VirtualSpaceSize, aligned_expand_vs_by_words);
+        size_t allocation_aligned_expand_words =
+            align_size_up(aligned_expand_vs_by_words, os::vm_allocation_granularity() / BytesPerWord);
+        size_t grow_vs_words =
+            MAX2((size_t)VirtualSpaceSize, allocation_aligned_expand_words);
         if (grow_vs(grow_vs_words)) {
           // Got it.  It's on the list now.  Get a chunk from it.
           assert(current_virtual_space()->expanded_words() == 0,
-              "New virtuals space nodes should not have expanded");
+              "New virtual space nodes should not have expanded");
 
           size_t grow_chunks_by_words_aligned = align_size_up(grow_chunks_by_words,
                                                               page_size_words);
@@ -3357,7 +3359,7 @@
 
 #ifndef PRODUCT
 
-class MetaspaceAuxTest : AllStatic {
+class TestMetaspaceAuxTest : AllStatic {
  public:
   static void test_reserved() {
     size_t reserved = MetaspaceAux::reserved_bytes();
@@ -3397,14 +3399,25 @@
     }
   }
 
+  static void test_virtual_space_list_large_chunk() {
+    VirtualSpaceList* vs_list = new VirtualSpaceList(os::vm_allocation_granularity());
+    MutexLockerEx cl(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag);
+    // A size larger than VirtualSpaceSize (256k) and add one page to make it _not_ be
+    // vm_allocation_granularity aligned on Windows.
+    size_t large_size = (size_t)(2*256*K + (os::vm_page_size()/BytesPerWord));
+    large_size += (os::vm_page_size()/BytesPerWord);
+    vs_list->get_new_chunk(large_size, large_size, 0);
+  }
+
   static void test() {
     test_reserved();
     test_committed();
+    test_virtual_space_list_large_chunk();
   }
 };
 
-void MetaspaceAux_test() {
-  MetaspaceAuxTest::test();
+void TestMetaspaceAux_test() {
+  TestMetaspaceAuxTest::test();
 }
 
 #endif
--- a/hotspot/src/share/vm/prims/jni.cpp	Wed Sep 25 13:25:24 2013 +0200
+++ b/hotspot/src/share/vm/prims/jni.cpp	Wed Sep 25 17:23:41 2013 +0200
@@ -5046,7 +5046,7 @@
 void TestReservedSpace_test();
 void TestReserveMemorySpecial_test();
 void TestVirtualSpace_test();
-void MetaspaceAux_test();
+void TestMetaspaceAux_test();
 #if INCLUDE_ALL_GCS
 void TestG1BiasedArray_test();
 #endif
@@ -5057,7 +5057,7 @@
     run_unit_test(TestReservedSpace_test());
     run_unit_test(TestReserveMemorySpecial_test());
     run_unit_test(TestVirtualSpace_test());
-    run_unit_test(MetaspaceAux_test());
+    run_unit_test(TestMetaspaceAux_test());
     run_unit_test(GlobalDefinitions::test_globals());
     run_unit_test(GCTimerAllTest::all());
     run_unit_test(arrayOopDesc::test_max_array_length());