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

Ningsheng Jian njian at openjdk.org
Wed May 10 06:42:27 UTC 2023


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

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

Commit messages:
 - 8307572: AArch64: Vector registers are clobbered by some macroassemblers

Changes: https://git.openjdk.org/jdk/pull/13895/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13895&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8307572
  Stats: 391 lines in 6 files changed: 334 ins; 0 del; 57 mod
  Patch: https://git.openjdk.org/jdk/pull/13895.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13895/head:pull/13895

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


More information about the hotspot-dev mailing list