Commit 6d54d948 authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[mips][sparkplug] Callee-saved registers for RecordWrite

Port c5d41ae6

Bug: v8:11420
Change-Id: I65ac4f2a100ada91f7009ff8990bb6079d00e7dc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2986416Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu yu <liuyu@loongson.cn>
Cr-Commit-Position: refs/heads/master@{#75412}
parent cb66c5b9
...@@ -636,13 +636,14 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ...@@ -636,13 +636,14 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
// -- ra : return address // -- ra : return address
// ----------------------------------- // -----------------------------------
__ AssertGeneratorObject(a1);
// Store input value into generator object. // Store input value into generator object.
__ sw(v0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset)); __ sw(v0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset));
__ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, v0, a3, __ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, v0, a3,
kRAHasNotBeenSaved, SaveFPRegsMode::kIgnore); kRAHasNotBeenSaved, SaveFPRegsMode::kIgnore);
// Check that a1 is still valid, RecordWrite might have clobbered it.
__ AssertGeneratorObject(a1);
// Load suspended function and context. // Load suspended function and context.
__ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
__ lw(cp, FieldMemOperand(t0, JSFunction::kContextOffset)); __ lw(cp, FieldMemOperand(t0, JSFunction::kContextOffset));
......
...@@ -324,12 +324,12 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { ...@@ -324,12 +324,12 @@ void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
// -- a1 : the JSGeneratorObject to resume // -- a1 : the JSGeneratorObject to resume
// -- ra : return address // -- ra : return address
// ----------------------------------- // -----------------------------------
__ AssertGeneratorObject(a1);
// Store input value into generator object. // Store input value into generator object.
__ Sd(v0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset)); __ Sd(v0, FieldMemOperand(a1, JSGeneratorObject::kInputOrDebugPosOffset));
__ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, v0, a3, __ RecordWriteField(a1, JSGeneratorObject::kInputOrDebugPosOffset, v0, a3,
kRAHasNotBeenSaved, SaveFPRegsMode::kIgnore); kRAHasNotBeenSaved, SaveFPRegsMode::kIgnore);
// Check that a1 is still valid, RecordWrite might have clobbered it.
__ AssertGeneratorObject(a1);
// Load suspended function and context. // Load suspended function and context.
__ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); __ Ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
...@@ -779,6 +779,7 @@ static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm, ...@@ -779,6 +779,7 @@ static void ReplaceClosureCodeWithOptimizedCode(MacroAssembler* masm,
Register closure, Register closure,
Register scratch1, Register scratch1,
Register scratch2) { Register scratch2) {
DCHECK(!AreAliased(optimized_code, closure, scratch1, scratch2));
// Store code entry in the closure. // Store code entry in the closure.
__ Sd(optimized_code, FieldMemOperand(closure, JSFunction::kCodeOffset)); __ Sd(optimized_code, FieldMemOperand(closure, JSFunction::kCodeOffset));
__ mov(scratch1, optimized_code); // Write barrier clobbers scratch1 below. __ mov(scratch1, optimized_code); // Write barrier clobbers scratch1 below.
......
...@@ -19,9 +19,22 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() { ...@@ -19,9 +19,22 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
return registers; return registers;
} }
#if DEBUG
template <typename DerivedDescriptor>
void StaticCallInterfaceDescriptor<DerivedDescriptor>::
VerifyArgumentRegisterCount(CallInterfaceDescriptorData* data, int argc) {
RegList allocatable_regs = data->allocatable_registers();
if (argc >= 1) DCHECK(allocatable_regs | a0.bit());
if (argc >= 2) DCHECK(allocatable_regs | a1.bit());
if (argc >= 3) DCHECK(allocatable_regs | a2.bit());
if (argc >= 4) DCHECK(allocatable_regs | a3.bit());
// Additional arguments are passed on the stack.
}
#endif // DEBUG
// static // static
constexpr auto WriteBarrierDescriptor::registers() { constexpr auto WriteBarrierDescriptor::registers() {
return RegisterArray(a0, a1, a2, a3, kReturnRegister0); return RegisterArray(a1, a2, a0, v0, a3);
} }
// static // static
......
...@@ -324,6 +324,7 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -324,6 +324,7 @@ void MacroAssembler::RecordWrite(Register object, Register address,
if (FLAG_debug_code) { if (FLAG_debug_code) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
DCHECK(!AreAliased(object, value, scratch));
lw(scratch, MemOperand(address)); lw(scratch, MemOperand(address));
Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch, Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch,
Operand(value)); Operand(value));
...@@ -355,8 +356,12 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -355,8 +356,12 @@ void MacroAssembler::RecordWrite(Register object, Register address,
if (ra_status == kRAHasNotBeenSaved) { if (ra_status == kRAHasNotBeenSaved) {
push(ra); push(ra);
} }
CallRecordWriteStubSaveRegisters(object, address, remembered_set_action,
fp_mode); Register slot_address = WriteBarrierDescriptor::SlotAddressRegister();
DCHECK(!AreAliased(object, slot_address, value));
mov(slot_address, address);
CallRecordWriteStub(object, slot_address, remembered_set_action, fp_mode);
if (ra_status == kRAHasNotBeenSaved) { if (ra_status == kRAHasNotBeenSaved) {
pop(ra); pop(ra);
} }
...@@ -368,6 +373,7 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -368,6 +373,7 @@ void MacroAssembler::RecordWrite(Register object, Register address,
if (FLAG_debug_code) { if (FLAG_debug_code) {
li(address, Operand(bit_cast<int32_t>(kZapValue + 12))); li(address, Operand(bit_cast<int32_t>(kZapValue + 12)));
li(value, Operand(bit_cast<int32_t>(kZapValue + 16))); li(value, Operand(bit_cast<int32_t>(kZapValue + 16)));
li(slot_address, Operand(bit_cast<int32_t>(kZapValue + 20)));
} }
} }
...@@ -5569,9 +5575,7 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination, ...@@ -5569,9 +5575,7 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination,
DCHECK(root_array_available()); DCHECK(root_array_available());
Label if_code_is_off_heap, out; Label if_code_is_off_heap, out;
UseScratchRegisterScope temps(this); Register scratch = kScratchReg;
Register scratch = temps.Acquire();
DCHECK(!AreAliased(destination, scratch)); DCHECK(!AreAliased(destination, scratch));
DCHECK(!AreAliased(code_object, scratch)); DCHECK(!AreAliased(code_object, scratch));
......
...@@ -19,9 +19,26 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() { ...@@ -19,9 +19,26 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
return registers; return registers;
} }
#if DEBUG
template <typename DerivedDescriptor>
void StaticCallInterfaceDescriptor<DerivedDescriptor>::
VerifyArgumentRegisterCount(CallInterfaceDescriptorData* data, int argc) {
RegList allocatable_regs = data->allocatable_registers();
if (argc >= 1) DCHECK(allocatable_regs | a0.bit());
if (argc >= 2) DCHECK(allocatable_regs | a1.bit());
if (argc >= 3) DCHECK(allocatable_regs | a2.bit());
if (argc >= 4) DCHECK(allocatable_regs | a3.bit());
if (argc >= 5) DCHECK(allocatable_regs | a4.bit());
if (argc >= 6) DCHECK(allocatable_regs | a5.bit());
if (argc >= 7) DCHECK(allocatable_regs | a6.bit());
if (argc >= 8) DCHECK(allocatable_regs | a7.bit());
// Additional arguments are passed on the stack.
}
#endif // DEBUG
// static // static
constexpr auto WriteBarrierDescriptor::registers() { constexpr auto WriteBarrierDescriptor::registers() {
return RegisterArray(a0, a1, a2, a3, kReturnRegister0); return RegisterArray(a1, a5, a4, a0, a2, v0, a3);
} }
// static // static
......
...@@ -321,6 +321,7 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -321,6 +321,7 @@ void MacroAssembler::RecordWrite(Register object, Register address,
if (FLAG_debug_code) { if (FLAG_debug_code) {
UseScratchRegisterScope temps(this); UseScratchRegisterScope temps(this);
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
DCHECK(!AreAliased(object, value, scratch));
Ld(scratch, MemOperand(address)); Ld(scratch, MemOperand(address));
Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch, Assert(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite, scratch,
Operand(value)); Operand(value));
...@@ -352,8 +353,12 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -352,8 +353,12 @@ void MacroAssembler::RecordWrite(Register object, Register address,
if (ra_status == kRAHasNotBeenSaved) { if (ra_status == kRAHasNotBeenSaved) {
push(ra); push(ra);
} }
CallRecordWriteStubSaveRegisters(object, address, remembered_set_action,
fp_mode); Register slot_address = WriteBarrierDescriptor::SlotAddressRegister();
DCHECK(!AreAliased(object, slot_address, value));
mov(slot_address, address);
CallRecordWriteStub(object, slot_address, remembered_set_action, fp_mode);
if (ra_status == kRAHasNotBeenSaved) { if (ra_status == kRAHasNotBeenSaved) {
pop(ra); pop(ra);
} }
...@@ -365,6 +370,7 @@ void MacroAssembler::RecordWrite(Register object, Register address, ...@@ -365,6 +370,7 @@ void MacroAssembler::RecordWrite(Register object, Register address,
if (FLAG_debug_code) { if (FLAG_debug_code) {
li(address, Operand(bit_cast<int64_t>(kZapValue + 12))); li(address, Operand(bit_cast<int64_t>(kZapValue + 12)));
li(value, Operand(bit_cast<int64_t>(kZapValue + 16))); li(value, Operand(bit_cast<int64_t>(kZapValue + 16)));
li(slot_address, Operand(bit_cast<int64_t>(kZapValue + 20)));
} }
} }
...@@ -6099,9 +6105,7 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination, ...@@ -6099,9 +6105,7 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination,
DCHECK(root_array_available()); DCHECK(root_array_available());
Label if_code_is_off_heap, out; Label if_code_is_off_heap, out;
UseScratchRegisterScope temps(this); Register scratch = kScratchReg;
Register scratch = temps.Acquire();
DCHECK(!AreAliased(destination, scratch)); DCHECK(!AreAliased(destination, scratch));
DCHECK(!AreAliased(code_object, scratch)); DCHECK(!AreAliased(code_object, scratch));
......
...@@ -4068,7 +4068,6 @@ void CodeGenerator::FinishFrame(Frame* frame) { ...@@ -4068,7 +4068,6 @@ void CodeGenerator::FinishFrame(Frame* frame) {
const RegList saves = call_descriptor->CalleeSavedRegisters(); const RegList saves = call_descriptor->CalleeSavedRegisters();
if (saves != 0) { if (saves != 0) {
int count = base::bits::CountPopulation(saves); int count = base::bits::CountPopulation(saves);
DCHECK_EQ(kNumCalleeSaved, count + 1);
frame->AllocateSavedCalleeRegisterSlots(count); frame->AllocateSavedCalleeRegisterSlots(count);
} }
} }
...@@ -4192,7 +4191,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4192,7 +4191,6 @@ void CodeGenerator::AssembleConstructFrame() {
if (saves != 0) { if (saves != 0) {
// Save callee-saved registers. // Save callee-saved registers.
__ MultiPush(saves); __ MultiPush(saves);
DCHECK_EQ(kNumCalleeSaved, base::bits::CountPopulation(saves) + 1);
} }
if (returns != 0) { if (returns != 0) {
......
...@@ -4277,7 +4277,6 @@ void CodeGenerator::FinishFrame(Frame* frame) { ...@@ -4277,7 +4277,6 @@ void CodeGenerator::FinishFrame(Frame* frame) {
const RegList saves = call_descriptor->CalleeSavedRegisters(); const RegList saves = call_descriptor->CalleeSavedRegisters();
if (saves != 0) { if (saves != 0) {
int count = base::bits::CountPopulation(saves); int count = base::bits::CountPopulation(saves);
DCHECK_EQ(kNumCalleeSaved, count + 1);
frame->AllocateSavedCalleeRegisterSlots(count); frame->AllocateSavedCalleeRegisterSlots(count);
} }
} }
...@@ -4403,7 +4402,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4403,7 +4402,6 @@ void CodeGenerator::AssembleConstructFrame() {
if (saves != 0) { if (saves != 0) {
// Save callee-saved registers. // Save callee-saved registers.
__ MultiPush(saves); __ MultiPush(saves);
DCHECK_EQ(kNumCalleeSaved, base::bits::CountPopulation(saves) + 1);
} }
if (returns != 0) { if (returns != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment