hotspot/src/share/vm/memory/allocation.hpp
changeset 37057 03b3e1870228
parent 33097 96e348cb0442
child 37092 0e56e3c9d545
--- a/hotspot/src/share/vm/memory/allocation.hpp	Thu Feb 25 13:08:19 2016 +0100
+++ b/hotspot/src/share/vm/memory/allocation.hpp	Wed Mar 09 12:44:12 2016 +0100
@@ -724,30 +724,23 @@
 // is set so that we always use malloc except for Solaris where we set the
 // limit to get mapped memory.
 template <class E, MEMFLAGS F>
-class ArrayAllocator VALUE_OBJ_CLASS_SPEC {
-  char* _addr;
-  bool _use_malloc;
-  size_t _size;
-  bool _free_in_destructor;
+class ArrayAllocator : public AllStatic {
+ private:
+  static bool should_use_malloc(size_t length);
+
+  static size_t size_for_malloc(size_t length);
+  static size_t size_for_mmap(size_t length);
 
-  static bool should_use_malloc(size_t size) {
-    return size < ArrayAllocatorMallocLimit;
-  }
+  static E* allocate_malloc(size_t length);
+  static E* allocate_mmap(size_t length);
 
-  static char* allocate_inner(size_t& size, bool& use_malloc);
+  static void free_malloc(E* addr, size_t length);
+  static void free_mmap(E* addr, size_t length);
+
  public:
-  ArrayAllocator(bool free_in_destructor = true) :
-    _addr(NULL), _use_malloc(false), _size(0), _free_in_destructor(free_in_destructor) { }
-
-  ~ArrayAllocator() {
-    if (_free_in_destructor) {
-      free();
-    }
-  }
-
-  E* allocate(size_t length);
-  E* reallocate(size_t new_length);
-  void free();
+  static E* allocate(size_t length);
+  static E* reallocate(E* old_addr, size_t old_length, size_t new_length);
+  static void free(E* addr, size_t length);
 };
 
 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP