--- old/src/share/vm/gc/g1/g1CardLiveData.cpp 2017-06-14 14:52:22.856389672 +0200 +++ new/src/share/vm/gc/g1/g1CardLiveData.cpp 2017-06-14 14:52:22.730385827 +0200 @@ -54,13 +54,13 @@ G1CardLiveData::bm_word_t* G1CardLiveData::allocate_large_bitmap(size_t size_in_bits) { size_t size_in_words = BitMap::calc_size_in_words(size_in_bits); - bm_word_t* map = MmapArrayAllocator::allocate(size_in_words); + bm_word_t* map = MmapArrayAllocator::allocate(size_in_words, mtGC); return map; } void G1CardLiveData::free_large_bitmap(bm_word_t* bitmap, size_t size_in_bits) { - MmapArrayAllocator::free(bitmap, BitMap::calc_size_in_words(size_in_bits)); + MmapArrayAllocator::free(bitmap, BitMap::calc_size_in_words(size_in_bits)); } void G1CardLiveData::initialize(size_t max_capacity, uint num_max_regions) { --- old/src/share/vm/gc/g1/g1ConcurrentMark.cpp 2017-06-14 14:52:23.465408258 +0200 +++ new/src/share/vm/gc/g1/g1ConcurrentMark.cpp 2017-06-14 14:52:23.337404351 +0200 @@ -144,7 +144,7 @@ assert(new_capacity <= _max_chunk_capacity, "Trying to resize stack to " SIZE_FORMAT " chunks when the maximum is " SIZE_FORMAT, new_capacity, _max_chunk_capacity); - TaskQueueEntryChunk* new_base = MmapArrayAllocator::allocate_or_null(new_capacity); + TaskQueueEntryChunk* new_base = MmapArrayAllocator::allocate_or_null(new_capacity, mtGC); if (new_base == NULL) { log_warning(gc)("Failed to reserve memory for new overflow mark stack with " SIZE_FORMAT " chunks and size " SIZE_FORMAT "B.", new_capacity, new_capacity * sizeof(TaskQueueEntryChunk)); @@ -152,7 +152,7 @@ } // Release old mapping. if (_base != NULL) { - MmapArrayAllocator::free(_base, _chunk_capacity); + MmapArrayAllocator::free(_base, _chunk_capacity); } _base = new_base; @@ -205,7 +205,7 @@ G1CMMarkStack::~G1CMMarkStack() { if (_base != NULL) { - MmapArrayAllocator::free(_base, _chunk_capacity); + MmapArrayAllocator::free(_base, _chunk_capacity); } } --- old/src/share/vm/gc/g1/g1HotCardCache.cpp 2017-06-14 14:52:24.118428186 +0200 +++ new/src/share/vm/gc/g1/g1HotCardCache.cpp 2017-06-14 14:52:23.993424371 +0200 @@ -36,7 +36,7 @@ _use_cache = true; _hot_cache_size = (size_t)1 << G1ConcRSLogCacheSize; - _hot_cache = ArrayAllocator::allocate(_hot_cache_size); + _hot_cache = ArrayAllocator::allocate(_hot_cache_size, mtGC); reset_hot_cache_internal(); @@ -51,7 +51,7 @@ G1HotCardCache::~G1HotCardCache() { if (default_use_cache()) { assert(_hot_cache != NULL, "Logic"); - ArrayAllocator::free(_hot_cache, _hot_cache_size); + ArrayAllocator::free(_hot_cache, _hot_cache_size); _hot_cache = NULL; } } --- old/src/share/vm/gc/shared/taskqueue.inline.hpp 2017-06-14 14:52:24.735447015 +0200 +++ new/src/share/vm/gc/shared/taskqueue.inline.hpp 2017-06-14 14:52:24.611443231 +0200 @@ -44,13 +44,13 @@ template inline void GenericTaskQueue::initialize() { - _elems = ArrayAllocator::allocate(N); + _elems = ArrayAllocator::allocate(N, F); } template inline GenericTaskQueue::~GenericTaskQueue() { assert(false, "This code is currently never called"); - ArrayAllocator::free(const_cast(_elems), N); + ArrayAllocator::free(const_cast(_elems), N); } template --- old/src/share/vm/memory/allocation.hpp 2017-06-14 14:52:25.344465600 +0200 +++ new/src/share/vm/memory/allocation.hpp 2017-06-14 14:52:25.216461694 +0200 @@ -713,43 +713,43 @@ // to mapped memory for large allocations. By default ArrayAllocatorMallocLimit // is set so that we always use malloc except for Solaris where we set the // limit to get mapped memory. -template +template class ArrayAllocator : public AllStatic { private: static bool should_use_malloc(size_t length); - static E* allocate_malloc(size_t length); - static E* allocate_mmap(size_t length); + static E* allocate_malloc(size_t length, MEMFLAGS flags); + static E* allocate_mmap(size_t length, MEMFLAGS flags); static void free_malloc(E* addr, size_t length); static void free_mmap(E* addr, size_t length); public: - static E* allocate(size_t length); - static E* reallocate(E* old_addr, size_t old_length, size_t new_length); + static E* allocate(size_t length, MEMFLAGS flags); + static E* reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags); static void free(E* addr, size_t length); }; // Uses mmaped memory for all allocations. All allocations are initially // zero-filled. No pre-touching. -template +template class MmapArrayAllocator : public AllStatic { private: static size_t size_for(size_t length); public: - static E* allocate_or_null(size_t length); - static E* allocate(size_t length); + static E* allocate_or_null(size_t length, MEMFLAGS flags); + static E* allocate(size_t length, MEMFLAGS flags); static void free(E* addr, size_t length); }; // Uses malloc:ed memory for all allocations. -template +template class MallocArrayAllocator : public AllStatic { public: static size_t size_for(size_t length); - static E* allocate(size_t length); + static E* allocate(size_t length, MEMFLAGS flags); static void free(E* addr, size_t length); }; --- old/src/share/vm/memory/allocation.inline.hpp 2017-06-14 14:52:25.963484491 +0200 +++ new/src/share/vm/memory/allocation.inline.hpp 2017-06-14 14:52:25.839480706 +0200 @@ -145,19 +145,19 @@ FreeHeap(p); } -template -size_t MmapArrayAllocator::size_for(size_t length) { +template +size_t MmapArrayAllocator::size_for(size_t length) { size_t size = length * sizeof(E); int alignment = os::vm_allocation_granularity(); return align_size_up(size, alignment); } -template -E* MmapArrayAllocator::allocate_or_null(size_t length) { +template +E* MmapArrayAllocator::allocate_or_null(size_t length, MEMFLAGS flags) { size_t size = size_for(length); int alignment = os::vm_allocation_granularity(); - char* addr = os::reserve_memory(size, NULL, alignment, F); + char* addr = os::reserve_memory(size, NULL, alignment, flags); if (addr == NULL) { return NULL; } @@ -170,12 +170,12 @@ } } -template -E* MmapArrayAllocator::allocate(size_t length) { +template +E* MmapArrayAllocator::allocate(size_t length, MEMFLAGS flags) { size_t size = size_for(length); int alignment = os::vm_allocation_granularity(); - char* addr = os::reserve_memory(size, NULL, alignment, F); + char* addr = os::reserve_memory(size, NULL, alignment, flags); if (addr == NULL) { vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)"); } @@ -185,55 +185,55 @@ return (E*)addr; } -template -void MmapArrayAllocator::free(E* addr, size_t length) { +template +void MmapArrayAllocator::free(E* addr, size_t length) { bool result = os::release_memory((char*)addr, size_for(length)); assert(result, "Failed to release memory"); } -template -size_t MallocArrayAllocator::size_for(size_t length) { +template +size_t MallocArrayAllocator::size_for(size_t length) { return length * sizeof(E); } -template -E* MallocArrayAllocator::allocate(size_t length) { - return (E*)AllocateHeap(size_for(length), F); +template +E* MallocArrayAllocator::allocate(size_t length, MEMFLAGS flags) { + return (E*)AllocateHeap(size_for(length), flags); } -template -void MallocArrayAllocator::free(E* addr, size_t /*length*/) { +template +void MallocArrayAllocator::free(E* addr, size_t /*length*/) { FreeHeap(addr); } -template -bool ArrayAllocator::should_use_malloc(size_t length) { - return MallocArrayAllocator::size_for(length) < ArrayAllocatorMallocLimit; +template +bool ArrayAllocator::should_use_malloc(size_t length) { + return MallocArrayAllocator::size_for(length) < ArrayAllocatorMallocLimit; } -template -E* ArrayAllocator::allocate_malloc(size_t length) { - return MallocArrayAllocator::allocate(length); +template +E* ArrayAllocator::allocate_malloc(size_t length, MEMFLAGS flags) { + return MallocArrayAllocator::allocate(length, flags); } -template -E* ArrayAllocator::allocate_mmap(size_t length) { - return MmapArrayAllocator::allocate(length); +template +E* ArrayAllocator::allocate_mmap(size_t length, MEMFLAGS flags) { + return MmapArrayAllocator::allocate(length, flags); } -template -E* ArrayAllocator::allocate(size_t length) { +template +E* ArrayAllocator::allocate(size_t length, MEMFLAGS flags) { if (should_use_malloc(length)) { - return allocate_malloc(length); + return allocate_malloc(length, flags); } - return allocate_mmap(length); + return allocate_mmap(length, flags); } -template -E* ArrayAllocator::reallocate(E* old_addr, size_t old_length, size_t new_length) { +template +E* ArrayAllocator::reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags) { E* new_addr = (new_length > 0) - ? allocate(new_length) + ? allocate(new_length, flags) : NULL; if (new_addr != NULL && old_addr != NULL) { @@ -247,18 +247,18 @@ return new_addr; } -template -void ArrayAllocator::free_malloc(E* addr, size_t length) { - MallocArrayAllocator::free(addr, length); +template +void ArrayAllocator::free_malloc(E* addr, size_t length) { + MallocArrayAllocator::free(addr, length); } -template -void ArrayAllocator::free_mmap(E* addr, size_t length) { - MmapArrayAllocator::free(addr, length); +template +void ArrayAllocator::free_mmap(E* addr, size_t length) { + MmapArrayAllocator::free(addr, length); } -template -void ArrayAllocator::free(E* addr, size_t length) { +template +void ArrayAllocator::free(E* addr, size_t length) { if (addr != NULL) { if (should_use_malloc(length)) { free_malloc(addr, length); --- old/src/share/vm/utilities/bitMap.cpp 2017-06-14 14:52:26.631504876 +0200 +++ new/src/share/vm/utilities/bitMap.cpp 2017-06-14 14:52:26.508501123 +0200 @@ -48,10 +48,10 @@ class CHeapBitMapAllocator : StackObj { public: bm_word_t* allocate(size_t size_in_words) const { - return ArrayAllocator::allocate(size_in_words); + return ArrayAllocator::allocate(size_in_words, mtInternal); } void free(bm_word_t* map, idx_t size_in_words) const { - ArrayAllocator::free(map, size_in_words); + ArrayAllocator::free(map, size_in_words); } };