Commit 996a2dd9 authored by Liu Yu's avatar Liu Yu Committed by Commit Bot

[mips][builtins] Clear c_entry_fp when entering JS and at exception path

Port: 07b03b83

Bug: v8:10026
Change-Id: Ia9e5f420253a4fb3726a4064ed2471684af610e3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2670168
Auto-Submit: Liu yu <liuyu@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/master@{#72521}
parent fca1d52b
......@@ -375,12 +375,18 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
__ li(t3, Operand(-1)); // Push a bad frame pointer to fail if it is used.
__ li(t2, Operand(StackFrame::TypeToMarker(type)));
__ li(t1, Operand(StackFrame::TypeToMarker(type)));
__ li(t0, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress,
__ li(t4, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress,
masm->isolate()));
__ lw(t0, MemOperand(t0));
__ lw(t0, MemOperand(t4));
__ Push(t3, t2, t1, t0);
pushed_stack_space += 4 * kPointerSize;
// Clear c_entry_fp, now we've pushed its previous value to the stack.
// If the c_entry_fp is not already zero and we don't clear it, the
// SafeStackFrameIterator will assume we are executing C++ and miss the JS
// frames on top.
__ Sw(zero_reg, MemOperand(t4));
// Set up frame pointer for the frame to be pushed.
__ addiu(fp, sp, -EntryFrameConstants::kCallerFPOffset);
pushed_stack_space += EntryFrameConstants::kCallerFPOffset;
......@@ -2467,6 +2473,15 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
// underlying register is caller-saved and can be arbitrarily clobbered.
__ ResetSpeculationPoisonRegister();
// Clear c_entry_fp, like we do in `LeaveExitFrame`.
{
UseScratchRegisterScope temps(masm);
Register scratch = temps.Acquire();
__ li(scratch, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress,
masm->isolate()));
__ Sw(zero_reg, MemOperand(scratch));
}
// Compute the handler entry address and jump to it.
__ li(t9, pending_handler_entrypoint_address);
__ lw(t9, MemOperand(t9));
......
......@@ -524,9 +524,16 @@ void Generate_JSEntryVariant(MacroAssembler* masm, StackFrame::Type type,
__ li(s3, Operand(StackFrame::TypeToMarker(type)));
ExternalReference c_entry_fp = ExternalReference::Create(
IsolateAddressId::kCEntryFPAddress, masm->isolate());
__ li(s4, c_entry_fp);
__ Ld(s4, MemOperand(s4));
__ li(s5, c_entry_fp);
__ Ld(s4, MemOperand(s5));
__ Push(s1, s2, s3, s4);
// Clear c_entry_fp, now we've pushed its previous value to the stack.
// If the c_entry_fp is not already zero and we don't clear it, the
// SafeStackFrameIterator will assume we are executing C++ and miss the JS
// frames on top.
__ Sd(zero_reg, MemOperand(s5));
// Set up frame pointer for the frame to be pushed.
__ daddiu(fp, sp, -EntryFrameConstants::kCallerFPOffset);
......@@ -2540,6 +2547,15 @@ void Builtins::Generate_CEntry(MacroAssembler* masm, int result_size,
// underlying register is caller-saved and can be arbitrarily clobbered.
__ ResetSpeculationPoisonRegister();
// Clear c_entry_fp, like we do in `LeaveExitFrame`.
{
UseScratchRegisterScope temps(masm);
Register scratch = temps.Acquire();
__ li(scratch, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress,
masm->isolate()));
__ Sd(zero_reg, MemOperand(scratch));
}
// Compute the handler entry address and jump to it.
__ li(t9, pending_handler_entrypoint_address);
__ Ld(t9, MemOperand(t9));
......
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