@@ -102,7 +102,7 @@ class RetryableAllocationMark {
102102 private:
103103 InternalOOMEMark _iom;
104104 public:
105- RetryableAllocationMark (JavaThread* thread, bool activate ) : _iom(activate ? thread : nullptr ) {}
105+ RetryableAllocationMark (JavaThread* thread) : _iom(thread) {}
106106 ~RetryableAllocationMark () {
107107 JavaThread* THREAD = _iom.thread (); // For exception macros.
108108 if (THREAD != nullptr ) {
@@ -117,34 +117,29 @@ class RetryableAllocationMark {
117117 }
118118};
119119
120- JRT_BLOCK_ENTRY (void , JVMCIRuntime::new_instance_common (JavaThread* current, Klass* klass, bool null_on_fail ))
120+ JRT_BLOCK_ENTRY (void , JVMCIRuntime::new_instance_or_null (JavaThread* current, Klass* klass))
121121 JRT_BLOCK;
122122 assert (klass->is_klass (), "not a class");
123123 Handle holder (current, klass->klass_holder ()); // keep the klass alive
124124 InstanceKlass* h = InstanceKlass::cast(klass);
125125 {
126- RetryableAllocationMark ram (current, null_on_fail );
126+ RetryableAllocationMark ram (current);
127127 h->check_valid_for_instantiation (true , CHECK);
128- oop obj;
129- if (null_on_fail) {
130- if (!h->is_initialized ()) {
131- // Cannot re-execute class initialization without side effects
132- // so return without attempting the initialization
133- return ;
134- }
135- } else {
136- // make sure klass is initialized
137- h->initialize (CHECK);
128+ if (!h->is_initialized ()) {
129+ // Cannot re-execute class initialization without side effects
130+ // so return without attempting the initialization
131+ current->set_vm_result (nullptr );
132+ return ;
138133 }
139134 // allocate instance and return via TLS
140- obj = h->allocate_instance (CHECK);
135+ oop obj = h->allocate_instance (CHECK);
141136 current->set_vm_result (obj);
142137 }
143138 JRT_BLOCK_END;
144139 SharedRuntime::on_slowpath_allocation_exit (current);
145140JRT_END
146141
147- JRT_BLOCK_ENTRY (void , JVMCIRuntime::new_array_common (JavaThread* current, Klass* array_klass, jint length, bool null_on_fail ))
142+ JRT_BLOCK_ENTRY (void , JVMCIRuntime::new_array_or_null (JavaThread* current, Klass* array_klass, jint length))
148143 JRT_BLOCK;
149144 // Note: no handle for klass needed since they are not used
150145 // anymore after new_objArray() and no GC can happen before.
@@ -153,27 +148,21 @@ JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array_common(JavaThread* current, Klass*
153148 oop obj;
154149 if (array_klass->is_typeArray_klass ()) {
155150 BasicType elt_type = TypeArrayKlass::cast (array_klass)->element_type ();
156- RetryableAllocationMark ram (current, null_on_fail );
151+ RetryableAllocationMark ram (current);
157152 obj = oopFactory::new_typeArray (elt_type, length, CHECK);
158153 } else {
159154 Handle holder (current, array_klass->klass_holder ()); // keep the klass alive
160155 Klass* elem_klass = ObjArrayKlass::cast (array_klass)->element_klass ();
161- RetryableAllocationMark ram (current, null_on_fail );
156+ RetryableAllocationMark ram (current);
162157 obj = oopFactory::new_objArray (elem_klass, length, CHECK);
163158 }
164159 // This is pretty rare but this runtime patch is stressful to deoptimization
165160 // if we deoptimize here so force a deopt to stress the path.
166161 if (DeoptimizeALot) {
167162 static int deopts = 0 ;
168- // Alternate between deoptimizing and raising an error (which will also cause a deopt)
169163 if (deopts++ % 2 == 0 ) {
170- if (null_on_fail) {
171- // Drop the allocation
172- obj = nullptr ;
173- } else {
174- ResourceMark rm (current);
175- THROW (vmSymbols::java_lang_OutOfMemoryError ());
176- }
164+ // Drop the allocation
165+ obj = nullptr ;
177166 } else {
178167 deopt_caller ();
179168 }
@@ -183,42 +172,38 @@ JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array_common(JavaThread* current, Klass*
183172 SharedRuntime::on_slowpath_allocation_exit (current);
184173JRT_END
185174
186- JRT_ENTRY (void , JVMCIRuntime::new_multi_array_common (JavaThread* current, Klass* klass, int rank, jint* dims, bool null_on_fail ))
175+ JRT_ENTRY (void , JVMCIRuntime::new_multi_array_or_null (JavaThread* current, Klass* klass, int rank, jint* dims))
187176 assert(klass->is_klass (), "not a class");
188177 assert (rank >= 1 , " rank must be nonzero" );
189178 Handle holder (current, klass->klass_holder ()); // keep the klass alive
190- RetryableAllocationMark ram (current, null_on_fail );
179+ RetryableAllocationMark ram (current);
191180 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
192181 current->set_vm_result (obj);
193182JRT_END
194183
195- JRT_ENTRY (void , JVMCIRuntime::dynamic_new_array_common (JavaThread* current, oopDesc* element_mirror, jint length, bool null_on_fail ))
196- RetryableAllocationMark ram(current, null_on_fail );
184+ JRT_ENTRY (void , JVMCIRuntime::dynamic_new_array_or_null (JavaThread* current, oopDesc* element_mirror, jint length))
185+ RetryableAllocationMark ram(current);
197186 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
198187 current->set_vm_result (obj);
199188JRT_END
200189
201- JRT_ENTRY (void , JVMCIRuntime::dynamic_new_instance_common (JavaThread* current, oopDesc* type_mirror, bool null_on_fail ))
190+ JRT_ENTRY (void , JVMCIRuntime::dynamic_new_instance_or_null (JavaThread* current, oopDesc* type_mirror))
202191 InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(type_mirror));
203192
204193 if (klass == nullptr ) {
205194 ResourceMark rm (current);
206195 THROW (vmSymbols::java_lang_InstantiationException ());
207196 }
208- RetryableAllocationMark ram (current, null_on_fail );
197+ RetryableAllocationMark ram (current);
209198
210199 // Create new instance (the receiver)
211200 klass->check_valid_for_instantiation (false , CHECK);
212201
213- if (null_on_fail) {
214- if (!klass->is_initialized ()) {
215- // Cannot re-execute class initialization without side effects
216- // so return without attempting the initialization
217- return ;
218- }
219- } else {
220- // Make sure klass gets initialized
221- klass->initialize (CHECK);
202+ if (!klass->is_initialized ()) {
203+ // Cannot re-execute class initialization without side effects
204+ // so return without attempting the initialization
205+ current->set_vm_result (nullptr );
206+ return ;
222207 }
223208
224209 oop obj = klass->allocate_instance (CHECK);
0 commit comments