8305590: Remove nothrow exception specifications from operator new

Reviewed-by: coleenp, kbarrett
This commit is contained in:
Afshin Zafari 2023-04-23 15:20:18 +00:00 committed by Jesper Wilhelmsson
parent 8d696aea9e
commit 0f51e63263
8 changed files with 26 additions and 50 deletions

View File

@ -494,7 +494,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
fi
if test "x$TOOLCHAIN_TYPE" = xgcc; then
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fcheck-new -fstack-protector"
TOOLCHAIN_CFLAGS_JVM="$TOOLCHAIN_CFLAGS_JVM -fstack-protector"
TOOLCHAIN_CFLAGS_JDK="-pipe -fstack-protector"
# reduce lib size on linux in link step, this needs also special compile flags
# do this on s390x also for libjvm (where serviceability agent is not supported)

View File

@ -71,11 +71,6 @@ void FreeHeap(void* p) {
void* MetaspaceObj::_shared_metaspace_base = nullptr;
void* MetaspaceObj::_shared_metaspace_top = nullptr;
void* StackObj::operator new(size_t size) throw() { ShouldNotCallThis(); return 0; }
void StackObj::operator delete(void* p) { ShouldNotCallThis(); }
void* StackObj::operator new [](size_t size) throw() { ShouldNotCallThis(); return 0; }
void StackObj::operator delete [](void* p) { ShouldNotCallThis(); }
void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
size_t word_size,
MetaspaceObj::Type type, TRAPS) throw() {

View File

@ -179,13 +179,13 @@ void FreeHeap(void* p);
class CHeapObjBase {
public:
ALWAYSINLINE void* operator new(size_t size, MEMFLAGS f) throw() {
ALWAYSINLINE void* operator new(size_t size, MEMFLAGS f) {
return AllocateHeap(size, f);
}
ALWAYSINLINE void* operator new(size_t size,
MEMFLAGS f,
const NativeCallStack& stack) throw() {
const NativeCallStack& stack) {
return AllocateHeap(size, f, stack);
}
@ -202,13 +202,13 @@ class CHeapObjBase {
return AllocateHeap(size, f, AllocFailStrategy::RETURN_NULL);
}
ALWAYSINLINE void* operator new[](size_t size, MEMFLAGS f) throw() {
ALWAYSINLINE void* operator new[](size_t size, MEMFLAGS f) {
return AllocateHeap(size, f);
}
ALWAYSINLINE void* operator new[](size_t size,
MEMFLAGS f,
const NativeCallStack& stack) throw() {
const NativeCallStack& stack) {
return AllocateHeap(size, f, stack);
}
@ -233,12 +233,12 @@ class CHeapObjBase {
template<MEMFLAGS F>
class CHeapObj {
public:
ALWAYSINLINE void* operator new(size_t size) throw() {
ALWAYSINLINE void* operator new(size_t size) {
return CHeapObjBase::operator new(size, F);
}
ALWAYSINLINE void* operator new(size_t size,
const NativeCallStack& stack) throw() {
const NativeCallStack& stack) {
return CHeapObjBase::operator new(size, F, stack);
}
@ -251,12 +251,12 @@ class CHeapObj {
return CHeapObjBase::operator new(size, F, nt);
}
ALWAYSINLINE void* operator new[](size_t size) throw() {
ALWAYSINLINE void* operator new[](size_t size) {
return CHeapObjBase::operator new[](size, F);
}
ALWAYSINLINE void* operator new[](size_t size,
const NativeCallStack& stack) throw() {
const NativeCallStack& stack) {
return CHeapObjBase::operator new[](size, F, stack);
}
@ -282,11 +282,11 @@ class CHeapObj {
// Calling new or delete will result in fatal error.
class StackObj {
private:
void* operator new(size_t size) throw();
void* operator new [](size_t size) throw();
void operator delete(void* p);
void operator delete [](void* p);
public:
void* operator new(size_t size) = delete;
void* operator new [](size_t size) = delete;
void operator delete(void* p) = delete;
void operator delete [](void* p) = delete;
};
// Base class for objects stored in Metaspace.
@ -432,7 +432,7 @@ extern void resource_free_bytes( Thread* thread, char *old, size_t size );
// Base class for objects allocated in the resource area.
class ResourceObj {
public:
void* operator new(size_t size) throw() {
void* operator new(size_t size) {
return resource_allocate_bytes(size);
}
@ -500,11 +500,11 @@ protected:
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant, MEMFLAGS flags) throw() = delete;
// Arena allocations
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, Arena *arena);
void* operator new [](size_t size, Arena *arena) = delete;
// Resource allocations
void* operator new(size_t size) throw() {
void* operator new(size_t size) {
address res = (address)resource_allocate_bytes(size);
DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
return res;
@ -515,8 +515,8 @@ protected:
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 new [](size_t size) = delete;
void* operator new [](size_t size, const std::nothrow_t& nothrow_constant) = delete;
void operator delete(void* p);
void operator delete [](void* p) = delete;

View File

@ -3651,7 +3651,7 @@ JvmtiEnv::IsMethodObsolete(Method* method, jboolean* is_obsolete_ptr) {
// monitor_ptr - pre-checked for null
jvmtiError
JvmtiEnv::CreateRawMonitor(const char* name, jrawMonitorID* monitor_ptr) {
JvmtiRawMonitor* rmonitor = new JvmtiRawMonitor(name);
JvmtiRawMonitor* rmonitor = new (std::nothrow) JvmtiRawMonitor(name);
NULL_CHECK(rmonitor, JVMTI_ERROR_OUT_OF_MEMORY);
*monitor_ptr = (jrawMonitorID)rmonitor;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -110,11 +110,6 @@ class JvmtiRawMonitor : public CHeapObj<mtSynchronizer> {
M_INTERRUPTED // Thread.interrupt()
};
// Non-aborting operator new
void* operator new(size_t size) throw() {
return CHeapObj::operator new(size, std::nothrow);
}
JvmtiRawMonitor(const char* name);
~JvmtiRawMonitor();

View File

@ -58,15 +58,6 @@ THREAD_LOCAL Thread* Thread::_thr_current = nullptr;
#endif
// ======= Thread ========
void* Thread::allocate(size_t size, bool throw_excpt, MEMFLAGS flags) {
return throw_excpt ? AllocateHeap(size, flags, CURRENT_PC)
: AllocateHeap(size, flags, CURRENT_PC, AllocFailStrategy::RETURN_NULL);
}
void Thread::operator delete(void* p) {
FreeHeap(p);
}
// Base class for all threads: VMThread, WatcherThread, ConcurrentMarkSweepThread,
// JavaThread

View File

@ -200,14 +200,6 @@ class Thread: public ThreadShadow {
// with the calling Thread?
static bool is_JavaThread_protected_by_TLH(const JavaThread* target);
void* operator new(size_t size) throw() { return allocate(size, true); }
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
return allocate(size, false); }
void operator delete(void* p);
protected:
static void* allocate(size_t size, bool throw_excpt, MEMFLAGS flags = mtThread);
private:
DEBUG_ONLY(bool _suspendible_thread;)

View File

@ -809,13 +809,16 @@ public:
this->clear_and_deallocate();
}
void* operator new(size_t size) throw() {
void* operator new(size_t size) {
return AnyObj::operator new(size, F);
}
void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() {
return AnyObj::operator new(size, nothrow_constant, F);
}
void operator delete(void *p) {
AnyObj::operator delete(p);
}
};
// Custom STL-style iterator to iterate over GrowableArrays