@@ -4286,87 +4286,59 @@ JRT_LEAF(void, SharedRuntime::load_inline_type_fields_in_regs(JavaThread* curren
42864286}
42874287JRT_END
42884288
4289- static void store_inline_type_fields_to_buf_slow (JavaThread* current, intptr_t res) {
4290- ResourceMark rm;
4291- RegisterMap reg_map (current,
4292- RegisterMap::UpdateMap::include,
4293- RegisterMap::ProcessFrames::include,
4294- RegisterMap::WalkContinuation::skip);
4295- frame stubFrame = current->last_frame ();
4296- frame callerFrame = stubFrame.sender (®_map);
4297-
4298- #ifdef ASSERT
4299- InlineKlass* verif_vk = InlineKlass::returned_inline_klass (reg_map);
4300- #endif
4301-
4302- if (!is_set_nth_bit (res, 0 )) {
4303- // We're not returning with inline type fields in registers (the
4304- // calling convention didn't allow it for this inline klass)
4305- assert (!Metaspace::contains ((void *)res), " should be oop or pointer in buffer area" );
4306- current->set_vm_result_oop ((oopDesc*)res);
4307- assert (verif_vk == nullptr , " broken calling convention" );
4308- return ;
4309- }
4310-
4311- clear_nth_bit (res, 0 );
4312- InlineKlass* vk = (InlineKlass*)res;
4313- assert (verif_vk == vk, " broken calling convention" );
4314- assert (Metaspace::contains ((void *)res), " should be klass" );
4315-
4316- // Allocate handles for every oop field so they are safe in case of
4317- // a safepoint when allocating
4318- GrowableArray<Handle> handles;
4319- vk->save_oop_fields (reg_map, handles);
4320-
4321- // It's unsafe to safepoint until we are here
4322- JRT_BLOCK;
4323- {
4324- JavaThread* THREAD = current;
4325- oop vt = vk->realloc_result (reg_map, handles, CHECK);
4326- current->set_vm_result_oop (vt);
4327- }
4328- JRT_BLOCK_END;
4329- }
4330-
43314289// We've returned to an interpreted method, the interpreter needs a
43324290// reference to an inline type instance. Allocate it and initialize it
43334291// from field's values in registers.
43344292JRT_BLOCK_ENTRY (void , SharedRuntime::store_inline_type_fields_to_buf(JavaThread* current, intptr_t res))
43354293{
4336- store_inline_type_fields_to_buf_slow (current, res);
4337- }
4338- JRT_END
4339-
4340- JRT_BLOCK_ENTRY (void , SharedRuntime::allocate_inline_type_fields_buffer(JavaThread* current, intptr_t res))
4341- {
4342- current->set_vm_result_metadata (nullptr );
4343-
43444294 if (!is_set_nth_bit (res, 0 )) {
43454295 // We're not returning with inline type fields in registers (the
4346- // calling convention didn't allow it for this inline klass).
4296+ // calling convention didn't allow it for this inline klass)
43474297 assert (!Metaspace::contains ((void *)res), " should be oop or pointer in buffer area" );
43484298 current->set_vm_result_oop ((oopDesc*)res);
4299+ current->set_vm_result_metadata (nullptr );
43494300 return ;
43504301 }
43514302
43524303 clear_nth_bit (res, 0 );
43534304 InlineKlass* vk = (InlineKlass*)res;
43544305 assert (Metaspace::contains ((void *)res), " should be klass" );
4355- assert (vk->can_be_returned_as_fields (), " must be able to return as fields" );
43564306
4357- if (vk->contains_oops ()) {
4358- // Oop fields in scalar return registers must be converted to handles before
4359- // allocation can safepoint.
4360- store_inline_type_fields_to_buf_slow (current, res | 1 );
4307+ if (!vk->contains_oops ()) {
4308+ // No oop fields. Initialize the fields by calling the pack handler from
4309+ // the stub which is much faster (see 'generate_return_value_stub').
4310+ // Signal this by setting the metadata result to the value klass.
4311+ JRT_BLOCK;
4312+ {
4313+ oop vt = vk->allocate_instance (CHECK);
4314+ current->set_vm_result_oop (vt);
4315+ current->set_vm_result_metadata (vk);
4316+ }
4317+ JRT_BLOCK_END;
43614318 return ;
43624319 }
43634320
4321+ ResourceMark rm;
4322+ RegisterMap reg_map (current,
4323+ RegisterMap::UpdateMap::include,
4324+ RegisterMap::ProcessFrames::include,
4325+ RegisterMap::WalkContinuation::skip);
4326+ frame stubFrame = current->last_frame ();
4327+ frame callerFrame = stubFrame.sender (®_map);
4328+
4329+ assert (vk == InlineKlass::returned_inline_klass (reg_map), " broken calling convention" );
4330+
4331+ // Allocate handles for every oop field so they are safe in case of
4332+ // a safepoint when allocating
4333+ GrowableArray<Handle> handles;
4334+ vk->save_oop_fields (reg_map, handles);
4335+
4336+ // It's unsafe to safepoint until we are here
43644337 JRT_BLOCK;
43654338 {
4366- JavaThread* THREAD = current;
4367- oop vt = vk->allocate_instance (CHECK);
4339+ oop vt = vk->realloc_result (reg_map, handles, CHECK);
43684340 current->set_vm_result_oop (vt);
4369- current->set_vm_result_metadata (vk );
4341+ current->set_vm_result_metadata (nullptr );
43704342 }
43714343 JRT_BLOCK_END;
43724344}
0 commit comments