Mercurial > hg > truffle
comparison src/share/vm/memory/allocation.inline.hpp @ 10130:6f817ce50129
8010992: Remove calls to global ::operator new[] and new
Summary: disable use of global operator new and new[] which could cause unexpected exception and escape from NMT tracking.
Reviewed-by: coleenp, dholmes, zgu
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Fri, 19 Apr 2013 11:08:52 -0700 |
parents | 83f27710f5f7 |
children | 5a9fa2ba85f0 |
comparison
equal
deleted
inserted
replaced
10129:7815eaceaa8c | 10130:6f817ce50129 |
---|---|
80 } | 80 } |
81 | 81 |
82 | 82 |
83 template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size, | 83 template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size, |
84 address caller_pc){ | 84 address caller_pc){ |
85 void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); | |
85 #ifdef ASSERT | 86 #ifdef ASSERT |
86 void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); | |
87 if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); | 87 if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); |
88 #endif | |
88 return p; | 89 return p; |
89 #else | |
90 return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC)); | |
91 #endif | |
92 } | 90 } |
93 | 91 |
94 template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size, | 92 template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size, |
95 const std::nothrow_t& nothrow_constant, address caller_pc) { | 93 const std::nothrow_t& nothrow_constant, address caller_pc) { |
96 #ifdef ASSERT | |
97 void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), | 94 void* p = (void*)AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), |
98 AllocFailStrategy::RETURN_NULL); | 95 AllocFailStrategy::RETURN_NULL); |
96 #ifdef ASSERT | |
99 if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); | 97 if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p); |
98 #endif | |
100 return p; | 99 return p; |
101 #else | 100 } |
102 return (void *) AllocateHeap(size, F, (caller_pc != 0 ? caller_pc : CALLER_PC), | 101 |
103 AllocFailStrategy::RETURN_NULL); | 102 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size, |
104 #endif | 103 address caller_pc){ |
104 return CHeapObj<F>::operator new(size, caller_pc); | |
105 } | |
106 | |
107 template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size, | |
108 const std::nothrow_t& nothrow_constant, address caller_pc) { | |
109 return CHeapObj<F>::operator new(size, nothrow_constant, caller_pc); | |
105 } | 110 } |
106 | 111 |
107 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){ | 112 template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){ |
108 FreeHeap(p, F); | 113 FreeHeap(p, F); |
114 } | |
115 | |
116 template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){ | |
117 FreeHeap(p, F); | |
109 } | 118 } |
110 | 119 |
111 template <class E, MEMFLAGS F> | 120 template <class E, MEMFLAGS F> |
112 E* ArrayAllocator<E, F>::allocate(size_t length) { | 121 E* ArrayAllocator<E, F>::allocate(size_t length) { |
113 assert(_addr == NULL, "Already in use"); | 122 assert(_addr == NULL, "Already in use"); |