RFR: 8307572: AArch64: Vector registers are clobbered by some macroassemblers

Ningsheng Jian njian at openjdk.org
Fri May 12 01:58:51 UTC 2023


On Thu, 11 May 2023 08:42:40 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> I found that MacroAssembler::arrays_equals() would call stubcode, which may use vector registers. However, the call site in match rule does not claim the use of vector registers. Since c2 will allocate v16-v31 first [1], it's rare that using of v0-v7 will cause problem, but I did create a test case to expose the bug.
>> 
>> Apart from arrays_equals, I also checked other macroassemblers, and found several similar issues. Fixed by claiming those vector register being killed in match rules call sites, which should have minimal performance impact compared to always saving/restoring those vector registers, since those V0-Vx registers are rarely allocated and live cross the macroassembler call.
>> 
>> A jtreg test case is also added to demonstrate the failure. Test will fail without this patch, and pass with this patch.
>> 
>> Test: I tried to update the allocation order in [1] to allocate V0-V15 first and then V16-V31, and full jtreg tests passed with the allocation order changed. (I did found some test failures with this allocation order change without this patch). I have also eyeballed and checked other macroassembler calls, and others seemed fine.
>> 
>> [1] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/aarch64/aarch64.ad#L424
>
> Great catch, thanks. Does this one need backports?

Thanks for the review! @theRealAph @adinn

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

PR Comment: https://git.openjdk.org/jdk/pull/13895#issuecomment-1544992753


More information about the hotspot-dev mailing list