< prev index next >

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

Print this page




 132   return CHeapObj<F>::operator new(size, nothrow_constant, stack);
 133 }
 134 
 135 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
 136   const std::nothrow_t& nothrow_constant) throw() {
 137   return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
 138 }
 139 
 140 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){
 141     FreeHeap(p);
 142 }
 143 
 144 template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){
 145     FreeHeap(p);
 146 }
 147 
 148 template <class E, MEMFLAGS F>
 149 size_t MmapArrayAllocator<E, F>::size_for(size_t length) {
 150   size_t size = length * sizeof(E);
 151   int alignment = os::vm_allocation_granularity();
 152   return align_size_up(size, alignment);
 153 }
 154 
 155 template <class E, MEMFLAGS F>
 156 E* MmapArrayAllocator<E, F>::allocate_or_null(size_t length) {
 157   size_t size = size_for(length);
 158   int alignment = os::vm_allocation_granularity();
 159 
 160   char* addr = os::reserve_memory(size, NULL, alignment, F);
 161   if (addr == NULL) {
 162     return NULL;
 163   }
 164 
 165   if (os::commit_memory(addr, size, !ExecMem, "Allocator (commit)")) {
 166     return (E*)addr;
 167   } else {
 168     os::release_memory(addr, size);
 169     return NULL;
 170   }
 171 }
 172 




 132   return CHeapObj<F>::operator new(size, nothrow_constant, stack);
 133 }
 134 
 135 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
 136   const std::nothrow_t& nothrow_constant) throw() {
 137   return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
 138 }
 139 
 140 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){
 141     FreeHeap(p);
 142 }
 143 
 144 template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){
 145     FreeHeap(p);
 146 }
 147 
 148 template <class E, MEMFLAGS F>
 149 size_t MmapArrayAllocator<E, F>::size_for(size_t length) {
 150   size_t size = length * sizeof(E);
 151   int alignment = os::vm_allocation_granularity();
 152   return align_up(size, alignment);
 153 }
 154 
 155 template <class E, MEMFLAGS F>
 156 E* MmapArrayAllocator<E, F>::allocate_or_null(size_t length) {
 157   size_t size = size_for(length);
 158   int alignment = os::vm_allocation_granularity();
 159 
 160   char* addr = os::reserve_memory(size, NULL, alignment, F);
 161   if (addr == NULL) {
 162     return NULL;
 163   }
 164 
 165   if (os::commit_memory(addr, size, !ExecMem, "Allocator (commit)")) {
 166     return (E*)addr;
 167   } else {
 168     os::release_memory(addr, size);
 169     return NULL;
 170   }
 171 }
 172 


< prev index next >