< prev index next >

src/share/vm/memory/allocation.hpp

Print this page
rev 13100 : imported patch 8182169-arrayallocator-should-take-memflag-parameter


 696 // Code which uses REALLOC_RESOURCE_ARRAY should check an associated
 697 // ReallocMark, which is declared in the same scope as the reallocated
 698 // pointer.  Any operation that could __potentially__ cause a reallocation
 699 // should check the ReallocMark.
 700 class ReallocMark: public StackObj {
 701 protected:
 702   NOT_PRODUCT(int _nesting;)
 703 
 704 public:
 705   ReallocMark()   PRODUCT_RETURN;
 706   void check()    PRODUCT_RETURN;
 707 };
 708 
 709 // Helper class to allocate arrays that may become large.
 710 // Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
 711 // and uses mapped memory for larger allocations.
 712 // Most OS mallocs do something similar but Solaris malloc does not revert
 713 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
 714 // is set so that we always use malloc except for Solaris where we set the
 715 // limit to get mapped memory.
 716 template <class E, MEMFLAGS F>
 717 class ArrayAllocator : public AllStatic {
 718  private:
 719   static bool should_use_malloc(size_t length);
 720 
 721   static E* allocate_malloc(size_t length);
 722   static E* allocate_mmap(size_t length);
 723 
 724   static void free_malloc(E* addr, size_t length);
 725   static void free_mmap(E* addr, size_t length);
 726 
 727  public:
 728   static E* allocate(size_t length);
 729   static E* reallocate(E* old_addr, size_t old_length, size_t new_length);
 730   static void free(E* addr, size_t length);
 731 };
 732 
 733 // Uses mmaped memory for all allocations. All allocations are initially
 734 // zero-filled. No pre-touching.
 735 template <class E, MEMFLAGS F>
 736 class MmapArrayAllocator : public AllStatic {
 737  private:
 738   static size_t size_for(size_t length);
 739 
 740  public:
 741   static E* allocate_or_null(size_t length);
 742   static E* allocate(size_t length);
 743   static void free(E* addr, size_t length);
 744 };
 745 
 746 // Uses malloc:ed memory for all allocations.
 747 template <class E, MEMFLAGS F>
 748 class MallocArrayAllocator : public AllStatic {
 749  public:
 750   static size_t size_for(size_t length);
 751 
 752   static E* allocate(size_t length);
 753   static void free(E* addr, size_t length);
 754 };
 755 
 756 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP


 696 // Code which uses REALLOC_RESOURCE_ARRAY should check an associated
 697 // ReallocMark, which is declared in the same scope as the reallocated
 698 // pointer.  Any operation that could __potentially__ cause a reallocation
 699 // should check the ReallocMark.
 700 class ReallocMark: public StackObj {
 701 protected:
 702   NOT_PRODUCT(int _nesting;)
 703 
 704 public:
 705   ReallocMark()   PRODUCT_RETURN;
 706   void check()    PRODUCT_RETURN;
 707 };
 708 
 709 // Helper class to allocate arrays that may become large.
 710 // Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
 711 // and uses mapped memory for larger allocations.
 712 // Most OS mallocs do something similar but Solaris malloc does not revert
 713 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
 714 // is set so that we always use malloc except for Solaris where we set the
 715 // limit to get mapped memory.
 716 template <class E>
 717 class ArrayAllocator : public AllStatic {
 718  private:
 719   static bool should_use_malloc(size_t length);
 720 
 721   static E* allocate_malloc(size_t length, MEMFLAGS flags);
 722   static E* allocate_mmap(size_t length, MEMFLAGS flags);
 723 
 724   static void free_malloc(E* addr, size_t length);
 725   static void free_mmap(E* addr, size_t length);
 726 
 727  public:
 728   static E* allocate(size_t length, MEMFLAGS flags);
 729   static E* reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags);
 730   static void free(E* addr, size_t length);
 731 };
 732 
 733 // Uses mmaped memory for all allocations. All allocations are initially
 734 // zero-filled. No pre-touching.
 735 template <class E>
 736 class MmapArrayAllocator : public AllStatic {
 737  private:
 738   static size_t size_for(size_t length);
 739 
 740  public:
 741   static E* allocate_or_null(size_t length, MEMFLAGS flags);
 742   static E* allocate(size_t length, MEMFLAGS flags);
 743   static void free(E* addr, size_t length);
 744 };
 745 
 746 // Uses malloc:ed memory for all allocations.
 747 template <class E>
 748 class MallocArrayAllocator : public AllStatic {
 749  public:
 750   static size_t size_for(size_t length);
 751 
 752   static E* allocate(size_t length, MEMFLAGS flags);
 753   static void free(E* addr, size_t length);
 754 };
 755 
 756 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP
< prev index next >