RFR: 8294729: [s390] Implement nmethod entry barriers

Tyler Steele tsteele at openjdk.org
Wed Oct 26 20:00:38 UTC 2022


On Fri, 7 Oct 2022 12:36:29 GMT, Lutz Schmidt <lucy at openjdk.org> wrote:

>> 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.

Well spotted. I hadn't appreciated that this instruction wasn't setting the return address.

I am leaning towards the first ~nerdy~ cool hack if it's more general, though I do appreciate the compactness of the second suggestion.

-------------

PR: https://git.openjdk.org/jdk/pull/10558


More information about the hotspot-dev mailing list