Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save/load i2c2i adapters #25

Open
wants to merge 23 commits into
base: premain
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8e41ca2
Refactor SCCache address table setup
ashu-mehra Oct 13, 2024
4f96b30
Allocate address table entries for different types in fixed, independ…
ashu-mehra Oct 13, 2024
0fc149a
save and restore i2c and c2i adapter
ashu-mehra Oct 15, 2024
d5be825
Save AdapterHandlerEntry and AdapterFingerPrint in AOT cache
ashu-mehra Oct 15, 2024
17de7ea
Cleanup stale pointers in TrainingData
ashu-mehra Oct 15, 2024
091626a
Refactor code to lookup adapter code in AOT cache
ashu-mehra Oct 15, 2024
b05860a
Add PerfCounter for tracking time to load adapter table
ashu-mehra Oct 15, 2024
7fe50ae
Add assertion that ArchiveAdapters is set in SCCache::store_adapter
ashu-mehra Oct 17, 2024
fb5b88c
Archive adapter_handler_table to the AOT cache
ashu-mehra Oct 17, 2024
f6a79e3
Remove unused code
ashu-mehra Oct 18, 2024
0f7b7ba
Misc changes
ashu-mehra Oct 21, 2024
ccae838
Improve hashing algorithm for AdapterFingerPrint
ashu-mehra Oct 21, 2024
7db3ea0
Add a helper method to iterate over AdapterFingerPrint
ashu-mehra Oct 21, 2024
16bd0b5
Refactor code to avoid calling AdapterFingerPrint::as_basic_type() when
ashu-mehra Oct 22, 2024
3393d68
Fix a bug and add comment in AdapterHandlerEntry::restore_unshareable…
ashu-mehra Oct 23, 2024
1af4a1e
Fix compile failures
ashu-mehra Oct 23, 2024
268b945
Fix whitespace issues
ashu-mehra Oct 23, 2024
98b0da7
Surround code with INCLUDE_CDS where appropriate
ashu-mehra Oct 23, 2024
ea3d208
Move the check for is_abstract_method_adapter() to correct place
ashu-mehra Oct 23, 2024
04fb256
More whitespace fixes
ashu-mehra Oct 24, 2024
b04ba15
Acquire Compile_lock when writing exception blobs to the SCCache
ashu-mehra Oct 24, 2024
d99c24c
Address reivew comments by vnkozlov
ashu-mehra Nov 12, 2024
59b65ef
Address review comments by iklam
ashu-mehra Nov 12, 2024
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
49 changes: 8 additions & 41 deletions src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,40 +558,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
// If this happens, control eventually transfers back to the compiled
// caller, but with an uncorrected stack, causing delayed havoc.

if (VerifyAdapterCalls &&
(Interpreter::code() != nullptr || StubRoutines::final_stubs_code() != nullptr)) {
#if 0
// So, let's test for cascading c2i/i2c adapters right now.
// assert(Interpreter::contains($return_addr) ||
// StubRoutines::contains($return_addr),
// "i2c adapter must return to an interpreter frame");
__ block_comment("verify_i2c { ");
Label L_ok;
if (Interpreter::code() != nullptr) {
range_check(masm, rax, r11,
Interpreter::code()->code_start(), Interpreter::code()->code_end(),
L_ok);
}
if (StubRoutines::initial_stubs_code() != nullptr) {
range_check(masm, rax, r11,
StubRoutines::initial_stubs_code()->code_begin(),
StubRoutines::initial_stubs_code()->code_end(),
L_ok);
}
if (StubRoutines::final_stubs_code() != nullptr) {
range_check(masm, rax, r11,
StubRoutines::final_stubs_code()->code_begin(),
StubRoutines::final_stubs_code()->code_end(),
L_ok);
}
const char* msg = "i2c adapter must return to an interpreter frame";
__ block_comment(msg);
__ stop(msg);
__ bind(L_ok);
__ block_comment("} verify_i2ce ");
#endif
}

// Cut-out for having no stack args.
int comp_words_on_stack = align_up(comp_args_on_stack*VMRegImpl::stack_slot_size, wordSize)>>LogBytesPerWord;
if (comp_args_on_stack) {
Expand Down Expand Up @@ -712,12 +678,12 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
}

// ---------------------------------------------------------------
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
address i2c_entry = __ pc();

gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
Expand Down Expand Up @@ -778,7 +744,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
return;
}

static int c_calling_convention_priv(const BasicType *sig_bt,
Expand Down
15 changes: 8 additions & 7 deletions src/hotspot/cpu/arm/sharedRuntime_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,12 @@ static void gen_c2i_adapter(MacroAssembler *masm,

}

AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
address i2c_entry = __ pc();
gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);

Expand All @@ -638,7 +638,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm
address c2i_entry = __ pc();
gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, nullptr);
return;
}


Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/cpu/ppc/sharedRuntime_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,12 +1144,12 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
__ bctr();
}

AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
address i2c_entry;
address c2i_unverified_entry;
address c2i_entry;
Expand Down Expand Up @@ -1224,8 +1224,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, call_interpreter, ientry);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry,
c2i_no_clinit_check_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
return;
}

// An oop arg. Must pass a handle not the oop itself.
Expand Down
16 changes: 9 additions & 7 deletions src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,13 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
}

// ---------------------------------------------------------------
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {

void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
address i2c_entry = __ pc();
gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);

Expand Down Expand Up @@ -660,7 +661,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
return;
}

int SharedRuntime::vector_calling_convention(VMRegPair *regs,
Expand Down
15 changes: 8 additions & 7 deletions src/hotspot/cpu/s390/sharedRuntime_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2303,12 +2303,12 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
__ z_br(Z_R1_scratch);
}

AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
__ align(CodeEntryAlignment);
address i2c_entry = __ pc();
gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
Expand Down Expand Up @@ -2362,7 +2362,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
return;
}

// This function returns the adjust size (in number of words) to a c2i adapter
Expand Down
60 changes: 8 additions & 52 deletions src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,19 +707,6 @@ static void move_i2c_double(MacroAssembler *masm, XMMRegister r, Register saved_
__ movdbl(r, Address(saved_sp, next_val_off));
}

static void range_check(MacroAssembler* masm, Register pc_reg, Register temp_reg,
address code_start, address code_end,
Label& L_ok) {
Label L_fail;
__ lea(temp_reg, AddressLiteral(code_start, relocInfo::none));
__ cmpptr(pc_reg, temp_reg);
__ jcc(Assembler::belowEqual, L_fail);
__ lea(temp_reg, AddressLiteral(code_end, relocInfo::none));
__ cmpptr(pc_reg, temp_reg);
__ jcc(Assembler::below, L_ok);
__ bind(L_fail);
}

void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
Expand Down Expand Up @@ -749,38 +736,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
// Pick up the return address
__ movptr(rax, Address(rsp, 0));

if (VerifyAdapterCalls &&
(Interpreter::code() != nullptr || StubRoutines::final_stubs_code() != nullptr)) {
// So, let's test for cascading c2i/i2c adapters right now.
// assert(Interpreter::contains($return_addr) ||
// StubRoutines::contains($return_addr),
// "i2c adapter must return to an interpreter frame");
__ block_comment("verify_i2c { ");
Label L_ok;
if (Interpreter::code() != nullptr) {
range_check(masm, rax, rdi,
Interpreter::code()->code_start(), Interpreter::code()->code_end(),
L_ok);
}
if (StubRoutines::initial_stubs_code() != nullptr) {
range_check(masm, rax, rdi,
StubRoutines::initial_stubs_code()->code_begin(),
StubRoutines::initial_stubs_code()->code_end(),
L_ok);
}
if (StubRoutines::final_stubs_code() != nullptr) {
range_check(masm, rax, rdi,
StubRoutines::final_stubs_code()->code_begin(),
StubRoutines::final_stubs_code()->code_end(),
L_ok);
}
const char* msg = "i2c adapter must return to an interpreter frame";
__ block_comment(msg);
__ stop(msg);
__ bind(L_ok);
__ block_comment("} verify_i2ce ");
}

// Must preserve original SP for loading incoming arguments because
// we need to align the outgoing SP for compiled code.
__ movptr(rdi, rsp);
Expand Down Expand Up @@ -928,12 +883,12 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
}

// ---------------------------------------------------------------
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
address i2c_entry = __ pc();

gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
Expand Down Expand Up @@ -971,7 +926,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, nullptr);
return;
}

int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
Expand Down
64 changes: 8 additions & 56 deletions src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ static void patch_callers_callsite(MacroAssembler *masm) {
__ bind(L);
}


static void gen_c2i_adapter(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
Expand Down Expand Up @@ -827,19 +826,6 @@ static void gen_c2i_adapter(MacroAssembler *masm,
__ jmp(rcx);
}

static void range_check(MacroAssembler* masm, Register pc_reg, Register temp_reg,
address code_start, address code_end,
Label& L_ok) {
Label L_fail;
__ lea(temp_reg, AddressLiteral(code_start, relocInfo::none));
__ cmpptr(pc_reg, temp_reg);
__ jcc(Assembler::belowEqual, L_fail);
__ lea(temp_reg, AddressLiteral(code_end, relocInfo::none));
__ cmpptr(pc_reg, temp_reg);
__ jcc(Assembler::below, L_ok);
__ bind(L_fail);
}

void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
Expand Down Expand Up @@ -872,41 +858,6 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
// If this happens, control eventually transfers back to the compiled
// caller, but with an uncorrected stack, causing delayed havoc.

if (VerifyAdapterCalls &&
(Interpreter::code() != nullptr || StubRoutines::final_stubs_code() != nullptr)) {
// So, let's test for cascading c2i/i2c adapters right now.
// assert(Interpreter::contains($return_addr) ||
// StubRoutines::contains($return_addr),
// "i2c adapter must return to an interpreter frame");
__ block_comment("verify_i2c { ");
// Pick up the return address
__ movptr(rax, Address(rsp, 0));
Label L_ok;
if (Interpreter::code() != nullptr) {
range_check(masm, rax, r11,
Interpreter::code()->code_start(),
Interpreter::code()->code_end(),
L_ok);
}
if (StubRoutines::initial_stubs_code() != nullptr) {
range_check(masm, rax, r11,
StubRoutines::initial_stubs_code()->code_begin(),
StubRoutines::initial_stubs_code()->code_end(),
L_ok);
}
if (StubRoutines::final_stubs_code() != nullptr) {
range_check(masm, rax, r11,
StubRoutines::final_stubs_code()->code_begin(),
StubRoutines::final_stubs_code()->code_end(),
L_ok);
}
const char* msg = "i2c adapter must return to an interpreter frame";
__ block_comment(msg);
__ stop(msg);
__ bind(L_ok);
__ block_comment("} verify_i2ce ");
}

// Must preserve original SP for loading incoming arguments because
// we need to align the outgoing SP for compiled code.
__ movptr(r11, rsp);
Expand Down Expand Up @@ -1051,12 +1002,12 @@ void SharedRuntime::gen_i2c_adapter(MacroAssembler *masm,
}

// ---------------------------------------------------------------
AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterFingerPrint* fingerprint) {
void SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm,
int total_args_passed,
int comp_args_on_stack,
const BasicType *sig_bt,
const VMRegPair *regs,
AdapterHandlerEntry* handler) {
address i2c_entry = __ pc();

gen_i2c_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs);
Expand Down Expand Up @@ -1118,7 +1069,8 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

gen_c2i_adapter(masm, total_args_passed, comp_args_on_stack, sig_bt, regs, skip_fixup);

return AdapterHandlerLibrary::new_entry(fingerprint, i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
handler->set_entry_points(i2c_entry, c2i_entry, c2i_unverified_entry, c2i_no_clinit_check_entry);
return;
}

int SharedRuntime::c_calling_convention(const BasicType *sig_bt,
Expand Down
Loading