Skip to content

Commit 8ddaa81

Browse files
committed
Cleanup
1 parent 2f6c590 commit 8ddaa81

5 files changed

Lines changed: 60 additions & 97 deletions

File tree

src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12585,7 +12585,7 @@ class StubGenerator: public StubCodeGenerator {
1258512585
// multiple returned values from the inline type instance being
1258612586
// returned to registers or to store returned values to a newly
1258712587
// allocated inline type instance.
12588-
address generate_return_value_stub(address destination, const char* name, bool has_res, bool pack_inline_type_result = false) {
12588+
address generate_return_value_stub(address destination, const char* name, bool has_res) {
1258912589
// We need to save all registers the calling convention may use so
1259012590
// the runtime calls read or update those registers. This needs to
1259112591
// be in sync with SharedRuntime::java_return_convention().
@@ -12691,21 +12691,17 @@ class StubGenerator: public StubCodeGenerator {
1269112691
__ cbnz(rscratch1, pending);
1269212692

1269312693
if (has_res) {
12694-
if (pack_inline_type_result) {
12695-
Label skip_pack;
12696-
Register klass = r13;
12697-
Register tmp = r14;
12698-
__ get_vm_result_metadata(klass, rthread);
12699-
__ get_vm_result_oop(r0, rthread);
12700-
__ cbz(klass, skip_pack);
12701-
__ ldr(tmp, Address(klass, InlineKlass::adr_members_offset()));
12702-
__ ldr(tmp, Address(tmp, InlineKlass::pack_handler_offset()));
12703-
__ blr(tmp);
12704-
__ membar(Assembler::StoreStore);
12705-
__ bind(skip_pack);
12706-
} else {
12707-
__ get_vm_result_oop(r0, rthread);
12708-
}
12694+
// We just called SharedRuntime::store_inline_type_fields_to_buf. Check if we still
12695+
// need to initialize the buffer and if so, call the inline class specific pack handler.
12696+
Label skip_pack;
12697+
__ get_vm_result_oop(r0, rthread);
12698+
__ get_vm_result_metadata(rscratch1, rthread);
12699+
__ cbz(rscratch1, skip_pack);
12700+
__ ldr(rscratch1, Address(rscratch1, InlineKlass::adr_members_offset()));
12701+
__ ldr(rscratch1, Address(rscratch1, InlineKlass::pack_handler_offset()));
12702+
__ blr(rscratch1);
12703+
__ membar(Assembler::StoreStore);
12704+
__ bind(skip_pack);
1270912705
}
1271012706

1271112707
__ leave();
@@ -12776,7 +12772,7 @@ class StubGenerator: public StubCodeGenerator {
1277612772
StubRoutines::_load_inline_type_fields_in_regs =
1277712773
generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::load_inline_type_fields_in_regs), "load_inline_type_fields_in_regs", false);
1277812774
StubRoutines::_store_inline_type_fields_to_buf =
12779-
generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::allocate_inline_type_fields_buffer), "store_inline_type_fields_to_buf", true, true);
12775+
generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::store_inline_type_fields_to_buf), "store_inline_type_fields_to_buf", true);
1278012776
}
1278112777

1278212778
}

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4830,8 +4830,8 @@ void StubGenerator::generate_initial_stubs() {
48304830
generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::load_inline_type_fields_in_regs),
48314831
"load_inline_type_fields_in_regs", false);
48324832
StubRoutines::_store_inline_type_fields_to_buf =
4833-
generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::allocate_inline_type_fields_buffer),
4834-
"store_inline_type_fields_to_buf", true, true);
4833+
generate_return_value_stub(CAST_FROM_FN_PTR(address, SharedRuntime::store_inline_type_fields_to_buf),
4834+
"store_inline_type_fields_to_buf", true);
48354835
}
48364836

48374837
StubRoutines::_call_stub_entry =
@@ -4885,7 +4885,7 @@ void StubGenerator::generate_initial_stubs() {
48854885
// "0" is assigned for xmm0. Thus we need to ignore -Wnonnull.
48864886
PRAGMA_DIAG_PUSH
48874887
PRAGMA_NONNULL_IGNORED
4888-
address StubGenerator::generate_return_value_stub(address destination, const char* name, bool has_res, bool pack_inline_type_result) {
4888+
address StubGenerator::generate_return_value_stub(address destination, const char* name, bool has_res) {
48894889
// We need to save all registers the calling convention may use so
48904890
// the runtime calls read or update those registers. This needs to
48914891
// be in sync with SharedRuntime::java_return_convention().
@@ -5003,22 +5003,18 @@ address StubGenerator::generate_return_value_stub(address destination, const cha
50035003
__ jcc(Assembler::notEqual, pending);
50045004

50055005
if (has_res) {
5006-
if (pack_inline_type_result) {
5007-
Label skip_pack;
5008-
Register klass = rscratch1;
5009-
Register tmp = rscratch2;
5010-
__ get_vm_result_metadata(klass);
5011-
__ get_vm_result_oop(rax);
5012-
__ testptr(klass, klass);
5013-
__ jcc(Assembler::zero, skip_pack);
5014-
__ movptr(tmp, Address(klass, InlineKlass::adr_members_offset()));
5015-
__ movptr(tmp, Address(tmp, InlineKlass::pack_handler_offset()));
5016-
__ call(tmp);
5017-
__ membar(Assembler::StoreStore);
5018-
__ bind(skip_pack);
5019-
} else {
5020-
__ get_vm_result_oop(rax);
5021-
}
5006+
// We just called SharedRuntime::store_inline_type_fields_to_buf. Check if we still
5007+
// need to initialize the buffer and if so, call the inline class specific pack handler.
5008+
Label skip_pack;
5009+
__ get_vm_result_oop(rax);
5010+
__ get_vm_result_metadata(rscratch1);
5011+
__ testptr(rscratch1, rscratch1);
5012+
__ jcc(Assembler::zero, skip_pack);
5013+
__ movptr(rscratch1, Address(rscratch1, InlineKlass::adr_members_offset()));
5014+
__ movptr(rscratch1, Address(rscratch1, InlineKlass::pack_handler_offset()));
5015+
__ call(rscratch1);
5016+
__ membar(Assembler::StoreStore);
5017+
__ bind(skip_pack);
50225018
}
50235019

50245020
__ ret(0);

src/hotspot/cpu/x86/stubGenerator_x86_64.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ class StubGenerator: public StubCodeGenerator {
636636
address generate_upcall_stub_load_target();
637637

638638
// interpreter or compiled code marshalling registers to/from inline type instance
639-
address generate_return_value_stub(address destination, const char* name, bool has_res, bool pack_inline_type_result = false);
639+
address generate_return_value_stub(address destination, const char* name, bool has_res);
640640

641641
// Specialized stub implementations for UseSecondarySupersTable.
642642
void generate_lookup_secondary_supers_table_stub();

src/hotspot/share/runtime/sharedRuntime.cpp

Lines changed: 31 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,87 +4286,59 @@ JRT_LEAF(void, SharedRuntime::load_inline_type_fields_in_regs(JavaThread* curren
42864286
}
42874287
JRT_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(&reg_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.
43344292
JRT_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(&reg_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
}

src/hotspot/share/runtime/sharedRuntime.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ class SharedRuntime: AllStatic {
567567
static address resolve_opt_virtual_call_C(JavaThread* current);
568568

569569
static void load_inline_type_fields_in_regs(JavaThread* current, oopDesc* res);
570-
static void allocate_inline_type_fields_buffer(JavaThread* current, intptr_t res);
571570
static void store_inline_type_fields_to_buf(JavaThread* current, intptr_t res);
572571

573572
// arraycopy, the non-leaf version. (See StubRoutines for all the leaf calls.)

0 commit comments

Comments
 (0)