Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
addressed review comments and suggestions
  • Loading branch information
dougxc committed May 2, 2024
commit 545714a519ebd2f12173231b991875880e019965
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/shared/memAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool MemAllocator::Allocation::check_out_of_memory() {
}

const char* message = _overhead_limit_exceeded ? "GC overhead limit exceeded" : "Java heap space";
if (!_thread->in_internal_oome_mark()) {
if (!_thread->is_in_internal_oome_mark()) {
// -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support
report_java_out_of_memory(message);
if (JvmtiExport::should_post_resource_exhausted()) {
Expand All @@ -137,7 +137,7 @@ bool MemAllocator::Allocation::check_out_of_memory() {
Universe::out_of_memory_error_java_heap();
THROW_OOP_(exception, true);
} else {
THROW_OOP_(Universe::out_of_memory_error_java_heap(/* omit_backtrace*/ true), true);
THROW_OOP_(Universe::out_of_memory_error_java_heap_without_backtrace(), true);
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/hotspot/share/gc/shared/memAllocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ class InternalOOMEMark: public StackObj {
JavaThread* _thread;

public:
InternalOOMEMark(JavaThread* thread) {
explicit InternalOOMEMark(JavaThread* thread) {
if (thread != nullptr) {
_outer = thread->in_internal_oome_mark();
thread->set_in_internal_oome_mark(true);
_outer = thread->is_in_internal_oome_mark();
thread->set_is_in_internal_oome_mark(true);
_thread = thread;
} else {
_outer = false;
Expand All @@ -142,13 +142,12 @@ class InternalOOMEMark: public StackObj {
~InternalOOMEMark() {
if (_thread != nullptr) {
// Check that only InternalOOMEMark sets
// JavaThread::_in_internal_oome_mark
assert(_thread->in_internal_oome_mark(), "must be");
_thread->set_in_internal_oome_mark(_outer);
// JavaThread::_is_in_internal_oome_mark
assert(_thread->is_in_internal_oome_mark(), "must be");
_thread->set_is_in_internal_oome_mark(_outer);
}
}

// Returns nullptr iff `activate` was false in the constructor.
JavaThread* thread() const { return _thread; }
};

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class RetryableAllocationMark {
public:
RetryableAllocationMark(JavaThread* thread, bool activate) : _iom(activate ? thread : nullptr) {}
~RetryableAllocationMark() {
JavaThread* THREAD = _iom.thread();
JavaThread* THREAD = _iom.thread(); // For exception macros.
if (THREAD != nullptr) {
if (HAS_PENDING_EXCEPTION) {
oop ex = PENDING_EXCEPTION;
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/memory/universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,12 @@ objArrayOop Universe::preallocated_out_of_memory_errors() {

objArrayOop Universe::out_of_memory_errors() { return (objArrayOop)_out_of_memory_errors.resolve(); }

oop Universe::out_of_memory_error_java_heap(bool omit_backtrace) {
oop oome = out_of_memory_errors()->obj_at(_oom_java_heap);
if (!omit_backtrace) {
oome = gen_out_of_memory_error(oome);
}
return oome;
oop Universe::out_of_memory_error_java_heap() {
return gen_out_of_memory_error(out_of_memory_errors()->obj_at(_oom_java_heap));
}

oop Universe::out_of_memory_error_java_heap_without_backtrace() {
return out_of_memory_errors()->obj_at(_oom_java_heap);
}

oop Universe::out_of_memory_error_c_heap() {
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/memory/universe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ class Universe: AllStatic {
// OutOfMemoryError support. Returns an error with the required message. The returned error
// may or may not have a backtrace. If error has a backtrace then the stack trace is already
// filled in.
static oop out_of_memory_error_java_heap(bool omit_backtrace=false);
static oop out_of_memory_error_java_heap();
static oop out_of_memory_error_java_heap_without_backtrace();
static oop out_of_memory_error_c_heap();
static oop out_of_memory_error_metaspace();
static oop out_of_memory_error_class_metaspace();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/oops/klass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,12 +873,12 @@ void Klass::set_archived_java_mirror(int mirror_index) {

void Klass::check_array_allocation_length(int length, int max_length, TRAPS) {
if (length > max_length) {
if (!THREAD->in_internal_oome_mark()) {
if (!THREAD->is_in_internal_oome_mark()) {
report_java_out_of_memory("Requested array size exceeds VM limit");
JvmtiExport::post_array_size_exhausted();
THROW_OOP(Universe::out_of_memory_error_array_size());
} else {
THROW_OOP(Universe::out_of_memory_error_java_heap(/* omit_backtrace*/ true));
THROW_OOP(Universe::out_of_memory_error_java_heap_without_backtrace());
}
} else if (length < 0) {
THROW_MSG(vmSymbols::java_lang_NegativeArraySizeException(), err_msg("%d", length));
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/javaThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ JavaThread::JavaThread() :
#endif
#endif
_jni_attach_state(_not_attaching_via_jni),
_in_internal_oome_mark(false),
_is_in_internal_oome_mark(false),
#if INCLUDE_JVMCI
_pending_deoptimization(-1),
_pending_monitorenter(false),
Expand Down
9 changes: 5 additions & 4 deletions src/hotspot/share/runtime/javaThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
class AsyncExceptionHandshake;
class ContinuationEntry;
class DeoptResourceMark;
class InternalOOMEMark;
class JNIHandleBlock;
class JVMCIRuntime;
class InternalOOMEMark;

class JvmtiDeferredUpdates;
class JvmtiSampledObjectAllocEventCollector;
Expand Down Expand Up @@ -336,7 +336,7 @@ class JavaThread: public Thread {
volatile JNIAttachStates _jni_attach_state;

// In scope of an InternalOOMEMark?
bool _in_internal_oome_mark;
bool _is_in_internal_oome_mark;

#if INCLUDE_JVMCI
// The _pending_* fields below are used to communicate extra information
Expand Down Expand Up @@ -713,8 +713,9 @@ class JavaThread: public Thread {
MemRegion deferred_card_mark() const { return _deferred_card_mark; }
void set_deferred_card_mark(MemRegion mr) { _deferred_card_mark = mr; }

bool in_internal_oome_mark() const { return _in_internal_oome_mark; }
void set_in_internal_oome_mark(bool b) { _in_internal_oome_mark = b; }
// Is thread in scope of an InternalOOMEMark?
bool is_in_internal_oome_mark() const { return _is_in_internal_oome_mark; }
void set_is_in_internal_oome_mark(bool b) { _is_in_internal_oome_mark = b; }

#if INCLUDE_JVMCI
jlong pending_failed_speculation() const { return _pending_failed_speculation; }
Expand Down