Skip to content

Commit

Permalink
Just started
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Dec 1, 2023
1 parent 0f6467a commit 2081ca4
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 25 deletions.
43 changes: 42 additions & 1 deletion src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "precompiled.hpp"
#include "asm/assembler.hpp"
#include "asm/assembler.inline.hpp"
#include "code/compiledIC.hpp"
#include "compiler/disassembler.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/barrierSetAssembler.hpp"
Expand Down Expand Up @@ -3310,14 +3311,54 @@ address MacroAssembler::trampoline_call(Address entry) {
return call_pc;
}

uintptr_t MacroAssembler::create_ic_data() {
#ifdef COMPILER2
if (code_section()->scratch_emit()) {
return (uintptr_t)Universe::non_oop_word();
}
#endif
return (uintptr_t)new CompiledICData();
}

address MacroAssembler::ic_call(address entry, jint method_index) {
RelocationHolder rh = virtual_call_Relocation::spec(pc(), method_index);
IncompressibleRegion ir(this); // relocations
movptr(t1, (address)Universe::non_oop_word());
movptr(t1, create_ic_data());
assert_cond(entry != nullptr);
return trampoline_call(Address(entry, rh));
}

int MacroAssembler::ic_check_size() {
return NativeInstruction::instruction_size * 9;
}

int MacroAssembler::ic_check(int end_alignment) {
IncompressibleRegion ir(this); // relocations
Register receiver = j_rarg0;
Register data = t1;
Register tmp = t0;

align(end_alignment, offset() + ic_check_size());

int uep_offset = offset();

if (UseCompressedClassPointers) {
lw(tmp, Address(receiver, oopDesc::klass_offset_in_bytes()));
lw(data, Address(data, CompiledICData::speculated_klass_offset()));
} else {
ld(tmp, Address(receiver, oopDesc::klass_offset_in_bytes()));
ld(data, Address(data, CompiledICData::speculated_klass_offset()));
}

Label dont;
beq(data, tmp, dont);
far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
bind(dont);
assert((offset() % end_alignment) == 0, "Misaligned verified entry point");

return uep_offset;
}

// Emit a trampoline stub for a call to a target which is too far away.
//
// code sequences:
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,11 @@ class MacroAssembler: public Assembler {
//
// Return: the call PC or null if CodeCache is full.
address trampoline_call(Address entry);

uintptr_t create_ic_data();
address ic_call(address entry, jint method_index = 0);
static int ic_check_size();
int ic_check(int end_alignment);

// Support for memory inc/dec
// n.b. increment/decrement calls with an Address destination will
Expand Down
8 changes: 2 additions & 6 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1824,12 +1824,8 @@ void MachUEPNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const
{
// This is the unverified entry point.
C2_MacroAssembler _masm(&cbuf);

Label skip;
__ cmp_klass(j_rarg0, t1, t0, t2 /* call-clobbered t2 as a tmp */, skip);
__ far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
__ bind(skip);

__ ic_check(CodeEntryAlignment);

// These NOPs are critical so that verified entry point is properly
// 4 bytes aligned for patching by NativeJump::patch_verified_entry()
__ align(NativeInstruction::instruction_size);
Expand Down
22 changes: 6 additions & 16 deletions src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,9 @@ AdapterHandlerEntry* SharedRuntime::generate_i2c2i_adapters(MacroAssembler *masm

{
__ block_comment("c2i_unverified_entry {");
__ load_klass(t0, receiver, tmp);
__ ld(tmp, Address(holder, CompiledICHolder::holder_klass_offset()));
__ ld(xmethod, Address(holder, CompiledICHolder::holder_metadata_offset()));
__ beq(t0, tmp, ok);
__ far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));

__ ic_check(1 /* end_alignment */);
__ ld(xmethod, Address(holder, CompiledICData::speculated_method_offset()));

__ bind(ok);
// Method might have been compiled since the call site was patched to
Expand Down Expand Up @@ -1423,19 +1421,10 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
const Register ic_reg = t1;
const Register receiver = j_rarg0;

Label hit;
Label exception_pending;

__ verify_oop(receiver);
assert_different_registers(ic_reg, receiver, t0, t2);
__ cmp_klass(receiver, ic_reg, t0, t2 /* call-clobbered t2 as a tmp */, hit);
assert_different_registers(receiver, t0, t1);

__ far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));

// Verified entry point must be aligned
__ align(8);

__ bind(hit);
__ ic_check(8 /* end_alignment */);

int vep_offset = ((intptr_t)__ pc()) - start;

Expand Down Expand Up @@ -1870,6 +1859,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
__ leave();

// Any exception pending?
Label exception_pending;
__ ld(t0, Address(xthread, in_bytes(Thread::pending_exception_offset())));
__ bnez(t0, exception_pending);

Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/cpu/riscv/vtableStubs_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "precompiled.hpp"
#include "asm/assembler.inline.hpp"
#include "asm/macroAssembler.inline.hpp"
#include "code/compiledIC.hpp"
#include "code/vtableStubs.hpp"
#include "interp_masm_riscv.hpp"
#include "memory/resourceArea.hpp"
Expand Down Expand Up @@ -184,8 +185,8 @@ VtableStub* VtableStubs::create_itable_stub(int itable_index) {

Label L_no_such_interface;

__ ld(resolved_klass_reg, Address(icholder_reg, CompiledICHolder::holder_klass_offset()));
__ ld(holder_klass_reg, Address(icholder_reg, CompiledICHolder::holder_metadata_offset()));
__ ld(resolved_klass_reg, Address(icholder_reg, CompiledICData::itable_refc_klass_offset()));
__ ld(holder_klass_reg, Address(icholder_reg, CompiledICData::itable_defc_klass_offset()));

start_pc = __ pc();

Expand Down

0 comments on commit 2081ca4

Please sign in to comment.