711 protected: 712 NOT_PRODUCT(int _nesting;) 713 714 public: 715 ReallocMark() PRODUCT_RETURN; 716 void check() PRODUCT_RETURN; 717 }; 718 719 // Helper class to allocate arrays that may become large. 720 // Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit 721 // and uses mapped memory for larger allocations. 722 // Most OS mallocs do something similar but Solaris malloc does not revert 723 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit 724 // is set so that we always use malloc except for Solaris where we set the 725 // limit to get mapped memory. 726 template <class E, MEMFLAGS F> 727 class ArrayAllocator : public AllStatic { 728 private: 729 static bool should_use_malloc(size_t length); 730 731 static size_t size_for_malloc(size_t length); 732 static size_t size_for_mmap(size_t length); 733 734 static E* allocate_malloc(size_t length); 735 static E* allocate_mmap(size_t length); 736 737 static void free_malloc(E* addr, size_t length); 738 static void free_mmap(E* addr, size_t length); 739 740 public: 741 static E* allocate(size_t length); 742 static E* reallocate(E* old_addr, size_t old_length, size_t new_length); 743 static void free(E* addr, size_t length); 744 }; 745 746 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP | 711 protected: 712 NOT_PRODUCT(int _nesting;) 713 714 public: 715 ReallocMark() PRODUCT_RETURN; 716 void check() PRODUCT_RETURN; 717 }; 718 719 // Helper class to allocate arrays that may become large. 720 // Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit 721 // and uses mapped memory for larger allocations. 722 // Most OS mallocs do something similar but Solaris malloc does not revert 723 // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit 724 // is set so that we always use malloc except for Solaris where we set the 725 // limit to get mapped memory. 726 template <class E, MEMFLAGS F> 727 class ArrayAllocator : public AllStatic { 728 private: 729 static bool should_use_malloc(size_t length); 730 731 static E* allocate_malloc(size_t length); 732 static E* allocate_mmap(size_t length); 733 734 static void free_malloc(E* addr, size_t length); 735 static void free_mmap(E* addr, size_t length); 736 737 public: 738 static E* allocate(size_t length); 739 static E* reallocate(E* old_addr, size_t old_length, size_t new_length); 740 static void free(E* addr, size_t length); 741 }; 742 743 // Uses mmaped memory for all allocations. All allocations are initially 744 // zero-filled. No pre-touching. 745 template <class E, MEMFLAGS F> 746 class MmapArrayAllocator : public AllStatic { 747 private: 748 static size_t size_for(size_t length); 749 750 public: 751 static E* allocate(size_t length); 752 static void free(E* addr, size_t length); 753 }; 754 755 // Uses malloc:ed memory for all allocations. 756 template <class E, MEMFLAGS F> 757 class MallocArrayAllocator : public AllStatic { 758 public: 759 static size_t size_for(size_t length); 760 761 static E* allocate(size_t length); 762 static void free(E* addr, size_t length); 763 }; 764 765 #endif // SHARE_VM_MEMORY_ALLOCATION_HPP |