8286825: Linker naming cleanup

Reviewed-by: mcimadamore, rehn
This commit is contained in:
Jorn Vernee 2022-05-23 10:03:28 +00:00
parent a0042de411
commit 7becf13e61
68 changed files with 391 additions and 395 deletions

View File

@ -30,12 +30,12 @@
#include "compiler/oopMap.hpp"
#include "logging/logStream.hpp"
#include "memory/resourceArea.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
#include "runtime/stubCodeGenerator.hpp"
#define __ _masm->
class NativeInvokerGenerator : public StubCodeGenerator {
class DowncallStubGenerator : public StubCodeGenerator {
BasicType* _signature;
int _num_args;
BasicType _ret_bt;
@ -50,7 +50,7 @@ class NativeInvokerGenerator : public StubCodeGenerator {
int _framesize;
OopMapSet* _oop_maps;
public:
NativeInvokerGenerator(CodeBuffer* buffer,
DowncallStubGenerator(CodeBuffer* buffer,
BasicType* signature,
int num_args,
BasicType ret_bt,
@ -88,16 +88,16 @@ public:
static const int native_invoker_code_size = 1024;
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
int locs_size = 64;
CodeBuffer code("nep_invoker_blob", native_invoker_code_size, locs_size);
NativeInvokerGenerator g(&code, signature, num_args, ret_bt, abi, input_registers, output_registers, needs_return_buffer);
DowncallStubGenerator g(&code, signature, num_args, ret_bt, abi, input_registers, output_registers, needs_return_buffer);
g.generate();
code.log_section_sizes("nep_invoker_blob");
@ -120,7 +120,7 @@ RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
return stub;
}
void NativeInvokerGenerator::generate() {
void DowncallStubGenerator::generate() {
enum layout {
rfp_off,
rfp_off2,

View File

@ -29,8 +29,8 @@
#include "oops/typeArrayOop.inline.hpp"
#include "oops/oopCast.inline.hpp"
#include "opto/matcher.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreign_globals.inline.hpp"
#include "prims/foreignGlobals.hpp"
#include "prims/foreignGlobals.inline.hpp"
#include "utilities/formatBuffer.hpp"
bool ABIDescriptor::is_volatile_reg(Register reg) const {

View File

@ -118,7 +118,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
if (is_entry_frame()) {
// an entry frame must have a valid fp.
return fp_safe && is_entry_frame_valid(thread);
} else if (is_optimized_entry_frame()) {
} else if (is_upcall_stub_frame()) {
return fp_safe;
}
@ -222,7 +222,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
address jcw = (address)sender.entry_frame_call_wrapper();
return thread->is_in_stack_range_excl(jcw, (address)sender.fp());
} else if (sender_blob->is_optimized_entry_blob()) {
} else if (sender_blob->is_upcall_stub()) {
return false;
}
@ -372,27 +372,27 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
return fr;
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
assert(frame.is_optimized_entry_frame(), "wrong frame");
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
assert(frame.is_upcall_stub_frame(), "wrong frame");
// need unextended_sp here, since normal sp is wrong for interpreter callees
return reinterpret_cast<OptimizedEntryBlob::FrameData*>(
return reinterpret_cast<UpcallStub::FrameData*>(
reinterpret_cast<address>(frame.unextended_sp()) + in_bytes(_frame_data_offset));
}
bool frame::optimized_entry_frame_is_first() const {
assert(is_optimized_entry_frame(), "must be optimzed entry frame");
OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
bool frame::upcall_stub_frame_is_first() const {
assert(is_upcall_stub_frame(), "must be optimzed entry frame");
UpcallStub* blob = _cb->as_upcall_stub();
JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
return jfa->last_Java_sp() == NULL;
}
frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
frame frame::sender_for_upcall_stub_frame(RegisterMap* map) const {
assert(map != NULL, "map must be set");
OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
UpcallStub* blob = _cb->as_upcall_stub();
// Java frame called from C; skip all C frames and return top C
// frame of that chunk as the sender
JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
assert(!optimized_entry_frame_is_first(), "must have a frame anchor to go back to");
assert(!upcall_stub_frame_is_first(), "must have a frame anchor to go back to");
assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
// Since we are walking the stack now this nested anchor is obviously walkable
// even if it wasn't when it was stacked.

View File

@ -397,9 +397,9 @@ inline frame frame::sender_raw(RegisterMap* map) const {
return map->stack_chunk()->sender(*this, map);
}
if (is_entry_frame()) return sender_for_entry_frame(map);
if (is_optimized_entry_frame()) return sender_for_optimized_entry_frame(map);
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
if (is_entry_frame()) return sender_for_entry_frame(map);
if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
if (_cb != NULL) return sender_for_compiled_frame(map);

View File

@ -266,7 +266,7 @@ void MethodHandles::jump_to_native_invoker(MacroAssembler* _masm, Register nep_r
// Load the invoker, as NEP -> .invoker
__ verify_oop(nep_reg);
__ access_load_at(T_ADDRESS, IN_HEAP, temp_target,
Address(nep_reg, NONZERO(jdk_internal_foreign_abi_NativeEntryPoint::invoker_offset_in_bytes())),
Address(nep_reg, NONZERO(jdk_internal_foreign_abi_NativeEntryPoint::downcall_stub_address_offset_in_bytes())),
noreg, noreg);
__ br(temp_target);

View File

@ -26,7 +26,7 @@
#include "asm/macroAssembler.hpp"
#include "logging/logStream.hpp"
#include "memory/resourceArea.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/signature.hpp"
@ -115,16 +115,16 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr
__ block_comment("} restore_callee_saved_regs ");
}
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ResourceMark rm;
const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
const CallRegs call_regs = ForeignGlobals::parse_call_regs(jconv);
CodeBuffer buffer("upcall_stub_linkToNative", /* code_size = */ 2048, /* locs_size = */ 1024);
CodeBuffer buffer("upcall_stub", /* code_size = */ 2048, /* locs_size = */ 1024);
Register shuffle_reg = r19;
JavaCallingConvention out_conv;
@ -157,7 +157,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
int arg_save_area_offset = res_save_area_offset + result_spiller.spill_size_bytes();
int reg_save_area_offset = arg_save_area_offset + arg_spilller.spill_size_bytes();
int frame_data_offset = reg_save_area_offset + reg_save_area_size;
int frame_bottom_offset = frame_data_offset + sizeof(OptimizedEntryBlob::FrameData);
int frame_bottom_offset = frame_data_offset + sizeof(UpcallStub::FrameData);
int ret_buf_offset = -1;
if (needs_return_buffer) {
@ -209,7 +209,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
__ block_comment("{ on_entry");
__ lea(c_rarg0, Address(sp, frame_data_offset));
__ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, ProgrammableUpcallHandler::on_entry));
__ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_entry));
__ blr(rscratch1);
__ mov(rthread, r0);
__ reinit_heapbase();
@ -286,7 +286,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
__ block_comment("{ on_exit");
__ lea(c_rarg0, Address(sp, frame_data_offset));
// stack already aligned
__ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, ProgrammableUpcallHandler::on_exit));
__ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_exit));
__ blr(rscratch1);
__ block_comment("} on_exit");
@ -306,7 +306,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
// Native caller has no idea how to handle exceptions,
// so we just crash here. Up to callee to catch exceptions.
__ verify_oop(r0);
__ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, ProgrammableUpcallHandler::handle_uncaught_exception));
__ movptr(rscratch1, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::handle_uncaught_exception));
__ blr(rscratch1);
__ should_not_reach_here();
@ -316,18 +316,18 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
#ifndef PRODUCT
stringStream ss;
ss.print("optimized_upcall_stub_%s", entry->signature()->as_C_string());
ss.print("upcall_stub_%s", entry->signature()->as_C_string());
const char* name = _masm->code_string(ss.as_string());
#else // PRODUCT
const char* name = "optimized_upcall_stub";
const char* name = "upcall_stub";
#endif // PRODUCT
OptimizedEntryBlob* blob
= OptimizedEntryBlob::create(name,
&buffer,
exception_handler_offset,
receiver,
in_ByteSize(frame_data_offset));
UpcallStub* blob
= UpcallStub::create(name,
&buffer,
exception_handler_offset,
receiver,
in_ByteSize(frame_data_offset));
if (TraceOptimizedUpcallStubs) {
blob->print_on(tty);

View File

@ -22,16 +22,16 @@
*/
#include "precompiled.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
#include "utilities/debug.hpp"
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
Unimplemented();
return nullptr;
}

View File

@ -23,7 +23,7 @@
#include "precompiled.hpp"
#include "code/vmreg.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "utilities/debug.hpp"
class MacroAssembler;

View File

@ -311,12 +311,12 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
return fr;
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
ShouldNotCallThis();
return nullptr;
}
bool frame::optimized_entry_frame_is_first() const {
bool frame::upcall_stub_frame_is_first() const {
ShouldNotCallThis();
return false;
}

View File

@ -22,15 +22,15 @@
*/
#include "precompiled.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
#include "utilities/debug.hpp"
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ShouldNotCallThis();
return nullptr;
}

View File

@ -23,16 +23,16 @@
*/
#include "precompiled.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
#include "utilities/debug.hpp"
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
Unimplemented();
return nullptr;
}

View File

@ -24,7 +24,7 @@
#include "precompiled.hpp"
#include "code/vmreg.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "utilities/debug.hpp"
class MacroAssembler;

View File

@ -204,12 +204,12 @@ frame frame::sender_for_entry_frame(RegisterMap *map) const {
return fr;
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
ShouldNotCallThis();
return nullptr;
}
bool frame::optimized_entry_frame_is_first() const {
bool frame::upcall_stub_frame_is_first() const {
ShouldNotCallThis();
return false;
}

View File

@ -23,15 +23,15 @@
*/
#include "precompiled.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
#include "utilities/debug.hpp"
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ShouldNotCallThis();
return nullptr;
}

View File

@ -27,13 +27,13 @@
#include "prims/universalNativeInvoker.hpp"
#include "utilities/debug.hpp"
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
Unimplemented();
return nullptr;
}

View File

@ -25,7 +25,7 @@
#include "precompiled.hpp"
#include "code/vmreg.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "utilities/debug.hpp"
class MacroAssembler;

View File

@ -343,17 +343,17 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
return fr;
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
ShouldNotCallThis();
return nullptr;
}
bool frame::optimized_entry_frame_is_first() const {
bool frame::upcall_stub_frame_is_first() const {
ShouldNotCallThis();
return false;
}
frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
frame frame::sender_for_upcall_stub_frame(RegisterMap* map) const {
ShouldNotCallThis();
return {};
}

View File

@ -24,15 +24,15 @@
*/
#include "precompiled.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
#include "utilities/debug.hpp"
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ShouldNotCallThis();
return nullptr;
}
}

View File

@ -22,16 +22,16 @@
*/
#include "precompiled.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
#include "utilities/debug.hpp"
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
Unimplemented();
return nullptr;
}

View File

@ -23,7 +23,7 @@
#include "precompiled.hpp"
#include "code/vmreg.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "utilities/debug.hpp"
class MacroAssembler;

View File

@ -215,12 +215,12 @@ frame frame::sender_for_entry_frame(RegisterMap *map) const {
return fr;
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
ShouldNotCallThis();
return nullptr;
}
bool frame::optimized_entry_frame_is_first() const {
bool frame::upcall_stub_frame_is_first() const {
ShouldNotCallThis();
return false;
}

View File

@ -22,15 +22,15 @@
*/
#include "precompiled.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
#include "utilities/debug.hpp"
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ShouldNotCallThis();
return nullptr;
}

View File

@ -22,15 +22,15 @@
*/
#include "precompiled.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
Unimplemented();
return nullptr;
}

View File

@ -26,15 +26,15 @@
#include "code/codeBlob.hpp"
#include "logging/logStream.hpp"
#include "memory/resourceArea.hpp"
#include "prims/foreign_globals.inline.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/foreignGlobals.inline.hpp"
#include "prims/downcallLinker.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "utilities/formatBuffer.hpp"
#define __ _masm->
class NativeInvokerGenerator : public StubCodeGenerator {
class DowncallStubGenerator : public StubCodeGenerator {
BasicType* _signature;
int _num_args;
BasicType _ret_bt;
@ -49,7 +49,7 @@ class NativeInvokerGenerator : public StubCodeGenerator {
int _framesize;
OopMapSet* _oop_maps;
public:
NativeInvokerGenerator(CodeBuffer* buffer,
DowncallStubGenerator(CodeBuffer* buffer,
BasicType* signature,
int num_args,
BasicType ret_bt,
@ -87,16 +87,16 @@ public:
static const int native_invoker_code_size = 1024;
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
int locs_size = 64;
CodeBuffer code("nep_invoker_blob", native_invoker_code_size, locs_size);
NativeInvokerGenerator g(&code, signature, num_args, ret_bt, abi, input_registers, output_registers, needs_return_buffer);
DowncallStubGenerator g(&code, signature, num_args, ret_bt, abi, input_registers, output_registers, needs_return_buffer);
g.generate();
code.log_section_sizes("nep_invoker_blob");
@ -119,7 +119,7 @@ RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
return stub;
}
void NativeInvokerGenerator::generate() {
void DowncallStubGenerator::generate() {
enum layout {
rbp_off,
rbp_off2,

View File

@ -23,7 +23,7 @@
#include "precompiled.hpp"
#include "code/vmreg.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "utilities/debug.hpp"
class MacroAssembler;

View File

@ -26,7 +26,7 @@
#include "runtime/jniHandles.inline.hpp"
#include "oops/typeArrayOop.inline.hpp"
#include "oops/oopCast.inline.hpp"
#include "prims/foreign_globals.inline.hpp"
#include "prims/foreignGlobals.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "utilities/formatBuffer.hpp"

View File

@ -106,7 +106,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
if (is_entry_frame()) {
// an entry frame must have a valid fp.
return fp_safe && is_entry_frame_valid(thread);
} else if (is_optimized_entry_frame()) {
} else if (is_upcall_stub_frame()) {
return fp_safe;
}
@ -211,7 +211,7 @@ bool frame::safe_for_sender(JavaThread *thread) {
address jcw = (address)sender.entry_frame_call_wrapper();
return thread->is_in_stack_range_excl(jcw, (address)sender.fp());
} else if (sender_blob->is_optimized_entry_blob()) {
} else if (sender_blob->is_upcall_stub()) {
return false;
}
@ -366,27 +366,27 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const {
return fr;
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
assert(frame.is_optimized_entry_frame(), "wrong frame");
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
assert(frame.is_upcall_stub_frame(), "wrong frame");
// need unextended_sp here, since normal sp is wrong for interpreter callees
return reinterpret_cast<OptimizedEntryBlob::FrameData*>(
return reinterpret_cast<UpcallStub::FrameData*>(
reinterpret_cast<address>(frame.unextended_sp()) + in_bytes(_frame_data_offset));
}
bool frame::optimized_entry_frame_is_first() const {
assert(is_optimized_entry_frame(), "must be optimzed entry frame");
OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
bool frame::upcall_stub_frame_is_first() const {
assert(is_upcall_stub_frame(), "must be optimzed entry frame");
UpcallStub* blob = _cb->as_upcall_stub();
JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
return jfa->last_Java_sp() == NULL;
}
frame frame::sender_for_optimized_entry_frame(RegisterMap* map) const {
frame frame::sender_for_upcall_stub_frame(RegisterMap* map) const {
assert(map != NULL, "map must be set");
OptimizedEntryBlob* blob = _cb->as_optimized_entry_blob();
UpcallStub* blob = _cb->as_upcall_stub();
// Java frame called from C; skip all C frames and return top C
// frame of that chunk as the sender
JavaFrameAnchor* jfa = blob->jfa_for_frame(*this);
assert(!optimized_entry_frame_is_first(), "must have a frame anchor to go back to");
assert(!upcall_stub_frame_is_first(), "must have a frame anchor to go back to");
assert(jfa->last_Java_sp() > sp(), "must be above this frame on stack");
// Since we are walking the stack now this nested anchor is obviously walkable
// even if it wasn't when it was stacked.

View File

@ -384,9 +384,9 @@ inline frame frame::sender_raw(RegisterMap* map) const {
return map->stack_chunk()->sender(*this, map);
}
if (is_entry_frame()) return sender_for_entry_frame(map);
if (is_optimized_entry_frame()) return sender_for_optimized_entry_frame(map);
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
if (is_entry_frame()) return sender_for_entry_frame(map);
if (is_upcall_stub_frame()) return sender_for_upcall_stub_frame(map);
if (is_interpreted_frame()) return sender_for_interpreter_frame(map);
assert(_cb == CodeCache::find_blob(pc()), "Must be the same");
if (_cb != NULL) return sender_for_compiled_frame(map);

View File

@ -211,7 +211,7 @@ void MethodHandles::jump_to_native_invoker(MacroAssembler* _masm, Register nep_r
// Load the invoker, as NEP -> .invoker
__ verify_oop(nep_reg);
__ access_load_at(T_ADDRESS, IN_HEAP, temp_target,
Address(nep_reg, NONZERO(jdk_internal_foreign_abi_NativeEntryPoint::invoker_offset_in_bytes())),
Address(nep_reg, NONZERO(jdk_internal_foreign_abi_NativeEntryPoint::downcall_stub_address_offset_in_bytes())),
noreg, noreg);
__ jmp(temp_target);

View File

@ -22,14 +22,14 @@
*/
#include "precompiled.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ShouldNotCallThis();
return nullptr;
}

View File

@ -29,8 +29,8 @@
#include "compiler/disassembler.hpp"
#include "logging/logStream.hpp"
#include "memory/resourceArea.hpp"
#include "prims/foreign_globals.inline.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/foreignGlobals.inline.hpp"
#include "prims/upcallLinker.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubRoutines.hpp"
@ -168,15 +168,15 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr
// "0" is assigned for rax and for xmm0. Thus we need to ignore -Wnonnull.
PRAGMA_DIAG_PUSH
PRAGMA_NONNULL_IGNORED
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
const CallRegs call_regs = ForeignGlobals::parse_call_regs(jconv);
CodeBuffer buffer("upcall_stub_linkToNative", /* code_size = */ 2048, /* locs_size = */ 1024);
CodeBuffer buffer("upcall_stub", /* code_size = */ 2048, /* locs_size = */ 1024);
Register shuffle_reg = rbx;
JavaCallingConvention out_conv;
@ -209,7 +209,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
int arg_save_area_offset = res_save_area_offset + result_spiller.spill_size_bytes();
int reg_save_area_offset = arg_save_area_offset + arg_spilller.spill_size_bytes();
int frame_data_offset = reg_save_area_offset + reg_save_area_size;
int frame_bottom_offset = frame_data_offset + sizeof(OptimizedEntryBlob::FrameData);
int frame_bottom_offset = frame_data_offset + sizeof(UpcallStub::FrameData);
int ret_buf_offset = -1;
if (needs_return_buffer) {
@ -267,7 +267,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
__ vzeroupper();
__ lea(c_rarg0, Address(rsp, frame_data_offset));
// stack already aligned
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, ProgrammableUpcallHandler::on_entry)));
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, UpcallLinker::on_entry)));
__ movptr(r15_thread, rax);
__ reinit_heapbase();
__ block_comment("} on_entry");
@ -343,7 +343,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
__ vzeroupper();
__ lea(c_rarg0, Address(rsp, frame_data_offset));
// stack already aligned
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, ProgrammableUpcallHandler::on_exit)));
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, UpcallLinker::on_exit)));
__ reinit_heapbase();
__ block_comment("} on_exit");
@ -369,7 +369,7 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
__ mov(c_rarg0, rax);
__ andptr(rsp, -StackAlignmentInBytes); // align stack as required by ABI
__ subptr(rsp, frame::arg_reg_save_area_bytes); // windows (not really needed)
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, ProgrammableUpcallHandler::handle_uncaught_exception)));
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, UpcallLinker::handle_uncaught_exception)));
__ should_not_reach_here();
__ block_comment("} exception handler");
@ -379,18 +379,18 @@ address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiv
#ifndef PRODUCT
stringStream ss;
ss.print("optimized_upcall_stub_%s", entry->signature()->as_C_string());
ss.print("upcall_stub_%s", entry->signature()->as_C_string());
const char* name = _masm->code_string(ss.as_string());
#else // PRODUCT
const char* name = "optimized_upcall_stub";
const char* name = "upcall_stub";
#endif // PRODUCT
OptimizedEntryBlob* blob
= OptimizedEntryBlob::create(name,
&buffer,
exception_handler_offset,
receiver,
in_ByteSize(frame_data_offset));
UpcallStub* blob
= UpcallStub::create(name,
&buffer,
exception_handler_offset,
receiver,
in_ByteSize(frame_data_offset));
if (TraceOptimizedUpcallStubs) {
blob->print_on(tty);

View File

@ -22,15 +22,15 @@
*/
#include "precompiled.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
RuntimeStub* ProgrammableInvoker::make_native_invoker(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
RuntimeStub* DowncallLinker::make_downcall_stub(BasicType* signature,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer) {
Unimplemented();
return nullptr;
}

View File

@ -23,7 +23,7 @@
#include "precompiled.hpp"
#include "code/vmreg.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "utilities/debug.hpp"
class MacroAssembler;

View File

@ -62,12 +62,12 @@ frame frame::sender_for_entry_frame(RegisterMap *map) const {
return frame(zeroframe()->next(), sender_sp());
}
OptimizedEntryBlob::FrameData* OptimizedEntryBlob::frame_data_for_frame(const frame& frame) const {
UpcallStub::FrameData* UpcallStub::frame_data_for_frame(const frame& frame) const {
ShouldNotCallThis();
return nullptr;
}
bool frame::optimized_entry_frame_is_first() const {
bool frame::upcall_stub_frame_is_first() const {
ShouldNotCallThis();
return false;
}

View File

@ -22,14 +22,14 @@
*/
#include "precompiled.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
address ProgrammableUpcallHandler::generate_optimized_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size) {
ShouldNotCallThis();
return nullptr;
}

View File

@ -4238,11 +4238,11 @@ bool java_lang_invoke_LambdaForm::is_instance(oop obj) {
}
int jdk_internal_foreign_abi_NativeEntryPoint::_method_type_offset;
int jdk_internal_foreign_abi_NativeEntryPoint::_invoker_offset;
int jdk_internal_foreign_abi_NativeEntryPoint::_downcall_stub_address_offset;
#define NEP_FIELDS_DO(macro) \
macro(_method_type_offset, k, "methodType", java_lang_invoke_MethodType_signature, false); \
macro(_invoker_offset, k, "invoker", long_signature, false);
macro(_method_type_offset, k, "methodType", java_lang_invoke_MethodType_signature, false); \
macro(_downcall_stub_address_offset, k, "downcallStubAddress", long_signature, false);
bool jdk_internal_foreign_abi_NativeEntryPoint::is_instance(oop obj) {
return obj != NULL && is_subclass(obj->klass());
@ -4263,8 +4263,8 @@ oop jdk_internal_foreign_abi_NativeEntryPoint::method_type(oop entry) {
return entry->obj_field(_method_type_offset);
}
jlong jdk_internal_foreign_abi_NativeEntryPoint::invoker(oop entry) {
return entry->long_field(_invoker_offset);
jlong jdk_internal_foreign_abi_NativeEntryPoint::downcall_stub_address(oop entry) {
return entry->long_field(_downcall_stub_address_offset);
}
int jdk_internal_foreign_abi_ABIDescriptor::_inputStorage_offset;

View File

@ -1284,7 +1284,7 @@ class jdk_internal_foreign_abi_NativeEntryPoint: AllStatic {
private:
static int _method_type_offset;
static int _invoker_offset;
static int _downcall_stub_address_offset;
static void compute_offsets();
@ -1293,7 +1293,7 @@ class jdk_internal_foreign_abi_NativeEntryPoint: AllStatic {
// Accessors
static oop method_type(oop entry);
static jlong invoker(oop entry);
static jlong downcall_stub_address(oop entry);
// Testers
static bool is_subclass(Klass* klass) {
@ -1303,8 +1303,8 @@ class jdk_internal_foreign_abi_NativeEntryPoint: AllStatic {
static bool is_instance(oop obj);
// Accessors for code generation:
static int method_type_offset_in_bytes() { return _method_type_offset; }
static int invoker_offset_in_bytes() { return _invoker_offset; }
static int method_type_offset_in_bytes() { return _method_type_offset; }
static int downcall_stub_address_offset_in_bytes() { return _downcall_stub_address_offset; }
};
class jdk_internal_foreign_abi_ABIDescriptor: AllStatic {

View File

@ -370,7 +370,7 @@
template(jdk_internal_foreign_abi_VMStorage_signature, "Ljdk/internal/foreign/abi/VMStorage;") \
template(jdk_internal_foreign_abi_VMStorage_array_signature, "[Ljdk/internal/foreign/abi/VMStorage;") \
template(jdk_internal_foreign_abi_VMStorage_array_array_signature, "[[Ljdk/internal/foreign/abi/VMStorage;") \
template(jdk_internal_foreign_abi_CallConv, "jdk/internal/foreign/abi/ProgrammableUpcallHandler$CallRegs") \
template(jdk_internal_foreign_abi_CallConv, "jdk/internal/foreign/abi/UpcallLinker$CallRegs") \
\
/* Support for JVMCI */ \
JVMCI_VM_SYMBOLS_DO(template, do_alias) \

View File

@ -723,12 +723,12 @@ void DeoptimizationBlob::print_value_on(outputStream* st) const {
st->print_cr("Deoptimization (frame not available)");
}
// Implementation of OptimizedEntryBlob
// Implementation of UpcallStub
OptimizedEntryBlob::OptimizedEntryBlob(const char* name, CodeBuffer* cb, int size,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset) :
RuntimeBlob(name, cb, sizeof(OptimizedEntryBlob), size, CodeOffsets::frame_never_safe, 0 /* no frame size */,
UpcallStub::UpcallStub(const char* name, CodeBuffer* cb, int size,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset) :
RuntimeBlob(name, cb, sizeof(UpcallStub), size, CodeOffsets::frame_never_safe, 0 /* no frame size */,
/* oop maps = */ nullptr, /* caller must gc arguments = */ false),
_exception_handler_offset(exception_handler_offset),
_receiver(receiver),
@ -736,58 +736,58 @@ OptimizedEntryBlob::OptimizedEntryBlob(const char* name, CodeBuffer* cb, int siz
CodeCache::commit(this);
}
void* OptimizedEntryBlob::operator new(size_t s, unsigned size) throw() {
void* UpcallStub::operator new(size_t s, unsigned size) throw() {
return CodeCache::allocate(size, CodeBlobType::NonNMethod);
}
OptimizedEntryBlob* OptimizedEntryBlob::create(const char* name, CodeBuffer* cb,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset) {
UpcallStub* UpcallStub::create(const char* name, CodeBuffer* cb,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset) {
ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock
OptimizedEntryBlob* blob = nullptr;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(OptimizedEntryBlob));
UpcallStub* blob = nullptr;
unsigned int size = CodeBlob::allocation_size(cb, sizeof(UpcallStub));
{
MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
blob = new (size) OptimizedEntryBlob(name, cb, size,
blob = new (size) UpcallStub(name, cb, size,
exception_handler_offset, receiver, frame_data_offset);
}
// Track memory usage statistic after releasing CodeCache_lock
MemoryService::track_code_cache_memory_usage();
trace_new_stub(blob, "OptimizedEntryBlob");
trace_new_stub(blob, "UpcallStub");
return blob;
}
void OptimizedEntryBlob::oops_do(OopClosure* f, const frame& frame) {
void UpcallStub::oops_do(OopClosure* f, const frame& frame) {
frame_data_for_frame(frame)->old_handles->oops_do(f);
}
JavaFrameAnchor* OptimizedEntryBlob::jfa_for_frame(const frame& frame) const {
JavaFrameAnchor* UpcallStub::jfa_for_frame(const frame& frame) const {
return &frame_data_for_frame(frame)->jfa;
}
void OptimizedEntryBlob::free(OptimizedEntryBlob* blob) {
void UpcallStub::free(UpcallStub* blob) {
assert(blob != nullptr, "caller must check for NULL");
JNIHandles::destroy_global(blob->receiver());
RuntimeBlob::free(blob);
}
void OptimizedEntryBlob::preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) {
void UpcallStub::preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) {
ShouldNotReachHere(); // caller should never have to gc arguments
}
// Misc.
void OptimizedEntryBlob::verify() {
void UpcallStub::verify() {
// unimplemented
}
void OptimizedEntryBlob::print_on(outputStream* st) const {
void UpcallStub::print_on(outputStream* st) const {
RuntimeBlob::print_on(st);
print_value_on(st);
}
void OptimizedEntryBlob::print_value_on(outputStream* st) const {
st->print_cr("OptimizedEntryBlob (" INTPTR_FORMAT ") used for %s", p2i(this), name());
void UpcallStub::print_value_on(outputStream* st) const {
st->print_cr("UpcallStub (" INTPTR_FORMAT ") used for %s", p2i(this), name());
}

View File

@ -67,7 +67,7 @@ struct CodeBlobType {
// ExceptionBlob : Used for stack unrolling
// SafepointBlob : Used to handle illegal instruction exceptions
// UncommonTrapBlob : Used to handle uncommon traps
// OptimizedEntryBlob : Used for upcalls from native code
// UpcallStub : Used for upcalls from native code
//
//
// Layout : continuous in the CodeCache
@ -79,9 +79,9 @@ struct CodeBlobType {
class CodeBlobLayout;
class OptimizedEntryBlob; // for as_optimized_entry_blob()
class UpcallStub; // for as_upcall_stub()
class RuntimeStub; // for as_runtime_stub()
class JavaFrameAnchor; // for OptimizedEntryBlob::jfa_for_frame
class JavaFrameAnchor; // for UpcallStub::jfa_for_frame
class CodeBlob {
friend class VMStructs;
@ -154,7 +154,7 @@ public:
virtual bool is_adapter_blob() const { return false; }
virtual bool is_vtable_blob() const { return false; }
virtual bool is_method_handles_adapter_blob() const { return false; }
virtual bool is_optimized_entry_blob() const { return false; }
virtual bool is_upcall_stub() const { return false; }
bool is_compiled() const { return _is_compiled; }
const bool* is_compiled_addr() const { return &_is_compiled; }
@ -165,13 +165,13 @@ public:
CompilerType compiler_type() const { return _type; }
// Casting
nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; }
nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
CodeBlob* as_codeblob_or_null() const { return (CodeBlob*) this; }
OptimizedEntryBlob* as_optimized_entry_blob() const { assert(is_optimized_entry_blob(), "must be entry blob"); return (OptimizedEntryBlob*) this; }
RuntimeStub* as_runtime_stub() const { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; }
nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; }
CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; }
CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; }
CodeBlob* as_codeblob_or_null() const { return (CodeBlob*) this; }
UpcallStub* as_upcall_stub() const { assert(is_upcall_stub(), "must be upcall stub"); return (UpcallStub*) this; }
RuntimeStub* as_runtime_stub() const { assert(is_runtime_stub(), "must be runtime blob"); return (RuntimeStub*) this; }
// Boundaries
address header_begin() const { return (address) this; }
@ -409,7 +409,7 @@ class BufferBlob: public RuntimeBlob {
friend class AdapterBlob;
friend class VtableBlob;
friend class MethodHandlesAdapterBlob;
friend class OptimizedEntryBlob;
friend class UpcallStub;
friend class WhiteBox;
private:
@ -753,16 +753,17 @@ class SafepointBlob: public SingletonBlob {
//----------------------------------------------------------------------------------------------------
class ProgrammableUpcallHandler;
class UpcallLinker;
class OptimizedEntryBlob: public RuntimeBlob {
friend class ProgrammableUpcallHandler;
// A (Panama) upcall stub. Not used by JNI.
class UpcallStub: public RuntimeBlob {
friend class UpcallLinker;
private:
intptr_t _exception_handler_offset;
jobject _receiver;
ByteSize _frame_data_offset;
OptimizedEntryBlob(const char* name, CodeBuffer* cb, int size,
UpcallStub(const char* name, CodeBuffer* cb, int size,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset);
@ -779,11 +780,11 @@ class OptimizedEntryBlob: public RuntimeBlob {
FrameData* frame_data_for_frame(const frame& frame) const;
public:
// Creation
static OptimizedEntryBlob* create(const char* name, CodeBuffer* cb,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset);
static UpcallStub* create(const char* name, CodeBuffer* cb,
intptr_t exception_handler_offset,
jobject receiver, ByteSize frame_data_offset);
static void free(OptimizedEntryBlob* blob);
static void free(UpcallStub* blob);
address exception_handler() { return code_begin() + _exception_handler_offset; }
jobject receiver() { return _receiver; }
@ -791,7 +792,7 @@ class OptimizedEntryBlob: public RuntimeBlob {
JavaFrameAnchor* jfa_for_frame(const frame& frame) const;
// Typing
virtual bool is_optimized_entry_blob() const override { return true; }
virtual bool is_upcall_stub() const override { return true; }
// GC/Verification support
void oops_do(OopClosure* f, const frame& frame);

View File

@ -21,22 +21,22 @@
* questions.
*/
#ifndef SHARE_VM_PRIMS_UNIVERSALNATIVEINVOKER_HPP
#define SHARE_VM_PRIMS_UNIVERSALNATIVEINVOKER_HPP
#ifndef SHARE_VM_PRIMS_DOWNCALLLINKER_HPP
#define SHARE_VM_PRIMS_DOWNCALLLINKER_HPP
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
class RuntimeStub;
class ProgrammableInvoker: AllStatic {
class DowncallLinker: AllStatic {
public:
static RuntimeStub* make_native_invoker(BasicType*,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer);
static RuntimeStub* make_downcall_stub(BasicType*,
int num_args,
BasicType ret_bt,
const ABIDescriptor& abi,
const GrowableArray<VMReg>& input_registers,
const GrowableArray<VMReg>& output_registers,
bool needs_return_buffer);
};
#endif // SHARE_VM_PRIMS_UNIVERSALNATIVEINVOKER_HPP
#endif // SHARE_VM_PRIMS_DOWNCALLLINKER_HPP

View File

@ -22,10 +22,10 @@
*/
#include "precompiled.hpp"
#include "foreign_globals.hpp"
#include "foreignGlobals.hpp"
#include "classfile/javaClasses.hpp"
#include "memory/resourceArea.hpp"
#include "prims/foreign_globals.inline.hpp"
#include "prims/foreignGlobals.inline.hpp"
#include "runtime/jniHandles.inline.hpp"
#define FOREIGN_ABI "jdk/internal/foreign/abi/"

View File

@ -30,7 +30,7 @@
#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"
#include CPU_HEADER(foreign_globals)
#include CPU_HEADER(foreignGlobals)
class CallingConventionClosure {
public:

View File

@ -24,7 +24,7 @@
#ifndef SHARE_PRIMS_FOREIGN_GLOBALS_INLINE_HPP
#define SHARE_PRIMS_FOREIGN_GLOBALS_INLINE_HPP
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
#include "classfile/javaClasses.hpp"
#include "oops/oopsHierarchy.hpp"

View File

@ -30,12 +30,12 @@
#include "memory/resourceArea.hpp"
#include "oops/typeArrayOop.inline.hpp"
#include "oops/oopCast.inline.hpp"
#include "prims/foreign_globals.inline.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/foreignGlobals.inline.hpp"
#include "prims/downcallLinker.hpp"
#include "runtime/jniHandles.inline.hpp"
JNI_ENTRY(jlong, NEP_makeInvoker(JNIEnv* env, jclass _unused, jobject method_type, jobject jabi,
jobjectArray arg_moves, jobjectArray ret_moves, jboolean needs_return_buffer))
JNI_ENTRY(jlong, NEP_makeDowncallStub(JNIEnv* env, jclass _unused, jobject method_type, jobject jabi,
jobjectArray arg_moves, jobjectArray ret_moves, jboolean needs_return_buffer))
ResourceMark rm;
const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
@ -73,11 +73,11 @@ JNI_ENTRY(jlong, NEP_makeInvoker(JNIEnv* env, jclass _unused, jobject method_typ
output_regs.push(ForeignGlobals::parse_vmstorage(ret_moves_oop->obj_at(i)));
}
return (jlong) ProgrammableInvoker::make_native_invoker(
return (jlong) DowncallLinker::make_downcall_stub(
basic_type, pslots, ret_bt, abi, input_regs, output_regs, needs_return_buffer)->code_begin();
JNI_END
JNI_ENTRY(jboolean, NEP_freeInvoker(JNIEnv* env, jclass _unused, jlong invoker))
JNI_ENTRY(jboolean, NEP_freeDowncallStub(JNIEnv* env, jclass _unused, jlong invoker))
// safe to call without code cache lock, because stub is always alive
CodeBlob* cb = CodeCache::find_blob((char*) invoker);
if (cb == nullptr) {
@ -94,8 +94,8 @@ JNI_END
#define VM_STORAGE_ARR "[Ljdk/internal/foreign/abi/VMStorage;"
static JNINativeMethod NEP_methods[] = {
{CC "makeInvoker", CC "(" METHOD_TYPE ABI_DESC VM_STORAGE_ARR VM_STORAGE_ARR "Z)J", FN_PTR(NEP_makeInvoker)},
{CC "freeInvoker0", CC "(J)Z", FN_PTR(NEP_freeInvoker)},
{CC "makeDowncallStub", CC "(" METHOD_TYPE ABI_DESC VM_STORAGE_ARR VM_STORAGE_ARR "Z)J", FN_PTR(NEP_makeDowncallStub)},
{CC "freeDowncallStub0", CC "(J)Z", FN_PTR(NEP_freeDowncallStub)},
};
#undef METHOD_TYPE

View File

@ -202,7 +202,7 @@ extern "C" {
void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterReferencesMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterUpcallHandlerMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterProgrammableUpcallHandlerMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterUpcallLinkerMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterNativeEntryPointMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
@ -220,7 +220,7 @@ static JNINativeMethod lookup_special_native_methods[] = {
{ CC"Java_jdk_internal_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },
{ CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
{ CC"Java_jdk_internal_foreign_abi_UpcallStubs_registerNatives", NULL, FN_PTR(JVM_RegisterUpcallHandlerMethods) },
{ CC"Java_jdk_internal_foreign_abi_ProgrammableUpcallHandler_registerNatives", NULL, FN_PTR(JVM_RegisterProgrammableUpcallHandlerMethods) },
{ CC"Java_jdk_internal_foreign_abi_UpcallLinker_registerNatives", NULL, FN_PTR(JVM_RegisterUpcallLinkerMethods) },
{ CC"Java_jdk_internal_foreign_abi_NativeEntryPoint_registerNatives", NULL, FN_PTR(JVM_RegisterNativeEntryPointMethods) },
{ CC"Java_jdk_internal_perf_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) },
{ CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) },

View File

@ -27,7 +27,7 @@
#include "classfile/systemDictionary.hpp"
#include "compiler/compilationPolicy.hpp"
#include "memory/resourceArea.hpp"
#include "prims/universalUpcallHandler.hpp"
#include "prims/upcallLinker.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/jniHandles.inline.hpp"
@ -57,7 +57,7 @@ struct UpcallContext {
APPROVED_CPP_THREAD_LOCAL UpcallContext threadContext;
JavaThread* ProgrammableUpcallHandler::maybe_attach_and_get_thread() {
JavaThread* UpcallLinker::maybe_attach_and_get_thread() {
JavaThread* thread = JavaThread::current_or_null();
if (thread == nullptr) {
JavaVM_ *vm = (JavaVM *)(&main_vm);
@ -72,7 +72,7 @@ JavaThread* ProgrammableUpcallHandler::maybe_attach_and_get_thread() {
}
// modelled after JavaCallWrapper::JavaCallWrapper
JavaThread* ProgrammableUpcallHandler::on_entry(OptimizedEntryBlob::FrameData* context) {
JavaThread* UpcallLinker::on_entry(UpcallStub::FrameData* context) {
JavaThread* thread = maybe_attach_and_get_thread();
context->thread = thread;
@ -110,7 +110,7 @@ JavaThread* ProgrammableUpcallHandler::on_entry(OptimizedEntryBlob::FrameData* c
}
// modelled after JavaCallWrapper::~JavaCallWrapper
void ProgrammableUpcallHandler::on_exit(OptimizedEntryBlob::FrameData* context) {
void UpcallLinker::on_exit(UpcallStub::FrameData* context) {
JavaThread* thread = context->thread;
assert(thread == JavaThread::current(), "must still be the same thread");
@ -133,7 +133,7 @@ void ProgrammableUpcallHandler::on_exit(OptimizedEntryBlob::FrameData* context)
assert(!thread->has_pending_exception(), "Upcall can not throw an exception");
}
void ProgrammableUpcallHandler::handle_uncaught_exception(oop exception) {
void UpcallLinker::handle_uncaught_exception(oop exception) {
ResourceMark rm;
// Based on CATCH macro
tty->print_cr("Uncaught exception:");
@ -141,7 +141,7 @@ void ProgrammableUpcallHandler::handle_uncaught_exception(oop exception) {
ShouldNotReachHere();
}
JVM_ENTRY(jlong, PUH_AllocateOptimizedUpcallStub(JNIEnv *env, jclass unused, jobject mh, jobject abi, jobject conv,
JVM_ENTRY(jlong, UL_MakeUpcallStub(JNIEnv *env, jclass unused, jobject mh, jobject abi, jobject conv,
jboolean needs_return_buffer, jlong ret_buf_size))
ResourceMark rm(THREAD);
Handle mh_h(THREAD, JNIHandles::resolve(mh));
@ -177,23 +177,23 @@ JVM_ENTRY(jlong, PUH_AllocateOptimizedUpcallStub(JNIEnv *env, jclass unused, job
BasicType* in_sig_bt = out_sig_bt + 1;
int total_in_args = total_out_args - 1;
return (jlong) ProgrammableUpcallHandler::generate_optimized_upcall_stub(
return (jlong) UpcallLinker::make_upcall_stub(
mh_j, entry, in_sig_bt, total_in_args, out_sig_bt, total_out_args, ret_type, abi, conv, needs_return_buffer, checked_cast<int>(ret_buf_size));
JVM_END
#define CC (char*) /*cast a literal from (const char*)*/
#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
static JNINativeMethod PUH_methods[] = {
{CC "allocateOptimizedUpcallStub", CC "(" "Ljava/lang/invoke/MethodHandle;" "L" FOREIGN_ABI "ABIDescriptor;" "L" FOREIGN_ABI "ProgrammableUpcallHandler$CallRegs;" "ZJ)J", FN_PTR(PUH_AllocateOptimizedUpcallStub)},
static JNINativeMethod UL_methods[] = {
{CC "makeUpcallStub", CC "(" "Ljava/lang/invoke/MethodHandle;" "L" FOREIGN_ABI "ABIDescriptor;" "L" FOREIGN_ABI "UpcallLinker$CallRegs;" "ZJ)J", FN_PTR(UL_MakeUpcallStub)},
};
/**
* This one function is exported, used by NativeLookup.
*/
JNI_ENTRY(void, JVM_RegisterProgrammableUpcallHandlerMethods(JNIEnv *env, jclass PUH_class))
JNI_ENTRY(void, JVM_RegisterUpcallLinkerMethods(JNIEnv *env, jclass UL_class))
ThreadToNativeFromVM ttnfv(thread);
int status = env->RegisterNatives(PUH_class, PUH_methods, sizeof(PUH_methods)/sizeof(JNINativeMethod));
int status = env->RegisterNatives(UL_class, UL_methods, sizeof(UL_methods)/sizeof(JNINativeMethod));
guarantee(status == JNI_OK && !env->ExceptionOccurred(),
"register jdk.internal.foreign.abi.ProgrammableUpcallHandler natives");
"register jdk.internal.foreign.abi.UpcallLinker natives");
JNI_END

View File

@ -21,29 +21,29 @@
* questions.
*/
#ifndef SHARE_VM_PRIMS_UNIVERSALUPCALLHANDLER_HPP
#define SHARE_VM_PRIMS_UNIVERSALUPCALLHANDLER_HPP
#ifndef SHARE_VM_PRIMS_UPCALLLINKER_HPP
#define SHARE_VM_PRIMS_UPCALLLINKER_HPP
#include "asm/codeBuffer.hpp"
#include "code/codeBlob.hpp"
#include "prims/foreign_globals.hpp"
#include "prims/foreignGlobals.hpp"
class JavaThread;
class ProgrammableUpcallHandler {
class UpcallLinker {
private:
static void handle_uncaught_exception(oop exception);
static JavaThread* maybe_attach_and_get_thread();
static JavaThread* on_entry(OptimizedEntryBlob::FrameData* context);
static void on_exit(OptimizedEntryBlob::FrameData* context);
static JavaThread* on_entry(UpcallStub::FrameData* context);
static void on_exit(UpcallStub::FrameData* context);
public:
static address generate_optimized_upcall_stub(jobject mh, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size);
static address make_upcall_stub(jobject mh, Method* entry,
BasicType* in_sig_bt, int total_in_args,
BasicType* out_sig_bt, int total_out_args,
BasicType ret_type,
jobject jabi, jobject jconv,
bool needs_return_buffer, int ret_buf_size);
};
#endif // SHARE_VM_PRIMS_UNIVERSALUPCALLHANDLER_HPP
#endif // SHARE_VM_PRIMS_UPCALLLINKER_HPP

View File

@ -32,7 +32,7 @@ JVM_ENTRY(static jboolean, UH_FreeUpcallStub0(JNIEnv *env, jobject _unused, jlon
if (cb == nullptr) {
return false;
}
OptimizedEntryBlob::free(cb->as_optimized_entry_blob());
UpcallStub::free(cb->as_upcall_stub());
return true;
JVM_END

View File

@ -1153,8 +1153,8 @@ void frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf,
oops_interpreted_do(f, map, use_interpreter_oop_map_cache);
} else if (is_entry_frame()) {
oops_entry_do(f, map);
} else if (is_optimized_entry_frame()) {
_cb->as_optimized_entry_blob()->oops_do(f, *this);
} else if (is_upcall_stub_frame()) {
_cb->as_upcall_stub()->oops_do(f, *this);
} else if (CodeCache::contains(pc())) {
oops_code_blob_do(f, cf, df, derived_mode, map);
} else {

View File

@ -188,7 +188,7 @@ class frame {
bool is_compiled_frame() const;
bool is_safepoint_blob_frame() const;
bool is_deoptimized_frame() const;
bool is_optimized_entry_frame() const;
bool is_upcall_stub_frame() const;
bool is_heap_frame() const { return _on_heap; }
// testers
@ -200,7 +200,7 @@ class frame {
// is this frame doing a call using the compiled calling convention?
bool is_compiled_caller() const {
return is_compiled_frame() || is_optimized_entry_frame();
return is_compiled_frame() || is_upcall_stub_frame();
}
// tells whether this frame is marked for deoptimization
@ -238,7 +238,7 @@ class frame {
frame sender_for_entry_frame(RegisterMap* map) const;
frame sender_for_interpreter_frame(RegisterMap* map) const;
frame sender_for_native_frame(RegisterMap* map) const;
frame sender_for_optimized_entry_frame(RegisterMap* map) const;
frame sender_for_upcall_stub_frame(RegisterMap* map) const;
bool is_entry_frame_valid(JavaThread* thread) const;
@ -420,7 +420,7 @@ class frame {
// tells whether there is another chunk of Delta stack above
bool entry_frame_is_first() const;
bool optimized_entry_frame_is_first() const;
bool upcall_stub_frame_is_first() const;
// Safepoints

View File

@ -54,12 +54,12 @@ inline bool frame::is_stub_frame() const {
inline bool frame::is_first_frame() const {
return (is_entry_frame() && entry_frame_is_first())
// Optimized entry frames are only present on certain platforms
|| (is_optimized_entry_frame() && optimized_entry_frame_is_first());
// Upcall stub frames entry frames are only present on certain platforms
|| (is_upcall_stub_frame() && upcall_stub_frame_is_first());
}
inline bool frame::is_optimized_entry_frame() const {
return _cb != NULL && _cb->is_optimized_entry_blob();
inline bool frame::is_upcall_stub_frame() const {
return _cb != NULL && _cb->is_upcall_stub();
}
inline bool frame::is_compiled_frame() const {

View File

@ -38,7 +38,7 @@
#include "memory/universe.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
#include "prims/universalNativeInvoker.hpp"
#include "prims/downcallLinker.hpp"
#include "runtime/globals.hpp"
#include "runtime/atomic.hpp"
#include "runtime/continuation.hpp"

View File

@ -34,7 +34,7 @@
//
class JavaThread;
class MacroAssembler;
class ProgrammableUpcallHandler;
class UpcallLinker;
class ZeroFrame;
class JavaFrameAnchor {
@ -53,7 +53,7 @@ friend class VMStructs;
friend class JVMCIVMStructs;
friend class BytecodeInterpreter;
friend class JavaCallWrapper;
friend class ProgrammableUpcallHandler;
friend class UpcallLinker;
private:
//

View File

@ -513,8 +513,8 @@ address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* curr
// JavaCallWrapper::~JavaCallWrapper
return StubRoutines::catch_exception_entry();
}
if (blob != NULL && blob->is_optimized_entry_blob()) {
return ((OptimizedEntryBlob*)blob)->exception_handler();
if (blob != NULL && blob->is_upcall_stub()) {
return ((UpcallStub*)blob)->exception_handler();
}
// Interpreted code
if (Interpreter::contains(return_address)) {
@ -1459,7 +1459,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method_ic_miss(JavaThread*
frame stub_frame = current->last_frame();
assert(stub_frame.is_runtime_frame(), "sanity check");
frame caller_frame = stub_frame.sender(&reg_map);
assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame() && !caller_frame.is_optimized_entry_frame(), "unexpected frame");
assert(!caller_frame.is_interpreted_frame() && !caller_frame.is_entry_frame() && !caller_frame.is_upcall_stub_frame(), "unexpected frame");
#endif /* ASSERT */
methodHandle callee_method;
@ -1492,7 +1492,7 @@ JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method(JavaThread* current)
if (caller_frame.is_interpreted_frame() ||
caller_frame.is_entry_frame() ||
caller_frame.is_optimized_entry_frame()) {
caller_frame.is_upcall_stub_frame()) {
Method* callee = current->callee_target();
guarantee(callee != NULL && callee->is_method(), "bad handshake");
current->set_vm_result_2(callee);

View File

@ -44,14 +44,9 @@ import static java.lang.invoke.MethodHandles.identity;
import static java.lang.invoke.MethodHandles.insertArguments;
import static java.lang.invoke.MethodType.methodType;
/**
* This class implements native call invocation through a so called 'universal adapter'. A universal adapter takes
* an array of longs together with a call 'recipe', which is used to move the arguments in the right places as
* expected by the system ABI.
*/
public class ProgrammableInvoker {
public class DowncallLinker {
private static final boolean USE_SPEC = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty("jdk.internal.foreign.ProgrammableInvoker.USE_SPEC", "true"));
GetPropertyAction.privilegedGetProperty("jdk.internal.foreign.DowncallLinker.USE_SPEC", "true"));
private static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess();
@ -62,7 +57,7 @@ public class ProgrammableInvoker {
static {
try {
MethodHandles.Lookup lookup = MethodHandles.lookup();
MH_INVOKE_INTERP_BINDINGS = lookup.findVirtual(ProgrammableInvoker.class, "invokeInterpBindings",
MH_INVOKE_INTERP_BINDINGS = lookup.findVirtual(DowncallLinker.class, "invokeInterpBindings",
methodType(Object.class, SegmentAllocator.class, Object[].class, InvocationData.class));
MH_CHECK_SYMBOL = lookup.findStatic(SharedUtils.class, "checkSymbol",
methodType(void.class, Addressable.class));
@ -74,7 +69,7 @@ public class ProgrammableInvoker {
private final ABIDescriptor abi;
private final CallingSequence callingSequence;
public ProgrammableInvoker(ABIDescriptor abi, CallingSequence callingSequence) {
public DowncallLinker(ABIDescriptor abi, CallingSequence callingSequence) {
this.abi = abi;
assert callingSequence.forDowncall();
this.callingSequence = callingSequence;

View File

@ -33,7 +33,7 @@ import java.util.Arrays;
import java.util.List;
/**
* This class describes a 'native invoker', which is used as an appendix argument to linkToNative calls.
* This class describes a 'native entry point', which is used as an appendix argument to linkToNative calls.
*/
public class NativeEntryPoint {
static {
@ -41,17 +41,17 @@ public class NativeEntryPoint {
}
private final MethodType methodType;
private final long invoker; // read by VM
private final long downcallStubAddress; // read by VM
private static final Cleaner CLEANER = CleanerFactory.cleaner();
private static final SoftReferenceCache<CacheKey, NativeEntryPoint> INVOKER_CACHE = new SoftReferenceCache<>();
private static final SoftReferenceCache<CacheKey, NativeEntryPoint> NEP_CACHE = new SoftReferenceCache<>();
private record CacheKey(MethodType methodType, ABIDescriptor abi,
List<VMStorage> argMoves, List<VMStorage> retMoves,
boolean needsReturnBuffer) {}
private NativeEntryPoint(MethodType methodType, long invoker) {
private NativeEntryPoint(MethodType methodType, long downcallStubAddress) {
this.methodType = methodType;
this.invoker = invoker;
this.downcallStubAddress = downcallStubAddress;
}
public static NativeEntryPoint make(ABIDescriptor abi,
@ -65,22 +65,22 @@ public class NativeEntryPoint {
assert (!needsReturnBuffer || methodType.parameterType(1) == long.class) : "return buffer address expected";
CacheKey key = new CacheKey(methodType, abi, Arrays.asList(argMoves), Arrays.asList(returnMoves), needsReturnBuffer);
return INVOKER_CACHE.get(key, k -> {
long invoker = makeInvoker(methodType, abi, argMoves, returnMoves, needsReturnBuffer);
NativeEntryPoint nep = new NativeEntryPoint(methodType, invoker);
CLEANER.register(nep, () -> freeInvoker(invoker));
return NEP_CACHE.get(key, k -> {
long downcallStub = makeDowncallStub(methodType, abi, argMoves, returnMoves, needsReturnBuffer);
NativeEntryPoint nep = new NativeEntryPoint(methodType, downcallStub);
CLEANER.register(nep, () -> freeDowncallStub(downcallStub));
return nep;
});
}
private static native long makeInvoker(MethodType methodType, ABIDescriptor abi,
VMStorage[] encArgMoves, VMStorage[] encRetMoves,
boolean needsReturnBuffer);
private static native long makeDowncallStub(MethodType methodType, ABIDescriptor abi,
VMStorage[] encArgMoves, VMStorage[] encRetMoves,
boolean needsReturnBuffer);
private static native boolean freeInvoker0(long invoker);
private static void freeInvoker(long invoker) {
if (!freeInvoker0(invoker)) {
throw new InternalError("Could not free invoker");
private static native boolean freeDowncallStub0(long downcallStub);
private static void freeDowncallStub(long downcallStub) {
if (!freeDowncallStub0(downcallStub)) {
throw new InternalError("Could not free downcall stub");
}
}

View File

@ -43,18 +43,18 @@ import static java.lang.invoke.MethodHandles.lookup;
import static java.lang.invoke.MethodType.methodType;
import static sun.security.action.GetBooleanAction.privilegedGetProperty;
public class ProgrammableUpcallHandler {
public class UpcallLinker {
private static final boolean DEBUG =
privilegedGetProperty("jdk.internal.foreign.ProgrammableUpcallHandler.DEBUG");
privilegedGetProperty("jdk.internal.foreign.UpcallLinker.DEBUG");
private static final boolean USE_SPEC = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty("jdk.internal.foreign.ProgrammableUpcallHandler.USE_SPEC", "true"));
GetPropertyAction.privilegedGetProperty("jdk.internal.foreign.UpcallLinker.USE_SPEC", "true"));
private static final MethodHandle MH_invokeInterpBindings;
static {
try {
MethodHandles.Lookup lookup = lookup();
MH_invokeInterpBindings = lookup.findStatic(ProgrammableUpcallHandler.class, "invokeInterpBindings",
MH_invokeInterpBindings = lookup.findStatic(UpcallLinker.class, "invokeInterpBindings",
methodType(Object.class, Object[].class, InvocationData.class));
} catch (ReflectiveOperationException e) {
throw new InternalError(e);
@ -91,7 +91,7 @@ public class ProgrammableUpcallHandler {
VMStorage[] args = Arrays.stream(argMoves).map(Binding.Move::storage).toArray(VMStorage[]::new);
VMStorage[] rets = Arrays.stream(retMoves).map(Binding.Move::storage).toArray(VMStorage[]::new);
CallRegs conv = new CallRegs(args, rets);
long entryPoint = allocateOptimizedUpcallStub(doBindings, abi, conv,
long entryPoint = makeUpcallStub(doBindings, abi, conv,
callingSequence.needsReturnBuffer(), callingSequence.returnBufferSize());
return UpcallStubs.makeUpcall(entryPoint, session);
}
@ -198,8 +198,8 @@ public class ProgrammableUpcallHandler {
// used for transporting data into native code
private static record CallRegs(VMStorage[] argRegs, VMStorage[] retRegs) {}
static native long allocateOptimizedUpcallStub(MethodHandle mh, ABIDescriptor abi, CallRegs conv,
boolean needsReturnBuffer, long returnBufferSize);
static native long makeUpcallStub(MethodHandle mh, ABIDescriptor abi, CallRegs conv,
boolean needsReturnBuffer, long returnBufferSize);
private static native void registerNatives();
static {

View File

@ -34,13 +34,13 @@ import jdk.internal.foreign.abi.ABIDescriptor;
import jdk.internal.foreign.abi.Binding;
import jdk.internal.foreign.abi.CallingSequence;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
import jdk.internal.foreign.abi.ProgrammableUpcallHandler;
import jdk.internal.foreign.abi.DowncallLinker;
import jdk.internal.foreign.abi.UpcallLinker;
import jdk.internal.foreign.abi.SharedUtils;
import jdk.internal.foreign.abi.VMStorage;
import jdk.internal.foreign.abi.aarch64.linux.LinuxAArch64CallArranger;
import jdk.internal.foreign.abi.aarch64.macos.MacOsAArch64CallArranger;
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.ProgrammableInvoker;
import java.lang.foreign.MemorySession;
import java.lang.invoke.MethodHandle;
@ -52,8 +52,8 @@ import static jdk.internal.foreign.PlatformLayouts.*;
import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.*;
/**
* For the AArch64 C ABI specifically, this class uses the ProgrammableInvoker API, namely CallingSequenceBuilder2
* to translate a C FunctionDescriptor into a CallingSequence2, which can then be turned into a MethodHandle.
* For the AArch64 C ABI specifically, this class uses CallingSequenceBuilder
* to translate a C FunctionDescriptor into a CallingSequence, which can then be turned into a MethodHandle.
*
* This includes taking care of synthetic arguments like pointers to return buffers for 'in-memory' returns.
*
@ -147,7 +147,7 @@ public abstract class CallArranger {
public MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc) {
Bindings bindings = getBindings(mt, cDesc, false);
MethodHandle handle = new ProgrammableInvoker(C, bindings.callingSequence).getBoundMethodHandle();
MethodHandle handle = new DowncallLinker(C, bindings.callingSequence).getBoundMethodHandle();
if (bindings.isInMemoryReturn) {
handle = SharedUtils.adaptDowncallForIMR(handle, cDesc);
@ -163,7 +163,7 @@ public abstract class CallArranger {
target = SharedUtils.adaptUpcallForIMR(target, true /* drop return, since we don't have bindings for it */);
}
return ProgrammableUpcallHandler.make(C, target, bindings.callingSequence, session);
return UpcallLinker.make(C, target, bindings.callingSequence, session);
}
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {

View File

@ -25,33 +25,33 @@
*/
package jdk.internal.foreign.abi.x64.sysv;
import jdk.internal.foreign.abi.ABIDescriptor;
import jdk.internal.foreign.abi.Binding;
import jdk.internal.foreign.abi.CallingSequence;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
import jdk.internal.foreign.abi.DowncallLinker;
import jdk.internal.foreign.abi.SharedUtils;
import jdk.internal.foreign.abi.UpcallLinker;
import jdk.internal.foreign.abi.VMStorage;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.GroupLayout;
import java.lang.foreign.MemoryAddress;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.MemorySession;
import jdk.internal.foreign.abi.ABIDescriptor;
import jdk.internal.foreign.abi.CallingSequence;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
import jdk.internal.foreign.abi.VMStorage;
import jdk.internal.foreign.abi.Binding;
import jdk.internal.foreign.abi.ProgrammableInvoker;
import jdk.internal.foreign.abi.ProgrammableUpcallHandler;
import jdk.internal.foreign.abi.SharedUtils;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.List;
import java.util.Optional;
import static jdk.internal.foreign.PlatformLayouts.*;
import static jdk.internal.foreign.abi.Binding.*;
import static jdk.internal.foreign.PlatformLayouts.SysV;
import static jdk.internal.foreign.abi.Binding.vmStore;
import static jdk.internal.foreign.abi.x64.X86_64Architecture.*;
/**
* For the SysV x64 C ABI specifically, this class uses the ProgrammableInvoker API, namely CallingSequenceBuilder2
* For the SysV x64 C ABI specifically, this class uses namely CallingSequenceBuilder
* to translate a C FunctionDescriptor into a CallingSequence, which can then be turned into a MethodHandle.
*
* This includes taking care of synthetic arguments like pointers to return buffers for 'in-memory' returns.
@ -121,7 +121,7 @@ public class CallArranger {
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc) {
Bindings bindings = getBindings(mt, cDesc, false);
MethodHandle handle = new ProgrammableInvoker(CSysV, bindings.callingSequence).getBoundMethodHandle();
MethodHandle handle = new DowncallLinker(CSysV, bindings.callingSequence).getBoundMethodHandle();
handle = MethodHandles.insertArguments(handle, handle.type().parameterCount() - 1, bindings.nVectorArgs);
if (bindings.isInMemoryReturn) {
@ -138,7 +138,7 @@ public class CallArranger {
target = SharedUtils.adaptUpcallForIMR(target, true /* drop return, since we don't have bindings for it */);
}
return ProgrammableUpcallHandler.make(CSysV, target, bindings.callingSequence, session);
return UpcallLinker.make(CSysV, target, bindings.callingSequence, session);
}
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {

View File

@ -24,34 +24,34 @@
*/
package jdk.internal.foreign.abi.x64.windows;
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.ABIDescriptor;
import jdk.internal.foreign.abi.Binding;
import jdk.internal.foreign.abi.CallingSequence;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
import jdk.internal.foreign.abi.DowncallLinker;
import jdk.internal.foreign.abi.SharedUtils;
import jdk.internal.foreign.abi.UpcallLinker;
import jdk.internal.foreign.abi.VMStorage;
import jdk.internal.foreign.abi.x64.X86_64Architecture;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.GroupLayout;
import java.lang.foreign.MemoryAddress;
import java.lang.foreign.MemoryLayout;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.MemorySession;
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
import jdk.internal.foreign.abi.ABIDescriptor;
import jdk.internal.foreign.abi.Binding;
import jdk.internal.foreign.abi.CallingSequence;
import jdk.internal.foreign.abi.ProgrammableInvoker;
import jdk.internal.foreign.abi.ProgrammableUpcallHandler;
import jdk.internal.foreign.abi.VMStorage;
import jdk.internal.foreign.abi.x64.X86_64Architecture;
import jdk.internal.foreign.abi.SharedUtils;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.util.List;
import java.util.Optional;
import static jdk.internal.foreign.PlatformLayouts.*;
import static jdk.internal.foreign.PlatformLayouts.Win64;
import static jdk.internal.foreign.abi.x64.X86_64Architecture.*;
/**
* For the Windowx x64 C ABI specifically, this class uses the ProgrammableInvoker API, namely CallingSequenceBuilder2
* to translate a C FunctionDescriptor into a CallingSequence2, which can then be turned into a MethodHandle.
* For the Windowx x64 C ABI specifically, this class uses CallingSequenceBuilder
* to translate a C FunctionDescriptor into a CallingSequence, which can then be turned into a MethodHandle.
*
* This includes taking care of synthetic arguments like pointers to return buffers for 'in-memory' returns.
*/
@ -124,7 +124,7 @@ public class CallArranger {
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc) {
Bindings bindings = getBindings(mt, cDesc, false);
MethodHandle handle = new ProgrammableInvoker(CWindows, bindings.callingSequence).getBoundMethodHandle();
MethodHandle handle = new DowncallLinker(CWindows, bindings.callingSequence).getBoundMethodHandle();
if (bindings.isInMemoryReturn) {
handle = SharedUtils.adaptDowncallForIMR(handle, cDesc);
@ -140,7 +140,7 @@ public class CallArranger {
target = SharedUtils.adaptUpcallForIMR(target, false /* need the return value as well */);
}
return ProgrammableUpcallHandler.make(CWindows, target, bindings.callingSequence, session);
return UpcallLinker.make(CWindows, target, bindings.callingSequence, session);
}
private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {