-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8360775: Fix Shenandoah GC test failures when APX is enabled #26009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,7 +353,7 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm, | |
|
||
// The rest is saved with the optimized path | ||
|
||
uint num_saved_regs = 4 + (dst != rax ? 1 : 0) + 4; | ||
uint num_saved_regs = 4 + (dst != rax ? 1 : 0) + 4 + (UseAPX ? 16 : 0); | ||
__ subptr(rsp, num_saved_regs * wordSize); | ||
uint slot = num_saved_regs; | ||
if (dst != rax) { | ||
|
@@ -367,6 +367,25 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm, | |
__ movptr(Address(rsp, (--slot) * wordSize), r9); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r10); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r11); | ||
// Save APX extended registers r16–r31 if enabled | ||
if (UseAPX) { | ||
__ movptr(Address(rsp, (--slot) * wordSize), r16); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r17); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r18); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r19); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r20); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r21); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r22); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r23); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r24); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r25); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r26); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r27); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r28); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r29); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r30); | ||
__ movptr(Address(rsp, (--slot) * wordSize), r31); | ||
Comment on lines
+372
to
+387
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you should use pushp2 / pop2p for these instructions also , maybe it can be handled along with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks Jatin (@jatin-bhateja) for the review and approval! This modification will be pursued in another PR (say #25889). |
||
} | ||
// r12-r15 are callee saved in all calling conventions | ||
assert(slot == 0, "must use all slots"); | ||
|
||
|
@@ -398,6 +417,25 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm, | |
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom), arg0, arg1); | ||
} | ||
|
||
// Restore APX extended registers r31–r16 if previously saved | ||
if (UseAPX) { | ||
__ movptr(r31, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r30, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r29, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r28, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r27, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r26, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r25, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r24, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r23, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r22, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r21, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r20, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r19, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r18, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r17, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r16, Address(rsp, (slot++) * wordSize)); | ||
} | ||
__ movptr(r11, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r10, Address(rsp, (slot++) * wordSize)); | ||
__ movptr(r9, Address(rsp, (slot++) * wordSize)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @vamsi-parasa ,
PUSHA / POPA assembler is agnostic to the use of hardcoded registers in calling context, e.g. in following line of code
https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp#L495
If dst and tmp1 are RAX then we endup currpting it since RAX is used as a scratch register for stack alignment, and in case RAX holds an oop pointer then we may see random crashes. Such idioms are limited to GC barreirs currently, and we have recently fixed one such issue in #25351
While the instruction sequence of PUSHA/ POPA with PPX hints is correct, Do you think for the time being we should limit the scope of this fix to save_machine_state and restor_machine_state routines rather than making generic fix in pusha/popa ?
I have tried it and it's working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jatin-bhateja Pusha is not expected to change any registers. The inadvertent change of registers is very hard to debug. So in my thoughts it is better to have a conservative implementation currently which doesn't change RAX register.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the updated code which fixes the issue by restoring the contents of RAX. The tests are passing with this update.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vamsi-parasa , yes this looks fine to me now, I had a similar thought to fix it.
https://github.com/openjdk/jdk/pull/25351/files#diff-d5d721ebf93346ba66e81257e4f6c5e6268d59774313c61e97353c0dfbf686a5R93