Commit 5286799c authored by Zhao Jiazhong's avatar Zhao Jiazhong Committed by Commit Bot

[mips][execution] Add argument count to the standard frame

Port a2fd94f0
https://crrev.com/c/2312783

Original Commit Message:

  This adds the argument count (as intptr) to the standard frame.
  StandardFrames are now in the same shape as OptimizedFrames.

  The argument count in the stack will be used to tear down the
  arguments when we remove the arguments adaptor frame.

Change-Id: I5cff9874735c1bdbd685deb0d829e57f1ee07ac2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2393323Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/master@{#69738}
parent ee801761
......@@ -40,19 +40,25 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) {
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
Runtime::FunctionId function_id) {
// ----------- S t a t e -------------
// -- a0 : actual argument count
// -- a1 : target function (preserved for callee)
// -- a3 : new target (preserved for callee)
// -----------------------------------
{
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the target function and the new target.
// Push a copy of the target function, the new target and the actual
// argument count.
// Push function as parameter to the runtime call.
__ Push(a1, a3, a1);
__ SmiTag(kJavaScriptCallArgCountRegister);
__ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
__ CallRuntime(function_id, 1);
// Restore target function and new target.
__ Pop(a1, a3);
// Restore target function, new target and actual argument count.
__ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister);
__ SmiUntag(kJavaScriptCallArgCountRegister);
}
static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch");
......@@ -844,6 +850,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
Register optimized_code_entry,
Register scratch1, Register scratch2) {
// ----------- S t a t e -------------
// -- a0 : actual argument count
// -- a3 : new target (preserved for callee if needed, and caller)
// -- a1 : target function (preserved for callee if needed, and caller)
// -----------------------------------
......@@ -880,6 +887,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector,
Register optimization_marker) {
// ----------- S t a t e -------------
// -- a0 : actual argument count
// -- a3 : new target (preserved for callee if needed, and caller)
// -- a1 : target function (preserved for callee if needed, and caller)
// -- feedback vector (preserved for caller if needed)
......@@ -989,10 +997,10 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm,
// Generate code for entering a JS function with the interpreter.
// On entry to the function the receiver and arguments have been pushed on the
// stack left to right. The actual argument count matches the formal parameter
// count expected by the function.
// stack left to right.
//
// The live registers are:
// o a0 : actual argument count (not including the receiver)
// o a1: the JS function object being called.
// o a3: the incoming new target or generator object
// o cp: our context
......@@ -1008,16 +1016,18 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ lw(a0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ lw(kScratchReg,
FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ lw(kInterpreterBytecodeArrayRegister,
FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, t0);
FieldMemOperand(kScratchReg, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister,
kScratchReg);
// The bytecode array could have been flushed from the shared function info,
// if so, call into CompileLazy.
Label compile_lazy;
__ GetObjectType(kInterpreterBytecodeArrayRegister, a0, a0);
__ Branch(&compile_lazy, ne, a0, Operand(BYTECODE_ARRAY_TYPE));
__ GetObjectType(kInterpreterBytecodeArrayRegister, kScratchReg, kScratchReg);
__ Branch(&compile_lazy, ne, kScratchReg, Operand(BYTECODE_ARRAY_TYPE));
// Load the feedback vector from the closure.
__ lw(feedback_vector,
......
......@@ -40,18 +40,24 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) {
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
Runtime::FunctionId function_id) {
// ----------- S t a t e -------------
// -- a0 : actual argument count
// -- a1 : target function (preserved for callee)
// -- a3 : new target (preserved for callee)
// -----------------------------------
{
FrameScope scope(masm, StackFrame::INTERNAL);
// Push a copy of the function onto the stack.
// Push a copy of the target function and the new target.
__ Push(a1, a3, a1);
// Push a copy of the target function, the new target and the actual
// argument count.
// Push function as parameter to the runtime call.
__ SmiTag(kJavaScriptCallArgCountRegister);
__ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
__ CallRuntime(function_id, 1);
// Restore target function and new target.
__ Pop(a1, a3);
// Restore target function, new target and actual argument count.
__ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister);
__ SmiUntag(kJavaScriptCallArgCountRegister);
}
static_assert(kJavaScriptCallCodeStartRegister == a2, "ABI mismatch");
......@@ -862,6 +868,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
Register optimized_code_entry,
Register scratch1, Register scratch2) {
// ----------- S t a t e -------------
// -- a0 : actual argument count
// -- a3 : new target (preserved for callee if needed, and caller)
// -- a1 : target function (preserved for callee if needed, and caller)
// -----------------------------------
......@@ -899,6 +906,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector,
Register optimization_marker) {
// ----------- S t a t e -------------
// -- a0 : actual argument count
// -- a3 : new target (preserved for callee if needed, and caller)
// -- a1 : target function (preserved for callee if needed, and caller)
// -- feedback vector (preserved for caller if needed)
......@@ -1008,10 +1016,10 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm,
// Generate code for entering a JS function with the interpreter.
// On entry to the function the receiver and arguments have been pushed on the
// stack left to right. The actual argument count matches the formal parameter
// count expected by the function.
// stack left to right.
//
// The live registers are:
// o a0 : actual argument count (not including the receiver)
// o a1: the JS function object being called.
// o a3: the incoming new target or generator object
// o cp: our context
......@@ -1027,16 +1035,18 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ Ld(a0, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ Ld(kScratchReg,
FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
__ Ld(kInterpreterBytecodeArrayRegister,
FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, a4);
FieldMemOperand(kScratchReg, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister,
kScratchReg);
// The bytecode array could have been flushed from the shared function info,
// if so, call into CompileLazy.
Label compile_lazy;
__ GetObjectType(kInterpreterBytecodeArrayRegister, a0, a0);
__ Branch(&compile_lazy, ne, a0, Operand(BYTECODE_ARRAY_TYPE));
__ GetObjectType(kInterpreterBytecodeArrayRegister, kScratchReg, kScratchReg);
__ Branch(&compile_lazy, ne, kScratchReg, Operand(BYTECODE_ARRAY_TYPE));
// Load the feedback vector from the closure.
__ Ld(feedback_vector,
......
......@@ -146,10 +146,11 @@ void TurboAssembler::PushCommonFrame(Register marker_reg) {
void TurboAssembler::PushStandardFrame(Register function_reg) {
int offset = -StandardFrameConstants::kContextOffset;
if (function_reg.is_valid()) {
Push(ra, fp, cp, function_reg);
offset += kPointerSize;
Push(ra, fp, cp, function_reg, kJavaScriptCallArgCountRegister);
offset += 2 * kPointerSize;
} else {
Push(ra, fp, cp);
Push(ra, fp, cp, kJavaScriptCallArgCountRegister);
offset += kPointerSize;
}
Addu(fp, sp, Operand(offset));
}
......
......@@ -144,10 +144,11 @@ void TurboAssembler::PushCommonFrame(Register marker_reg) {
void TurboAssembler::PushStandardFrame(Register function_reg) {
int offset = -StandardFrameConstants::kContextOffset;
if (function_reg.is_valid()) {
Push(ra, fp, cp, function_reg);
offset += kPointerSize;
Push(ra, fp, cp, function_reg, kJavaScriptCallArgCountRegister);
offset += 2 * kPointerSize;
} else {
Push(ra, fp, cp);
Push(ra, fp, cp, kJavaScriptCallArgCountRegister);
offset += kPointerSize;
}
Daddu(fp, sp, Operand(offset));
}
......
......@@ -3905,9 +3905,6 @@ void CodeGenerator::AssembleConstructFrame() {
}
} else if (call_descriptor->IsJSFunctionCall()) {
__ Prologue();
if (call_descriptor->PushArgumentCount()) {
__ Push(kJavaScriptCallArgCountRegister);
}
} else {
__ StubPrologue(info()->GetOutputStackFrameType());
if (call_descriptor->IsWasmFunctionCall()) {
......
......@@ -4202,9 +4202,6 @@ void CodeGenerator::AssembleConstructFrame() {
}
} else if (call_descriptor->IsJSFunctionCall()) {
__ Prologue();
if (call_descriptor->PushArgumentCount()) {
__ Push(kJavaScriptCallArgCountRegister);
}
} else {
__ StubPrologue(info()->GetOutputStackFrameType());
if (call_descriptor->IsWasmFunctionCall()) {
......
......@@ -16,8 +16,7 @@ class EntryFrameConstants : public AllStatic {
public:
// This is the offset to where JSEntry pushes the current value of
// Isolate::c_entry_fp onto the stack.
static constexpr int kCallerFPOffset =
-(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
// Stack offsets for arguments passed to JSEntry.
static constexpr int kArgcOffset = +0 * kSystemPointerSize;
......
......@@ -16,8 +16,7 @@ class EntryFrameConstants : public AllStatic {
public:
// This is the offset to where JSEntry pushes the current value of
// Isolate::c_entry_fp onto the stack.
static constexpr int kCallerFPOffset =
-(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
};
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
......
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