8037952: Remove code duplication in Metaspace::deallocate
authorstefank
Thu, 20 Mar 2014 15:03:18 +0100
changeset 23503 84698692e4ef
parent 23473 d94be023b00d
child 23504 6636d4e1b042
8037952: Remove code duplication in Metaspace::deallocate Reviewed-by: tschatzl, pliden, coleenp
hotspot/src/share/vm/memory/metaspace.cpp
--- a/hotspot/src/share/vm/memory/metaspace.cpp	Thu Mar 20 15:53:17 2014 +0100
+++ b/hotspot/src/share/vm/memory/metaspace.cpp	Thu Mar 20 15:03:18 2014 +0100
@@ -3343,37 +3343,22 @@
 }
 
 void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
-  if (SafepointSynchronize::is_at_safepoint()) {
-    assert(Thread::current()->is_VM_thread(), "should be the VM thread");
-    // Don't take Heap_lock
-    MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
-    if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
-      // Dark matter.  Too small for dictionary.
+  assert(!SafepointSynchronize::is_at_safepoint()
+         || Thread::current()->is_VM_thread(), "should be the VM thread");
+
+  MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
+
+  if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
+    // Dark matter.  Too small for dictionary.
 #ifdef ASSERT
-      Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
+    Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
 #endif
-      return;
-    }
-    if (is_class && using_class_space()) {
-      class_vsm()->deallocate(ptr, word_size);
-    } else {
-      vsm()->deallocate(ptr, word_size);
-    }
+    return;
+  }
+  if (is_class && using_class_space()) {
+    class_vsm()->deallocate(ptr, word_size);
   } else {
-    MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag);
-
-    if (word_size < TreeChunk<Metablock, FreeList<Metablock> >::min_size()) {
-      // Dark matter.  Too small for dictionary.
-#ifdef ASSERT
-      Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5);
-#endif
-      return;
-    }
-    if (is_class && using_class_space()) {
-      class_vsm()->deallocate(ptr, word_size);
-    } else {
-      vsm()->deallocate(ptr, word_size);
-    }
+    vsm()->deallocate(ptr, word_size);
   }
 }