< prev index next >

src/hotspot/share/memory/allocation.inline.hpp

Print this page
rev 48446 : 8195094: Fix type-O in "8159422: Very high Concurrent Mark mark stack contention"
Contributed-by: arno.zeller@sap.com


 146     FreeHeap(p);
 147 }
 148 
 149 template <class E>
 150 size_t MmapArrayAllocator<E>::size_for(size_t length) {
 151   size_t size = length * sizeof(E);
 152   int alignment = os::vm_allocation_granularity();
 153   return align_up(size, alignment);
 154 }
 155 
 156 template <class E>
 157 E* MmapArrayAllocator<E>::allocate_or_null(size_t length, MEMFLAGS flags) {
 158   size_t size = size_for(length);
 159   int alignment = os::vm_allocation_granularity();
 160 
 161   char* addr = os::reserve_memory(size, NULL, alignment, flags);
 162   if (addr == NULL) {
 163     return NULL;
 164   }
 165 
 166   if (os::commit_memory(addr, size, !ExecMem, "Allocator (commit)")) {
 167     return (E*)addr;
 168   } else {
 169     os::release_memory(addr, size);
 170     return NULL;
 171   }
 172 }
 173 
 174 template <class E>
 175 E* MmapArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
 176   size_t size = size_for(length);
 177   int alignment = os::vm_allocation_granularity();
 178 
 179   char* addr = os::reserve_memory(size, NULL, alignment, flags);
 180   if (addr == NULL) {
 181     vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)");
 182   }
 183 
 184   os::commit_memory_or_exit(addr, size, !ExecMem, "Allocator (commit)");
 185 
 186   return (E*)addr;




 146     FreeHeap(p);
 147 }
 148 
 149 template <class E>
 150 size_t MmapArrayAllocator<E>::size_for(size_t length) {
 151   size_t size = length * sizeof(E);
 152   int alignment = os::vm_allocation_granularity();
 153   return align_up(size, alignment);
 154 }
 155 
 156 template <class E>
 157 E* MmapArrayAllocator<E>::allocate_or_null(size_t length, MEMFLAGS flags) {
 158   size_t size = size_for(length);
 159   int alignment = os::vm_allocation_granularity();
 160 
 161   char* addr = os::reserve_memory(size, NULL, alignment, flags);
 162   if (addr == NULL) {
 163     return NULL;
 164   }
 165 
 166   if (os::commit_memory(addr, size, !ExecMem)) {
 167     return (E*)addr;
 168   } else {
 169     os::release_memory(addr, size);
 170     return NULL;
 171   }
 172 }
 173 
 174 template <class E>
 175 E* MmapArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
 176   size_t size = size_for(length);
 177   int alignment = os::vm_allocation_granularity();
 178 
 179   char* addr = os::reserve_memory(size, NULL, alignment, flags);
 180   if (addr == NULL) {
 181     vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "Allocator (reserve)");
 182   }
 183 
 184   os::commit_memory_or_exit(addr, size, !ExecMem, "Allocator (commit)");
 185 
 186   return (E*)addr;


< prev index next >