Skip to content

Commit

Permalink
Fixed size
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Dec 4, 2023
1 parent 2c52f13 commit b310c8c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
30 changes: 15 additions & 15 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3329,41 +3329,41 @@ address MacroAssembler::ic_call(address entry, jint method_index) {
}

int MacroAssembler::ic_check_size() {
return NativeInstruction::instruction_size * 9;
// No compressed
return (NativeInstruction::instruction_size * (2 /* 2 loads */ + 1 /* branch */))
+ far_branch_size();
}

int MacroAssembler::ic_check(int end_alignment) {
IncompressibleRegion ir(this);
Register receiver = j_rarg0;
Register data = t1;
Register tmp1 = t0;
Register tmp2 = t2;

int start_offset = offset();
Register tmp1 = t0; // t0 always scratch
// t2 is saved on call, thus should have been saved before this check.
// Hence we can clobber it.
Register tmp2 = t2;

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

int uep_offset = offset();

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

Label dont;
beq(tmp1, tmp2, dont);
Label ic_hit;
beq(tmp1, tmp2, ic_hit);
// Note, far_jump is not fixed size.
// Is this ever generates a movptr alignment/size will be off.
far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
bind(dont);

int beoffs = offset();
align(end_alignment, 0);
bind(ic_hit);

int offs = offset();
assert((offs % end_alignment) == 0, "Misaligned verified entry point: %d %d %d %d %d %d",
start_offset, uep_offset, beoffs, offs, ic_check_size(), end_alignment);
assert((offs % end_alignment) == 0, "Misaligned verified entry point");
return uep_offset;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ class MacroAssembler: public Assembler {

static int far_branch_size() {
if (far_branches()) {
return 2 * 4; // auipc + jalr, see far_call() & far_jump()
return 2 * NativeInstruction::instruction_size; // auipc + jalr, see far_call() & far_jump()
} else {
return 4;
}
Expand Down
21 changes: 11 additions & 10 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1807,14 +1807,13 @@ void MachUEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const
assert_cond(st != NULL);
st->print_cr("# MachUEPNode");
if (UseCompressedClassPointers) {
st->print_cr("\tlwu t0, [j_rarg0, oopDesc::klass_offset_in_bytes()]\t# compressed klass");
if (CompressedKlassPointers::shift() != 0) {
st->print_cr("\tdecode_klass_not_null t0, t0");
}
st->print_cr("\tlwu t0, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass");
st->print_cr("\tlwu t2, [t1 + CompiledICData::speculated_klass_offset()]\t# compressed klass");
} else {
st->print_cr("\tld t0, [j_rarg0, oopDesc::klass_offset_in_bytes()]\t# compressed klass");
st->print_cr("\tld t0, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass");
st->print_cr("\tld t2, [t1 + CompiledICData::speculated_klass_offset()]\t# compressed klass");
}
st->print_cr("\tbeq t0, t1, ic_hit");
st->print_cr("\tbeq t0, t2, ic_hit");
st->print_cr("\tj, SharedRuntime::_ic_miss_stub\t # Inline cache check");
st->print_cr("\tic_hit:");
}
Expand All @@ -1825,10 +1824,12 @@ void MachUEPNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const
// This is the unverified entry point.
C2_MacroAssembler _masm(&cbuf);
__ 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);

// Verified entry point must be properly 4 bytes aligned for
// patching by NativeJump::patch_verified_entry()
// ic_check() aligns to CodeEntryAlignment,
// which is >= InteriorEntryAlignment(min 16) > NativeInstruction::instruction_size(4).
assert(((__ offset()) % CodeEntryAlignment) == 0, "Misaligned verified entry point(NativeInstruction::instruction_size)");
}

uint MachUEPNode::size(PhaseRegAlloc* ra_) const
Expand Down

0 comments on commit b310c8c

Please sign in to comment.