8231356: Fix broken ResourceObj::operator new[] in debug builds

Reviewed-by: kbarrett, iklam
This commit is contained in:
Leo Korinth 2021-09-07 08:23:32 +00:00
parent 81c719be39
commit 3cd95a2932
2 changed files with 6 additions and 37 deletions

View File

@ -110,12 +110,6 @@ void* ResourceObj::operator new(size_t size, Arena *arena) throw() {
return res;
}
void* ResourceObj::operator new [](size_t size, Arena *arena) throw() {
address res = (address)arena->Amalloc(size);
DEBUG_ONLY(set_allocation_type(res, ARENA);)
return res;
}
void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flags) throw() {
address res = NULL;
switch (type) {
@ -133,10 +127,6 @@ void* ResourceObj::operator new(size_t size, allocation_type type, MEMFLAGS flag
return res;
}
void* ResourceObj::operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() {
return (address) operator new(size, type, flags);
}
void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags) throw() {
// should only call this with std::nothrow, use other operator new() otherwise
@ -156,11 +146,6 @@ void* ResourceObj::operator new(size_t size, const std::nothrow_t& nothrow_cons
return res;
}
void* ResourceObj::operator new [](size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags) throw() {
return (address)operator new(size, nothrow_constant, type, flags);
}
void ResourceObj::operator delete(void* p) {
assert(((ResourceObj *)p)->allocated_on_C_heap(),
"delete only allowed for C_HEAP objects");
@ -168,10 +153,6 @@ void ResourceObj::operator delete(void* p) {
FreeHeap(p);
}
void ResourceObj::operator delete [](void* p) {
operator delete(p);
}
#ifdef ASSERT
void ResourceObj::set_allocation_type(address res, allocation_type type) {
// Set allocation type in the resource object

View File

@ -421,15 +421,13 @@ protected:
public:
void* operator new(size_t size, allocation_type type, MEMFLAGS flags) throw();
void* operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw();
void* operator new [](size_t size, allocation_type type, MEMFLAGS flags) throw() = delete;
void* operator new(size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags) throw();
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant,
allocation_type type, MEMFLAGS flags) throw();
allocation_type type, MEMFLAGS flags) throw() = delete;
void* operator new(size_t size, Arena *arena) throw();
void* operator new [](size_t size, Arena *arena) throw();
void* operator new [](size_t size, Arena *arena) throw() = delete;
void* operator new(size_t size) throw() {
address res = (address)resource_allocate_bytes(size);
@ -443,20 +441,10 @@ protected:
return res;
}
void* operator new [](size_t size) throw() {
address res = (address)resource_allocate_bytes(size);
DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
return res;
}
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) throw() {
address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
return res;
}
void* operator new [](size_t size) throw() = delete;
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) throw() = delete;
void operator delete(void* p);
void operator delete [](void* p);
void operator delete [](void* p) = delete;
};
// One of the following macros must be used when allocating an array