changeset 26934:8a3682c071be

8058963: CollectorPolicy::satisfy_failed_metadata_allocation can avoid some safepoints Reviewed-by: brutisso, mgerdin
author ehelin
date Mon, 29 Sep 2014 10:38:50 +0200
parents 33d6fa41d290
children bcad74f0aa70
files hotspot/src/share/vm/memory/collectorPolicy.cpp hotspot/src/share/vm/memory/metaspace.hpp
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/memory/collectorPolicy.cpp	Sat Sep 27 15:11:41 2014 +0200
+++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp	Mon Sep 29 10:38:50 2014 +0200
@@ -817,7 +817,11 @@
   assert(!Heap_lock->owned_by_self(), "Should not be holding the Heap_lock");
 
   do {
-    MetaWord* result = NULL;
+    MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
+    if (result != NULL) {
+      return result;
+    }
+
     if (GC_locker::is_active_and_needs_gc()) {
       // If the GC_locker is active, just expand and allocate.
       // If that does not succeed, wait if this thread is not
--- a/hotspot/src/share/vm/memory/metaspace.hpp	Sat Sep 27 15:11:41 2014 +0200
+++ b/hotspot/src/share/vm/memory/metaspace.hpp	Mon Sep 29 10:38:50 2014 +0200
@@ -87,6 +87,7 @@
   friend class VM_CollectForMetadataAllocation;
   friend class MetaspaceGC;
   friend class MetaspaceAux;
+  friend class CollectorPolicy;
 
  public:
   enum MetadataType {
@@ -144,6 +145,8 @@
   //   allocate(ClassLoaderData*, size_t, bool, MetadataType, TRAPS)
   MetaWord* allocate(size_t word_size, MetadataType mdtype);
 
+  MetaWord* expand_and_allocate(size_t size, MetadataType mdtype);
+
   // Virtual Space lists for both classes and other metadata
   static VirtualSpaceList* _space_list;
   static VirtualSpaceList* _class_space_list;
@@ -234,9 +237,6 @@
                             bool read_only, MetaspaceObj::Type type, TRAPS);
   void deallocate(MetaWord* ptr, size_t byte_size, bool is_class);
 
-  MetaWord* expand_and_allocate(size_t size,
-                                MetadataType mdtype);
-
   static bool contains(const void* ptr);
 
   void dump(outputStream* const out) const;