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