20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/genCollectedHeap.hpp" 27 #include "memory/allocation.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/arena.hpp" 30 #include "memory/metaspaceShared.hpp" 31 #include "memory/resourceArea.hpp" 32 #include "memory/universe.hpp" 33 #include "runtime/atomic.hpp" 34 #include "runtime/os.hpp" 35 #include "runtime/task.hpp" 36 #include "runtime/threadCritical.hpp" 37 #include "services/memTracker.hpp" 38 #include "utilities/ostream.hpp" 39 40 void* MetaspaceObj::_shared_metaspace_base = NULL; 41 void* MetaspaceObj::_shared_metaspace_top = NULL; 42 43 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } 44 void StackObj::operator delete(void* p) { ShouldNotCallThis(); } 45 void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; } 46 void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } 47 48 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, 49 size_t word_size, 50 MetaspaceObj::Type type, TRAPS) throw() { 51 // Klass has it's own operator new 52 return Metaspace::allocate(loader_data, word_size, type, THREAD); 53 } 54 55 bool MetaspaceObj::is_metaspace_object() const { 56 return Metaspace::contains((void*)this); 57 } 58 59 void MetaspaceObj::print_address_on(outputStream* st) const { | 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "gc/shared/genCollectedHeap.hpp" 27 #include "memory/allocation.hpp" 28 #include "memory/allocation.inline.hpp" 29 #include "memory/arena.hpp" 30 #include "memory/metaspaceShared.hpp" 31 #include "memory/resourceArea.hpp" 32 #include "memory/universe.hpp" 33 #include "runtime/atomic.hpp" 34 #include "runtime/os.hpp" 35 #include "runtime/task.hpp" 36 #include "runtime/threadCritical.hpp" 37 #include "services/memTracker.hpp" 38 #include "utilities/ostream.hpp" 39 40 // allocate using malloc; will fail if no memory available 41 char* AllocateHeap(size_t size, 42 MEMFLAGS flags, 43 const NativeCallStack& stack, 44 AllocFailType alloc_failmode) { 45 char* p = (char*) os::malloc(size, flags, stack); 46 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) { 47 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap"); 48 } 49 return p; 50 } 51 52 char* AllocateHeap(size_t size, 53 MEMFLAGS flags) { 54 return AllocateHeap(size, flags, CALLER_PC); 55 } 56 char* AllocateHeap(size_t size, 57 MEMFLAGS flags, 58 const std::nothrow_t& nothrow_constant) { 59 return AllocateHeap(size, flags, CALLER_PC, AllocFailStrategy::RETURN_NULL); 60 } 61 char* AllocateHeap(size_t size, 62 MEMFLAGS flags, 63 const std::nothrow_t& nothrow_constant, 64 const NativeCallStack& stack) { 65 return AllocateHeap(size, flags, stack, AllocFailStrategy::RETURN_NULL); 66 } 67 68 char* ReallocateHeap(char *old, 69 size_t size, 70 MEMFLAGS flag, 71 AllocFailType alloc_failmode) { 72 char* p = (char*) os::realloc(old, size, flag, CALLER_PC); 73 if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) { 74 vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap"); 75 } 76 return p; 77 } 78 79 void FreeHeap(void* p) { 80 os::free(p); 81 } 82 83 void* MetaspaceObj::_shared_metaspace_base = NULL; 84 void* MetaspaceObj::_shared_metaspace_top = NULL; 85 86 void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; } 87 void StackObj::operator delete(void* p) { ShouldNotCallThis(); } 88 void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; } 89 void StackObj::operator delete [](void* p) { ShouldNotCallThis(); } 90 91 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data, 92 size_t word_size, 93 MetaspaceObj::Type type, TRAPS) throw() { 94 // Klass has it's own operator new 95 return Metaspace::allocate(loader_data, word_size, type, THREAD); 96 } 97 98 bool MetaspaceObj::is_metaspace_object() const { 99 return Metaspace::contains((void*)this); 100 } 101 102 void MetaspaceObj::print_address_on(outputStream* st) const { |