[riscv64] Save kCallerSaveFpu Register in LeaveExitFrame and EnterExitFrame.

Change-Id: I0ecd8450fce35925dc00f5db65a1132deb813b59
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3483696
Reviewed-by: ji qiu <qiuji@iscas.ac.cn>
Commit-Queue: ji qiu <qiuji@iscas.ac.cn>
Cr-Commit-Position: refs/heads/main@{#79299}
This commit is contained in:
Lu Yahan 2022-02-24 17:28:34 +08:00 committed by V8 LUCI CQ
parent 0e8e8a565e
commit 4d2b9e8e66
3 changed files with 21 additions and 13 deletions

View File

@ -4444,12 +4444,15 @@ void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space,
const int frame_alignment = MacroAssembler::ActivationFrameAlignment();
if (save_doubles) {
// The stack is already aligned to 0 modulo 8 for stores with sdc1.
int kNumOfSavedRegisters = FPURegister::kNumRegisters;
int space = kNumOfSavedRegisters * kDoubleSize;
int space = kNumCallerSavedFPU * kDoubleSize;
Sub64(sp, sp, Operand(space));
for (int i = 0; i < kNumOfSavedRegisters; i++) {
FPURegister reg = FPURegister::from_code(i);
StoreDouble(reg, MemOperand(sp, i * kDoubleSize));
int count = 0;
for (int i = 0; i < kNumFPURegisters; i++) {
if (kCallerSavedFPU & (1 << i)) {
FPURegister reg = FPURegister::from_code(i);
StoreDouble(reg, MemOperand(sp, count * kDoubleSize));
count++;
}
}
}
@ -4480,14 +4483,17 @@ void MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count,
BlockTrampolinePoolScope block_trampoline_pool(this);
// Optionally restore all double registers.
if (save_doubles) {
// Remember: we only need to restore every 2nd double FPU value.
int kNumOfSavedRegisters = FPURegister::kNumRegisters / 2;
// Remember: we only need to restore kCallerSavedFPU.
Sub64(scratch, fp,
Operand(ExitFrameConstants::kFixedFrameSizeFromFp +
kNumOfSavedRegisters * kDoubleSize));
for (int i = 0; i < kNumOfSavedRegisters; i++) {
FPURegister reg = FPURegister::from_code(2 * i);
LoadDouble(reg, MemOperand(scratch, i * kDoubleSize));
kNumCallerSavedFPU * kDoubleSize));
int cout = 0;
for (int i = 0; i < kNumFPURegisters; i++) {
if (kCalleeSavedFPU & (1 << i)) {
FPURegister reg = FPURegister::from_code(i);
LoadDouble(reg, MemOperand(scratch, cout * kDoubleSize));
cout++;
}
}
}

View File

@ -1107,7 +1107,7 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// Enter exit frame.
// argc - argument count to be dropped by LeaveExitFrame.
// save_doubles - saves FPU registers on stack, currently disabled.
// save_doubles - saves FPU registers on stack.
// stack_space - extra stack space.
void EnterExitFrame(bool save_doubles, int stack_space = 0,
StackFrame::Type frame_type = StackFrame::EXIT);

View File

@ -121,7 +121,7 @@ const RegList kCalleeSavedFPU = 1 << 8 | // fs0
1 << 26 | // fs10
1 << 27; // fs11
const int kNumCalleeSavedFPU = 12;
const int kNumCalleeSavedFPU = NumRegs(kCalleeSavedFPU);
const RegList kCallerSavedFPU = 1 << 0 | // ft0
1 << 1 | // ft1
@ -144,6 +144,8 @@ const RegList kCallerSavedFPU = 1 << 0 | // ft0
1 << 30 | // ft10
1 << 31; // ft11
const int kNumCallerSavedFPU = NumRegs(kCallerSavedFPU);
// Number of registers for which space is reserved in safepoints. Must be a
// multiple of 8.
const int kNumSafepointRegisters = 32;