Skip to content

Commit cc192ba

Browse files
Junliang Yanv8-scoped@luci-project-accounts.iam.gserviceaccount.com
authored andcommitted
ppc64: Replace r0 with UseScratchRegisterScope in Generate_JSEntryVariant
Use a scratch register acquired from UseScratchRegisterScope instead of the special r0 register for the entry-frame setup in Generate_JSEntryVariant. This is consistent with the register-allocator model used elsewhere in the PPC assembler and avoids relying on r0's special encoding behavior. The scratch pool (DefaultTmpList) contains callee-saved registers (r25, r26), so acquiring from it is only safe once kCalleeSaved has been spilled. The converted code sits between MultiPush(kCalleeSaved) and MultiPop(kCalleeSaved), where that invariant holds. The LR save/restore (mflr/mtlr) around those push/pop points is left using r0 on purpose: it runs while the caller's callee-saved values are still live in those pool registers, and r0 is the idiomatic volatile scratch for LR shuffling in the PPC prologue/epilogue. No functional change. IT: 8 Change-Id: Id80a975fd42ed0868f7ab4531d306f30f4a7e077 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8485449 Reviewed-by: Milad Farazmand <mfarazma@ibm.com> Auto-Submit: John <junyan1@ibm.com> Commit-Queue: John <junyan1@ibm.com> Cr-Commit-Position: refs/heads/main@{#110256}
1 parent 1ad6606 commit cc192ba

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

‎src/builtins/ppc/builtins-ppc.cc‎

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -868,28 +868,33 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
868868
// If the c_entry_fp is not already zero and we don't clear it, the
869869
// StackFrameIteratorForProfiler will assume we are executing C++ and miss the
870870
// JS frames on top.
871-
__ li(r0, Operand(-1)); // Push a bad frame pointer to fail if it is used.
872-
__ push(r0);
873-
if (V8_EMBEDDED_CONSTANT_POOL_BOOL) {
874-
__ li(kConstantPoolRegister, Operand::Zero());
875-
__ push(kConstantPoolRegister);
876-
}
877-
__ mov(r0, Operand(StackFrame::TypeToMarker(type)));
878-
__ push(r0);
879-
__ push(r0);
871+
{
872+
UseScratchRegisterScope temps(masm);
873+
Register scratch = temps.Acquire();
874+
// Push a bad frame pointer to fail if it is used.
875+
__ li(scratch, Operand(-1));
876+
__ push(scratch);
877+
if (V8_EMBEDDED_CONSTANT_POOL_BOOL) {
878+
__ li(kConstantPoolRegister, Operand::Zero());
879+
__ push(kConstantPoolRegister);
880+
}
881+
__ mov(scratch, Operand(StackFrame::TypeToMarker(type)));
882+
__ push(scratch);
883+
__ push(scratch);
880884

881-
__ mov(r0, Operand::Zero());
882-
__ LoadU64(r3, __ AsMemOperand(IsolateFieldId::kCEntryFP));
883-
__ StoreU64(r0, __ AsMemOperand(IsolateFieldId::kCEntryFP));
884-
__ push(r3);
885+
__ mov(scratch, Operand::Zero());
886+
__ LoadU64(r3, __ AsMemOperand(IsolateFieldId::kCEntryFP));
887+
__ StoreU64(scratch, __ AsMemOperand(IsolateFieldId::kCEntryFP));
888+
__ push(r3);
885889

886-
__ LoadU64(r3, __ AsMemOperand(IsolateFieldId::kFastCCallCallerFP));
887-
__ StoreU64(r0, __ AsMemOperand(IsolateFieldId::kFastCCallCallerFP));
888-
__ push(r3);
890+
__ LoadU64(r3, __ AsMemOperand(IsolateFieldId::kFastCCallCallerFP));
891+
__ StoreU64(scratch, __ AsMemOperand(IsolateFieldId::kFastCCallCallerFP));
892+
__ push(r3);
889893

890-
__ LoadU64(r3, __ AsMemOperand(IsolateFieldId::kFastCCallCallerPC));
891-
__ StoreU64(r0, __ AsMemOperand(IsolateFieldId::kFastCCallCallerPC));
892-
__ push(r3);
894+
__ LoadU64(r3, __ AsMemOperand(IsolateFieldId::kFastCCallCallerPC));
895+
__ StoreU64(scratch, __ AsMemOperand(IsolateFieldId::kFastCCallCallerPC));
896+
__ push(r3);
897+
}
893898

894899
Register scratch = r9;
895900
// Set up frame pointer for the frame to be pushed.

0 commit comments

Comments
 (0)