|
28 | 28 | #include "classfile/vmClasses.hpp" |
29 | 29 | #include "compiler/compileBroker.hpp" |
30 | 30 | #include "gc/shared/collectedHeap.hpp" |
| 31 | +#include "gc/shared/memAllocator.hpp" |
31 | 32 | #include "gc/shared/oopStorage.inline.hpp" |
32 | 33 | #include "jvmci/jniAccessMark.inline.hpp" |
33 | 34 | #include "jvmci/jvmciCompilerToVM.hpp" |
@@ -92,39 +93,25 @@ static void deopt_caller() { |
92 | 93 | } |
93 | 94 |
|
94 | 95 | // Manages a scope for a JVMCI runtime call that attempts a heap allocation. |
95 | | -// If there is a pending nonasync exception upon closing the scope and the runtime |
| 96 | +// If there is a pending OutOfMemoryError upon closing the scope and the runtime |
96 | 97 | // call is of the variety where allocation failure returns null without an |
97 | 98 | // exception, the following action is taken: |
98 | | -// 1. The pending nonasync exception is cleared |
| 99 | +// 1. The pending OutOfMemoryError is cleared |
99 | 100 | // 2. null is written to JavaThread::_vm_result |
100 | | -// 3. Checks that an OutOfMemoryError is Universe::out_of_memory_error_retry(). |
101 | | -class RetryableAllocationMark: public StackObj { |
| 101 | +class RetryableAllocationMark { |
102 | 102 | private: |
103 | | - JavaThread* _thread; |
| 103 | + InternalOOMEMark _iom; |
104 | 104 | public: |
105 | | - RetryableAllocationMark(JavaThread* thread, bool activate) { |
106 | | - if (activate) { |
107 | | - assert(!thread->in_retryable_allocation(), "retryable allocation scope is non-reentrant"); |
108 | | - _thread = thread; |
109 | | - _thread->set_in_retryable_allocation(true); |
110 | | - } else { |
111 | | - _thread = nullptr; |
112 | | - } |
113 | | - } |
| 105 | + RetryableAllocationMark(JavaThread* thread, bool activate) : _iom(activate ? thread : nullptr) {} |
114 | 106 | ~RetryableAllocationMark() { |
115 | | - if (_thread != nullptr) { |
116 | | - _thread->set_in_retryable_allocation(false); |
117 | | - JavaThread* THREAD = _thread; // For exception macros. |
| 107 | + JavaThread* THREAD = _iom.thread(); // For exception macros. |
| 108 | + if (THREAD != nullptr) { |
118 | 109 | if (HAS_PENDING_EXCEPTION) { |
119 | 110 | oop ex = PENDING_EXCEPTION; |
120 | | - // Do not clear probable async exceptions. |
121 | | - CLEAR_PENDING_NONASYNC_EXCEPTION; |
122 | | - oop retry_oome = Universe::out_of_memory_error_retry(); |
123 | | - if (ex->is_a(retry_oome->klass()) && retry_oome != ex) { |
124 | | - ResourceMark rm; |
125 | | - fatal("Unexpected exception in scope of retryable allocation: " INTPTR_FORMAT " of type %s", p2i(ex), ex->klass()->external_name()); |
| 111 | + THREAD->set_vm_result(nullptr); |
| 112 | + if (ex->is_a(vmClasses::OutOfMemoryError_klass())) { |
| 113 | + CLEAR_PENDING_EXCEPTION; |
126 | 114 | } |
127 | | - _thread->set_vm_result(nullptr); |
128 | 115 | } |
129 | 116 | } |
130 | 117 | } |
|
0 commit comments