RFR: 8294729: [s390] Implement nmethod entry barriers
Lutz Schmidt
lucy at openjdk.org
Wed Oct 26 20:00:38 UTC 2022
On Fri, 7 Oct 2022 12:19:08 GMT, Lutz Schmidt <lucy at openjdk.org> wrote:
>> src/hotspot/cpu/s390/gc/shared/barrierSetAssembler_s390.cpp line 95:
>>
>>> 93:
>>> 94: // Conditional Jump
>>> 95: __ z_bcr(Assembler::bcondNotEqual, Z_R1_scratch); // 2 bytes
>>
>> This is only a jump. We would need a call which sets Z_R14 = return address. It should be possible to set Z_R14 manually to the return address before the jump (z_lghrl). Alternatively, you could implement a stub like on x86_64.
>
> I you really want to use a nerdy hack, I would suggest you use
> `z_larl(Z_R14, (instr_len((unsigned long)LARL_ZOPC) + instr_len((unsigned long)BCR_ZOPC)) / 2);`
> `z_bcr(Assembler::bcondNotEqual, Z_R1_scratch);
> `
Edit: adapted to the fact that entry_barrier is an 8-byte field with only the rightmost 4 bytes being significant.
If this isn't nerdy enough, I have another idea (**works only on z14 and newer**). It replaces the load_const at the beginning with a z_larl() and then uses a z_bic() to fetch the target address and branch there. The z_larl will never go out of range because all generated code is in the code cache which is limited to 4GB in size. In total we would get:
__ z_larl(Z_R1_scratch, &StubRoutines::zarch::nmethod_entry_barrier());
__ z_clghsi(in_bytes(bs_nm->thread_disarmed_offset()), Z_thread, /* to be patched */ -1);
__ z_larl(Z_R14, (instr_len((unsigned long)LARL_ZOPC) + instr_len((unsigned long)BIC_ZOPC)) / 2);
__ z_bic(Assembler::bcondNotEqual, 0, Z_R0, Z_R1_scratch);
Nice, short, compact.
-------------
PR: https://git.openjdk.org/jdk/pull/10558
More information about the hotspot-dev
mailing list