Skip to content

Commit 9168f18

Browse files
committed
Fix Shenandoah. Avoid redundant patching. Remove unused code.
1 parent 0780d15 commit 9168f18

24 files changed

+17
-243
lines changed

src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ void NativeMovRegMem::verify() {
212212

213213
void NativeJump::verify() { ; }
214214

215-
216-
void NativeJump::check_verified_entry_alignment(address entry, address verified_entry) {
217-
}
218-
219-
220215
address NativeJump::jump_destination() const {
221216
address dest = MacroAssembler::target_addr_for_insn_or_null(instruction_address());
222217

@@ -359,31 +354,6 @@ bool NativeInstruction::is_stop() {
359354

360355
//-------------------------------------------------------------------
361356

362-
// MT-safe inserting of a jump over a jump or a nop (used by
363-
// nmethod::make_not_entrant)
364-
365-
void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) {
366-
367-
assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "expected fixed destination of patch");
368-
assert(nativeInstruction_at(verified_entry)->is_jump_or_nop()
369-
|| nativeInstruction_at(verified_entry)->is_sigill_not_entrant(),
370-
"Aarch64 cannot replace non-jump with jump");
371-
372-
// Patch this nmethod atomically.
373-
if (Assembler::reachable_from_branch_at(verified_entry, dest)) {
374-
ptrdiff_t disp = dest - verified_entry;
375-
guarantee(disp < 1 << 27 && disp > - (1 << 27), "branch overflow");
376-
377-
unsigned int insn = (0b000101 << 26) | ((disp >> 2) & 0x3ffffff);
378-
*(unsigned int*)verified_entry = insn;
379-
} else {
380-
// We use an illegal instruction for marking a method as not_entrant.
381-
NativeIllegalInstruction::insert(verified_entry);
382-
}
383-
384-
ICache::invalidate_range(verified_entry, instruction_size);
385-
}
386-
387357
void NativeGeneralJump::verify() { }
388358

389359
void NativeGeneralJump::insert_unconditional(address code_pos, address entry) {

src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ class NativeJump: public NativeInstruction {
360360

361361
// Insertion of native jump instruction
362362
static void insert(address code_pos, address entry);
363-
// MT-safe insertion of native jump at verified method entry
364-
static void check_verified_entry_alignment(address entry, address verified_entry);
365-
static void patch_verified_entry(address entry, address verified_entry, address dest);
366363
};
367364

368365
inline NativeJump* nativeJump_at(address address) {

src/hotspot/cpu/arm/nativeInst_arm_32.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -282,16 +282,6 @@ void NativeMovConstReg::set_pc_relative_offset(address addr, address pc) {
282282
}
283283
}
284284

285-
void RawNativeJump::check_verified_entry_alignment(address entry, address verified_entry) {
286-
}
287-
288-
void RawNativeJump::patch_verified_entry(address entry, address verified_entry, address dest) {
289-
assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "should be");
290-
int *a = (int *)verified_entry;
291-
a[0] = not_entrant_illegal_instruction; // always illegal
292-
ICache::invalidate_range((address)&a[0], sizeof a[0]);
293-
}
294-
295285
void NativeGeneralJump::insert_unconditional(address code_pos, address entry) {
296286
int offset = (int)(entry - code_pos - 8);
297287
assert(offset < 0x2000000 && offset > -0x2000000, "encoding constraint");

src/hotspot/cpu/arm/nativeInst_arm_32.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ class RawNativeInstruction {
6161
instr_fld_fst = 0xd0
6262
};
6363

64-
// illegal instruction used by NativeJump::patch_verified_entry
65-
// permanently undefined (UDF): 0xe << 28 | 0b1111111 << 20 | 0b1111 << 4
66-
static const int not_entrant_illegal_instruction = 0xe7f000f0;
67-
6864
static int decode_rotated_imm12(int encoding) {
6965
int base = encoding & 0xff;
7066
int right_rotation = (encoding & 0xf00) >> 7;
@@ -273,11 +269,6 @@ class RawNativeJump: public NativeInstruction {
273269
OrderAccess::storeload(); // overkill if caller holds lock?
274270
}
275271
}
276-
277-
static void check_verified_entry_alignment(address entry, address verified_entry);
278-
279-
static void patch_verified_entry(address entry, address verified_entry, address dest);
280-
281272
};
282273

283274
inline RawNativeJump* rawNativeJump_at(address address) {

src/hotspot/cpu/ppc/c1_MacroAssembler_ppc.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ void C1_MacroAssembler::explicit_null_check(Register base) {
4646

4747

4848
void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
49-
// Avoid stack bang as first instruction. It may get overwritten by patch_verified_entry.
5049
const Register return_pc = R20;
5150
mflr(return_pc);
5251

src/hotspot/cpu/ppc/nativeInst_ppc.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,28 +329,7 @@ void NativeMovConstReg::verify() {
329329
}
330330
}
331331
}
332-
#endif // ASSERT
333-
334-
void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) {
335-
ResourceMark rm;
336-
int code_size = 1 * BytesPerInstWord;
337-
CodeBuffer cb(verified_entry, code_size + 1);
338-
MacroAssembler* a = new MacroAssembler(&cb);
339-
#ifdef COMPILER2
340-
assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "expected fixed destination of patch");
341-
#endif
342-
// Patch this nmethod atomically. Always use illtrap/trap in debug build.
343-
if (DEBUG_ONLY(false &&) a->is_within_range_of_b(dest, a->pc())) {
344-
a->b(dest);
345-
} else {
346-
// The signal handler will continue at dest=OptoRuntime::handle_wrong_method_stub().
347-
// We use an illtrap for marking a method as not_entrant.
348-
a->illtrap();
349-
}
350-
ICache::ppc64_flush_icache_bytes(verified_entry, code_size);
351-
}
352332

353-
#ifdef ASSERT
354333
void NativeJump::verify() {
355334
address addr = addr_at(0);
356335

src/hotspot/cpu/ppc/nativeInst_ppc.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,7 @@ class NativeJump: public NativeInstruction {
328328
}
329329
}
330330

331-
// MT-safe insertion of native jump at verified method entry
332-
static void patch_verified_entry(address entry, address verified_entry, address dest);
333-
334331
void verify() NOT_DEBUG_RETURN;
335-
336-
static void check_verified_entry_alignment(address entry, address verified_entry) {
337-
// We just patch one instruction on ppc64, so the jump doesn't have to
338-
// be aligned. Nothing to do here.
339-
}
340332
};
341333

342334
// Instantiates a NativeJump object starting at the given instruction

src/hotspot/cpu/riscv/nativeInst_riscv.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,6 @@ void NativeMovRegMem::verify() {
356356

357357
void NativeJump::verify() { }
358358

359-
360-
void NativeJump::check_verified_entry_alignment(address entry, address verified_entry) {
361-
// Patching to not_entrant can happen while activations of the method are
362-
// in use. The patching in that instance must happen only when certain
363-
// alignment restrictions are true. These guarantees check those
364-
// conditions.
365-
366-
// Must be 4 bytes aligned
367-
MacroAssembler::assert_alignment(verified_entry);
368-
}
369-
370-
371359
address NativeJump::jump_destination() const {
372360
address dest = MacroAssembler::target_addr_for_insn(instruction_address());
373361

@@ -437,45 +425,6 @@ bool NativeInstruction::is_stop() {
437425

438426
//-------------------------------------------------------------------
439427

440-
// MT-safe inserting of a jump over a jump or a nop (used by
441-
// nmethod::make_not_entrant)
442-
443-
void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) {
444-
445-
assert(dest == SharedRuntime::get_handle_wrong_method_stub(), "expected fixed destination of patch");
446-
447-
assert(nativeInstruction_at(verified_entry)->is_jump_or_nop() ||
448-
nativeInstruction_at(verified_entry)->is_sigill_not_entrant(),
449-
"riscv cannot replace non-jump with jump");
450-
451-
check_verified_entry_alignment(entry, verified_entry);
452-
453-
// Patch this nmethod atomically.
454-
if (Assembler::reachable_from_branch_at(verified_entry, dest)) {
455-
ptrdiff_t offset = dest - verified_entry;
456-
guarantee(Assembler::is_simm21(offset) && ((offset % 2) == 0),
457-
"offset is too large to be patched in one jal instruction."); // 1M
458-
459-
uint32_t insn = 0;
460-
address pInsn = (address)&insn;
461-
Assembler::patch(pInsn, 31, 31, (offset >> 20) & 0x1);
462-
Assembler::patch(pInsn, 30, 21, (offset >> 1) & 0x3ff);
463-
Assembler::patch(pInsn, 20, 20, (offset >> 11) & 0x1);
464-
Assembler::patch(pInsn, 19, 12, (offset >> 12) & 0xff);
465-
Assembler::patch(pInsn, 11, 7, 0); // zero, no link jump
466-
Assembler::patch(pInsn, 6, 0, 0b1101111); // j, (jal x0 offset)
467-
Assembler::sd_instr(verified_entry, insn);
468-
} else {
469-
// We use an illegal instruction for marking a method as
470-
// not_entrant.
471-
NativeIllegalInstruction::insert(verified_entry);
472-
}
473-
474-
ICache::invalidate_range(verified_entry, instruction_size);
475-
}
476-
477-
//-------------------------------------------------------------------
478-
479428
void NativeGeneralJump::insert_unconditional(address code_pos, address entry) {
480429
CodeBuffer cb(code_pos, instruction_size);
481430
MacroAssembler a(&cb);

src/hotspot/cpu/riscv/nativeInst_riscv.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,6 @@ class NativeJump: public NativeInstruction {
274274

275275
// Insertion of native jump instruction
276276
static void insert(address code_pos, address entry);
277-
// MT-safe insertion of native jump at verified method entry
278-
static void check_verified_entry_alignment(address entry, address verified_entry);
279-
static void patch_verified_entry(address entry, address verified_entry, address dest);
280277
};
281278

282279
inline NativeJump* nativeJump_at(address addr) {

src/hotspot/cpu/riscv/riscv.ad

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,6 @@ void MachUEPNode::emit(C2_MacroAssembler* masm, PhaseRegAlloc* ra_) const
17961796
// This is the unverified entry point.
17971797
__ ic_check(CodeEntryAlignment);
17981798

1799-
// Verified entry point must be properly 4 bytes aligned for patching by NativeJump::patch_verified_entry().
18001799
// ic_check() aligns to CodeEntryAlignment >= InteriorEntryAlignment(min 16) > NativeInstruction::instruction_size(4).
18011800
assert(((__ offset()) % CodeEntryAlignment) == 0, "Misaligned verified entry point");
18021801
}
@@ -8191,7 +8190,7 @@ instruct unnecessary_membar_volatile_rvtso() %{
81918190
ins_cost(0);
81928191

81938192
size(0);
8194-
8193+
81958194
format %{ "#@unnecessary_membar_volatile_rvtso (unnecessary so empty encoding)" %}
81968195
ins_encode %{
81978196
__ block_comment("unnecessary_membar_volatile_rvtso");

0 commit comments

Comments
 (0)