Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JornVernee committed May 23, 2022
2 parents 9abf0a8 + 81f128b commit 04f84d6
Show file tree
Hide file tree
Showing 107 changed files with 803 additions and 615 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -88,16 +88,16 @@ class NativeInvokerGenerator : public StubCodeGenerator {

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");

Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 11 additions & 11 deletions src/hotspot/cpu/aarch64/frame_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/methodHandles_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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");

Expand All @@ -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();

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/frame_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/hotspot/cpu/ppc/frame_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading

0 comments on commit 04f84d6

Please sign in to comment.