26 # include "incls/_allocation.cpp.incl" 27 28 void* CHeapObj::operator new(size_t size){ 29 return (void *) AllocateHeap(size, "CHeapObj-new"); 30 } 31 32 void CHeapObj::operator delete(void* p){ 33 FreeHeap(p); 34 } 35 36 void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 37 void StackObj::operator delete(void* p) { ShouldNotCallThis(); }; 38 void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 39 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }; 40 41 void* ResourceObj::operator new(size_t size, allocation_type type) { 42 address res; 43 switch (type) { 44 case C_HEAP: 45 res = (address)AllocateHeap(size, "C_Heap: ResourceOBJ"); 46 break; 47 case RESOURCE_AREA: 48 res = (address)operator new(size); 49 break; 50 default: 51 ShouldNotReachHere(); 52 } 53 // Set allocation type in the resource object for assertion checks. 54 DEBUG_ONLY(((ResourceObj *)res)->_allocation = type;) 55 return res; 56 } 57 58 void ResourceObj::operator delete(void* p) { 59 assert(((ResourceObj *)p)->allocated_on_C_heap(), 60 "delete only allowed for C_HEAP objects"); 61 FreeHeap(p); 62 } 63 64 void trace_heap_malloc(size_t size, const char* name, void* p) { 65 // A lock is not needed here - tty uses a lock internally 66 tty->print_cr("Heap malloc " INTPTR_FORMAT " %7d %s", p, size, name == NULL ? "" : name); 67 } 68 69 70 void trace_heap_free(void* p) { 71 // A lock is not needed here - tty uses a lock internally 72 tty->print_cr("Heap free " INTPTR_FORMAT, p); 73 } 74 | 26 # include "incls/_allocation.cpp.incl" 27 28 void* CHeapObj::operator new(size_t size){ 29 return (void *) AllocateHeap(size, "CHeapObj-new"); 30 } 31 32 void CHeapObj::operator delete(void* p){ 33 FreeHeap(p); 34 } 35 36 void* StackObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 37 void StackObj::operator delete(void* p) { ShouldNotCallThis(); }; 38 void* _ValueObj::operator new(size_t size) { ShouldNotCallThis(); return 0; }; 39 void _ValueObj::operator delete(void* p) { ShouldNotCallThis(); }; 40 41 void* ResourceObj::operator new(size_t size, allocation_type type) { 42 address res; 43 switch (type) { 44 case C_HEAP: 45 res = (address)AllocateHeap(size, "C_Heap: ResourceOBJ"); 46 DEBUG_ONLY(set_allocation_type(res, C_HEAP);) 47 break; 48 case RESOURCE_AREA: 49 // Will set allocation type in the resource object. 50 res = (address)operator new(size); 51 break; 52 default: 53 ShouldNotReachHere(); 54 } 55 return res; 56 } 57 58 void ResourceObj::operator delete(void* p) { 59 assert(((ResourceObj *)p)->allocated_on_C_heap(), 60 "delete only allowed for C_HEAP objects"); 61 FreeHeap(p); 62 } 63 64 void trace_heap_malloc(size_t size, const char* name, void* p) { 65 // A lock is not needed here - tty uses a lock internally 66 tty->print_cr("Heap malloc " INTPTR_FORMAT " %7d %s", p, size, name == NULL ? "" : name); 67 } 68 69 70 void trace_heap_free(void* p) { 71 // A lock is not needed here - tty uses a lock internally 72 tty->print_cr("Heap free " INTPTR_FORMAT, p); 73 } 74 |