mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-09 09:58:43 +00:00
8199698: Change 8199275 breaks template instantiation for xlC (and potentially other compliers)
Reviewed-by: stefank, coleenp
This commit is contained in:
parent
7cbffcf023
commit
d52d7a880e
@ -37,6 +37,39 @@
|
||||
#include "services/memTracker.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
// allocate using malloc; will fail if no memory available
|
||||
char* AllocateHeap(size_t size,
|
||||
MEMFLAGS flags,
|
||||
const NativeCallStack& stack,
|
||||
AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {
|
||||
char* p = (char*) os::malloc(size, flags, stack);
|
||||
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
|
||||
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
char* AllocateHeap(size_t size,
|
||||
MEMFLAGS flags,
|
||||
AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/) {
|
||||
return AllocateHeap(size, flags, CALLER_PC);
|
||||
}
|
||||
|
||||
char* ReallocateHeap(char *old,
|
||||
size_t size,
|
||||
MEMFLAGS flag,
|
||||
AllocFailType alloc_failmode) {
|
||||
char* p = (char*) os::realloc(old, size, flag, CALLER_PC);
|
||||
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
|
||||
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void FreeHeap(void* p) {
|
||||
os::free(p);
|
||||
}
|
||||
|
||||
void* MetaspaceObj::_shared_metaspace_base = NULL;
|
||||
void* MetaspaceObj::_shared_metaspace_top = NULL;
|
||||
|
||||
|
||||
@ -154,22 +154,61 @@ const bool NMT_track_callsite = false;
|
||||
class NativeCallStack;
|
||||
|
||||
|
||||
char* AllocateHeap(size_t size,
|
||||
MEMFLAGS flags,
|
||||
const NativeCallStack& stack,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
|
||||
char* AllocateHeap(size_t size,
|
||||
MEMFLAGS flags,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
|
||||
|
||||
char* ReallocateHeap(char *old,
|
||||
size_t size,
|
||||
MEMFLAGS flag,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
|
||||
|
||||
void FreeHeap(void* p);
|
||||
|
||||
template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||
public:
|
||||
NOINLINE void* operator new(size_t size, const NativeCallStack& stack) throw();
|
||||
NOINLINE void* operator new(size_t size) throw();
|
||||
NOINLINE void* operator new (size_t size, const std::nothrow_t& nothrow_constant,
|
||||
const NativeCallStack& stack) throw();
|
||||
NOINLINE void* operator new (size_t size, const std::nothrow_t& nothrow_constant)
|
||||
throw();
|
||||
NOINLINE void* operator new [](size_t size, const NativeCallStack& stack) throw();
|
||||
NOINLINE void* operator new [](size_t size) throw();
|
||||
NOINLINE void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
|
||||
const NativeCallStack& stack) throw();
|
||||
NOINLINE void* operator new [](size_t size, const std::nothrow_t& nothrow_constant)
|
||||
throw();
|
||||
void operator delete(void* p);
|
||||
void operator delete [] (void* p);
|
||||
ALWAYSINLINE void* operator new(size_t size) throw() {
|
||||
return (void*)AllocateHeap(size, F);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t&,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new(size_t size, const std::nothrow_t&) throw() {
|
||||
return (void*)AllocateHeap(size, F, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size) throw() {
|
||||
return (void*)AllocateHeap(size, F);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t&,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
ALWAYSINLINE void* operator new[](size_t size, const std::nothrow_t&) throw() {
|
||||
return (void*)AllocateHeap(size, F, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
void operator delete(void* p) { FreeHeap(p); }
|
||||
void operator delete [] (void* p) { FreeHeap(p); }
|
||||
};
|
||||
|
||||
// Base class for objects allocated on the stack only.
|
||||
|
||||
@ -48,83 +48,6 @@ inline void inc_stat_counter(volatile julong* dest, julong add_value) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// allocate using malloc; will fail if no memory available
|
||||
inline char* AllocateHeap(size_t size, MEMFLAGS flags,
|
||||
const NativeCallStack& stack,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
|
||||
char* p = (char*) os::malloc(size, flags, stack);
|
||||
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
|
||||
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "AllocateHeap");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
ALWAYSINLINE char* AllocateHeap(size_t size, MEMFLAGS flags,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
|
||||
return AllocateHeap(size, flags, CURRENT_PC, alloc_failmode);
|
||||
}
|
||||
|
||||
ALWAYSINLINE char* ReallocateHeap(char *old, size_t size, MEMFLAGS flag,
|
||||
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
|
||||
char* p = (char*) os::realloc(old, size, flag, CURRENT_PC);
|
||||
if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
|
||||
vm_exit_out_of_memory(size, OOM_MALLOC_ERROR, "ReallocateHeap");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
inline void FreeHeap(void* p) {
|
||||
os::free(p);
|
||||
}
|
||||
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new(size_t size) throw() {
|
||||
return CHeapObj<F>::operator new(size, CALLER_PC);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
|
||||
const std::nothrow_t& nothrow_constant, const NativeCallStack& stack) throw() {
|
||||
return (void*)AllocateHeap(size, F, stack, AllocFailStrategy::RETURN_NULL);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new (size_t size,
|
||||
const std::nothrow_t& nothrow_constant) throw() {
|
||||
return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
|
||||
const NativeCallStack& stack) throw() {
|
||||
return CHeapObj<F>::operator new(size, stack);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size)
|
||||
throw() {
|
||||
return CHeapObj<F>::operator new(size, CALLER_PC);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
|
||||
const std::nothrow_t& nothrow_constant, const NativeCallStack& stack) throw() {
|
||||
return CHeapObj<F>::operator new(size, nothrow_constant, stack);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void* CHeapObj<F>::operator new [](size_t size,
|
||||
const std::nothrow_t& nothrow_constant) throw() {
|
||||
return CHeapObj<F>::operator new(size, nothrow_constant, CALLER_PC);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void CHeapObj<F>::operator delete(void* p){
|
||||
FreeHeap(p);
|
||||
}
|
||||
|
||||
template <MEMFLAGS F> void CHeapObj<F>::operator delete [](void* p){
|
||||
FreeHeap(p);
|
||||
}
|
||||
|
||||
template <class E>
|
||||
size_t MmapArrayAllocator<E>::size_for(size_t length) {
|
||||
size_t size = length * sizeof(E);
|
||||
|
||||
@ -152,7 +152,18 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); }
|
||||
#endif
|
||||
|
||||
// Inlining support
|
||||
#define NOINLINE
|
||||
#define ALWAYSINLINE inline __attribute__((always_inline))
|
||||
//
|
||||
// Be aware that for function/method declarations, xlC only supports the following
|
||||
// syntax (i.e. the attribute must be placed AFTER the function/method declarator):
|
||||
//
|
||||
// void* operator new(size_t size) throw() NOINLINE;
|
||||
//
|
||||
// For function/method defintions, the more common placement BEFORE the
|
||||
// function/method declarator seems to be supported as well:
|
||||
//
|
||||
// NOINLINE void* CHeapObj<F>::operator new(size_t size) throw() {...}
|
||||
|
||||
#define NOINLINE __attribute__((__noinline__))
|
||||
#define ALWAYSINLINE inline __attribute__((__always_inline__))
|
||||
|
||||
#endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_XLC_HPP
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user