Commit b469661e authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

PPC/S390: [execution] Add argument count to the standard frame

Port: a2fd94f0

Change-Id: I174ef5523806d23a0425e546ffe557b2c21defe7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2390828Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#69697}
parent a8ffcacb
...@@ -38,20 +38,26 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) { ...@@ -38,20 +38,26 @@ 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 -------------
// -- r3 : actual argument count
// -- r4 : target function (preserved for callee) // -- r4 : target function (preserved for callee)
// -- r6 : new target (preserved for callee) // -- r6 : new target (preserved for callee)
// ----------------------------------- // -----------------------------------
{ {
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); FrameAndConstantPoolScope 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(r4, r6, r4); __ SmiTag(kJavaScriptCallArgCountRegister);
__ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
__ CallRuntime(function_id, 1); __ CallRuntime(function_id, 1);
__ mr(r5, r3); __ mr(r5, r3);
// Restore target function and new target. // Restore target function, new target and actual argument count.
__ Pop(r4, r6); __ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister);
__ SmiUntag(kJavaScriptCallArgCountRegister);
} }
static_assert(kJavaScriptCallCodeStartRegister == r5, "ABI mismatch"); static_assert(kJavaScriptCallCodeStartRegister == r5, "ABI mismatch");
__ JumpCodeObject(r5); __ JumpCodeObject(r5);
...@@ -928,6 +934,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -928,6 +934,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
Register optimized_code_entry, Register optimized_code_entry,
Register scratch) { Register scratch) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r3 : actual argument count
// -- r6 : new target (preserved for callee if needed, and caller) // -- r6 : new target (preserved for callee if needed, and caller)
// -- r4 : target function (preserved for callee if needed, and caller) // -- r4 : target function (preserved for callee if needed, and caller)
// ----------------------------------- // -----------------------------------
...@@ -964,6 +971,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -964,6 +971,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 -------------
// -- r3 : actual argument count
// -- r6 : new target (preserved for callee if needed, and caller) // -- r6 : new target (preserved for callee if needed, and caller)
// -- r4 : target function (preserved for callee if needed, and caller) // -- r4 : target function (preserved for callee if needed, and caller)
// -- feedback vector (preserved for caller if needed) // -- feedback vector (preserved for caller if needed)
...@@ -1076,10 +1084,10 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, ...@@ -1076,10 +1084,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 r3: actual argument count (not including the receiver)
// o r4: the JS function object being called. // o r4: the JS function object being called.
// o r6: the incoming new target or generator object // o r6: the incoming new target or generator object
// o cp: our context // o cp: our context
...@@ -1097,17 +1105,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1097,17 +1105,17 @@ 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.
__ LoadTaggedPointerField( __ LoadTaggedPointerField(
r3, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); r7, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
// Load original bytecode array or the debug copy. // Load original bytecode array or the debug copy.
__ LoadTaggedPointerField( __ LoadTaggedPointerField(
kInterpreterBytecodeArrayRegister, kInterpreterBytecodeArrayRegister,
FieldMemOperand(r3, SharedFunctionInfo::kFunctionDataOffset)); FieldMemOperand(r7, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, r7); GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, ip);
// 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;
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r3, no_reg, __ CompareObjectType(kInterpreterBytecodeArrayRegister, r7, no_reg,
BYTECODE_ARRAY_TYPE); BYTECODE_ARRAY_TYPE);
__ bne(&compile_lazy); __ bne(&compile_lazy);
...@@ -1180,8 +1188,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1180,8 +1188,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
// Push bytecode array and Smi tagged bytecode array offset. // Push bytecode array and Smi tagged bytecode array offset.
__ SmiTag(r3, kInterpreterBytecodeOffsetRegister); __ SmiTag(r7, kInterpreterBytecodeOffsetRegister);
__ Push(kInterpreterBytecodeArrayRegister, r3); __ Push(kInterpreterBytecodeArrayRegister, r7);
// Allocate the local and temporary register file on the stack. // Allocate the local and temporary register file on the stack.
Label stack_overflow; Label stack_overflow;
......
...@@ -38,20 +38,26 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) { ...@@ -38,20 +38,26 @@ 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 -------------
// -- r2 : actual argument count
// -- r3 : target function (preserved for callee) // -- r3 : target function (preserved for callee)
// -- r5 : new target (preserved for callee) // -- r5 : new target (preserved for callee)
// ----------------------------------- // -----------------------------------
{ {
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); FrameAndConstantPoolScope 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(r3, r5, r3); __ SmiTag(kJavaScriptCallArgCountRegister);
__ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
__ CallRuntime(function_id, 1); __ CallRuntime(function_id, 1);
__ LoadRR(r4, r2); __ LoadRR(r4, r2);
// Restore target function and new target. // Restore target function, new target and actual argument count.
__ Pop(r3, r5); __ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister);
__ SmiUntag(kJavaScriptCallArgCountRegister);
} }
static_assert(kJavaScriptCallCodeStartRegister == r4, "ABI mismatch"); static_assert(kJavaScriptCallCodeStartRegister == r4, "ABI mismatch");
__ JumpCodeObject(r4); __ JumpCodeObject(r4);
...@@ -1000,6 +1006,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -1000,6 +1006,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
Register optimized_code_entry, Register optimized_code_entry,
Register scratch) { Register scratch) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- r2 : actual argument count
// -- r5 : new target (preserved for callee if needed, and caller) // -- r5 : new target (preserved for callee if needed, and caller)
// -- r3 : target function (preserved for callee if needed, and caller) // -- r3 : target function (preserved for callee if needed, and caller)
// ----------------------------------- // -----------------------------------
...@@ -1035,6 +1042,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm, ...@@ -1035,6 +1042,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 -------------
// -- r2 : actual argument count
// -- r5 : new target (preserved for callee if needed, and caller) // -- r5 : new target (preserved for callee if needed, and caller)
// -- r3 : target function (preserved for callee if needed, and caller) // -- r3 : target function (preserved for callee if needed, and caller)
// -- feedback vector (preserved for caller if needed) // -- feedback vector (preserved for caller if needed)
...@@ -1148,10 +1156,10 @@ static void AdvanceBytecodeOffsetOrReturn(MacroAssembler* masm, ...@@ -1148,10 +1156,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 r2: actual argument count (not including the receiver)
// o r3: the JS function object being called. // o r3: the JS function object being called.
// o r5: the incoming new target or generator object // o r5: the incoming new target or generator object
// o cp: our context // o cp: our context
...@@ -1169,17 +1177,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1169,17 +1177,17 @@ 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.
__ LoadTaggedPointerField( __ LoadTaggedPointerField(
r2, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset)); r6, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
// Load original bytecode array or the debug copy. // Load original bytecode array or the debug copy.
__ LoadTaggedPointerField( __ LoadTaggedPointerField(
kInterpreterBytecodeArrayRegister, kInterpreterBytecodeArrayRegister,
FieldMemOperand(r2, SharedFunctionInfo::kFunctionDataOffset)); FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, r6); GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, ip);
// 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;
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r2, no_reg, __ CompareObjectType(kInterpreterBytecodeArrayRegister, r6, no_reg,
BYTECODE_ARRAY_TYPE); BYTECODE_ARRAY_TYPE);
__ bne(&compile_lazy); __ bne(&compile_lazy);
......
...@@ -807,6 +807,7 @@ void TurboAssembler::PushStandardFrame(Register function_reg) { ...@@ -807,6 +807,7 @@ void TurboAssembler::PushStandardFrame(Register function_reg) {
} }
} }
addi(fp, sp, Operand(fp_delta * kSystemPointerSize)); addi(fp, sp, Operand(fp_delta * kSystemPointerSize));
Push(kJavaScriptCallArgCountRegister);
} }
void TurboAssembler::RestoreFrameStateForTailCall() { void TurboAssembler::RestoreFrameStateForTailCall() {
......
...@@ -790,6 +790,7 @@ void TurboAssembler::PushStandardFrame(Register function_reg) { ...@@ -790,6 +790,7 @@ void TurboAssembler::PushStandardFrame(Register function_reg) {
fp_delta = 1; fp_delta = 1;
} }
la(fp, MemOperand(sp, fp_delta * kSystemPointerSize)); la(fp, MemOperand(sp, fp_delta * kSystemPointerSize));
Push(kJavaScriptCallArgCountRegister);
} }
void TurboAssembler::RestoreFrameStateForTailCall() { void TurboAssembler::RestoreFrameStateForTailCall() {
......
...@@ -3637,9 +3637,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3637,9 +3637,6 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} else if (call_descriptor->IsJSFunctionCall()) { } else if (call_descriptor->IsJSFunctionCall()) {
__ Prologue(); __ Prologue();
if (call_descriptor->PushArgumentCount()) {
__ Push(kJavaScriptCallArgCountRegister);
}
} else { } else {
StackFrame::Type type = info()->GetOutputStackFrameType(); StackFrame::Type type = info()->GetOutputStackFrameType();
// TODO(mbrandy): Detect cases where ip is the entrypoint (for // TODO(mbrandy): Detect cases where ip is the entrypoint (for
......
...@@ -4579,9 +4579,6 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4579,9 +4579,6 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} else if (call_descriptor->IsJSFunctionCall()) { } else if (call_descriptor->IsJSFunctionCall()) {
__ Prologue(ip); __ Prologue(ip);
if (call_descriptor->PushArgumentCount()) {
__ Push(kJavaScriptCallArgCountRegister);
}
} else { } else {
StackFrame::Type type = info()->GetOutputStackFrameType(); StackFrame::Type type = info()->GetOutputStackFrameType();
// TODO(mbrandy): Detect cases where ip is the entrypoint (for // TODO(mbrandy): Detect cases where ip is the entrypoint (for
......
...@@ -14,8 +14,8 @@ namespace internal { ...@@ -14,8 +14,8 @@ namespace internal {
class EntryFrameConstants : public AllStatic { class EntryFrameConstants : public AllStatic {
public: public:
static constexpr int kCallerFPOffset = // Need to take constant pool into account.
-(StandardFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize); static constexpr int kCallerFPOffset = -4 * kSystemPointerSize;
}; };
class WasmCompileLazyFrameConstants : public TypedFrameConstants { class WasmCompileLazyFrameConstants : public TypedFrameConstants {
......
...@@ -14,8 +14,8 @@ namespace internal { ...@@ -14,8 +14,8 @@ namespace internal {
class EntryFrameConstants : public AllStatic { class EntryFrameConstants : public AllStatic {
public: public:
static constexpr int kCallerFPOffset = static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
-(StandardFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize);
// Stack offsets for arguments passed to JSEntry. // Stack offsets for arguments passed to JSEntry.
static constexpr int kArgvOffset = 20 * kSystemPointerSize; static constexpr int kArgvOffset = 20 * kSystemPointerSize;
}; };
......
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