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) {
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
Runtime::FunctionId function_id) {
// ----------- S t a t e -------------
// -- r3 : actual argument count
// -- r4 : target function (preserved for callee)
// -- r6 : new target (preserved for callee)
// -----------------------------------
{
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(r4, r6, r4);
__ SmiTag(kJavaScriptCallArgCountRegister);
__ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
__ CallRuntime(function_id, 1);
__ mr(r5, r3);
// Restore target function and new target.
__ Pop(r4, r6);
// Restore target function, new target and actual argument count.
__ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister);
__ SmiUntag(kJavaScriptCallArgCountRegister);
}
static_assert(kJavaScriptCallCodeStartRegister == r5, "ABI mismatch");
__ JumpCodeObject(r5);
......@@ -928,6 +934,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
Register optimized_code_entry,
Register scratch) {
// ----------- S t a t e -------------
// -- r3 : actual argument count
// -- r6 : new target (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,
static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector,
Register optimization_marker) {
// ----------- S t a t e -------------
// -- r3 : actual argument count
// -- r6 : new target (preserved for callee if needed, and caller)
// -- r4 : target function (preserved for callee if needed, and caller)
// -- feedback vector (preserved for caller if needed)
......@@ -1076,10 +1084,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 r3: actual argument count (not including the receiver)
// o r4: the JS function object being called.
// o r6: the incoming new target or generator object
// o cp: our context
......@@ -1097,17 +1105,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ LoadTaggedPointerField(
r3, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
r7, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
// Load original bytecode array or the debug copy.
__ LoadTaggedPointerField(
kInterpreterBytecodeArrayRegister,
FieldMemOperand(r3, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, r7);
FieldMemOperand(r7, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, ip);
// The bytecode array could have been flushed from the shared function info,
// if so, call into CompileLazy.
Label compile_lazy;
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r3, no_reg,
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r7, no_reg,
BYTECODE_ARRAY_TYPE);
__ bne(&compile_lazy);
......@@ -1180,8 +1188,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
// Push bytecode array and Smi tagged bytecode array offset.
__ SmiTag(r3, kInterpreterBytecodeOffsetRegister);
__ Push(kInterpreterBytecodeArrayRegister, r3);
__ SmiTag(r7, kInterpreterBytecodeOffsetRegister);
__ Push(kInterpreterBytecodeArrayRegister, r7);
// Allocate the local and temporary register file on the stack.
Label stack_overflow;
......
......@@ -38,20 +38,26 @@ void Builtins::Generate_Adaptor(MacroAssembler* masm, Address address) {
static void GenerateTailCallToReturnedCode(MacroAssembler* masm,
Runtime::FunctionId function_id) {
// ----------- S t a t e -------------
// -- r2 : actual argument count
// -- r3 : target function (preserved for callee)
// -- r5 : new target (preserved for callee)
// -----------------------------------
{
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(r3, r5, r3);
__ SmiTag(kJavaScriptCallArgCountRegister);
__ Push(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister, kJavaScriptCallTargetRegister);
__ CallRuntime(function_id, 1);
__ LoadRR(r4, r2);
// Restore target function and new target.
__ Pop(r3, r5);
// Restore target function, new target and actual argument count.
__ Pop(kJavaScriptCallTargetRegister, kJavaScriptCallNewTargetRegister,
kJavaScriptCallArgCountRegister);
__ SmiUntag(kJavaScriptCallArgCountRegister);
}
static_assert(kJavaScriptCallCodeStartRegister == r4, "ABI mismatch");
__ JumpCodeObject(r4);
......@@ -1000,6 +1006,7 @@ static void TailCallOptimizedCodeSlot(MacroAssembler* masm,
Register optimized_code_entry,
Register scratch) {
// ----------- S t a t e -------------
// -- r2 : actual argument count
// -- r5 : new target (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,
static void MaybeOptimizeCode(MacroAssembler* masm, Register feedback_vector,
Register optimization_marker) {
// ----------- S t a t e -------------
// -- r2 : actual argument count
// -- r5 : new target (preserved for callee if needed, and caller)
// -- r3 : target function (preserved for callee if needed, and caller)
// -- feedback vector (preserved for caller if needed)
......@@ -1148,10 +1156,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 r2: actual argument count (not including the receiver)
// o r3: the JS function object being called.
// o r5: the incoming new target or generator object
// o cp: our context
......@@ -1169,17 +1177,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
// Get the bytecode array from the function object and load it into
// kInterpreterBytecodeArrayRegister.
__ LoadTaggedPointerField(
r2, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
r6, FieldMemOperand(closure, JSFunction::kSharedFunctionInfoOffset));
// Load original bytecode array or the debug copy.
__ LoadTaggedPointerField(
kInterpreterBytecodeArrayRegister,
FieldMemOperand(r2, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, r6);
FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset));
GetSharedFunctionInfoBytecode(masm, kInterpreterBytecodeArrayRegister, ip);
// The bytecode array could have been flushed from the shared function info,
// if so, call into CompileLazy.
Label compile_lazy;
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r2, no_reg,
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r6, no_reg,
BYTECODE_ARRAY_TYPE);
__ bne(&compile_lazy);
......
......@@ -807,6 +807,7 @@ void TurboAssembler::PushStandardFrame(Register function_reg) {
}
}
addi(fp, sp, Operand(fp_delta * kSystemPointerSize));
Push(kJavaScriptCallArgCountRegister);
}
void TurboAssembler::RestoreFrameStateForTailCall() {
......
......@@ -790,6 +790,7 @@ void TurboAssembler::PushStandardFrame(Register function_reg) {
fp_delta = 1;
}
la(fp, MemOperand(sp, fp_delta * kSystemPointerSize));
Push(kJavaScriptCallArgCountRegister);
}
void TurboAssembler::RestoreFrameStateForTailCall() {
......
......@@ -3637,9 +3637,6 @@ void CodeGenerator::AssembleConstructFrame() {
}
} else if (call_descriptor->IsJSFunctionCall()) {
__ Prologue();
if (call_descriptor->PushArgumentCount()) {
__ Push(kJavaScriptCallArgCountRegister);
}
} else {
StackFrame::Type type = info()->GetOutputStackFrameType();
// TODO(mbrandy): Detect cases where ip is the entrypoint (for
......
......@@ -4579,9 +4579,6 @@ void CodeGenerator::AssembleConstructFrame() {
}
} else if (call_descriptor->IsJSFunctionCall()) {
__ Prologue(ip);
if (call_descriptor->PushArgumentCount()) {
__ Push(kJavaScriptCallArgCountRegister);
}
} else {
StackFrame::Type type = info()->GetOutputStackFrameType();
// TODO(mbrandy): Detect cases where ip is the entrypoint (for
......
......@@ -14,8 +14,8 @@ namespace internal {
class EntryFrameConstants : public AllStatic {
public:
static constexpr int kCallerFPOffset =
-(StandardFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize);
// Need to take constant pool into account.
static constexpr int kCallerFPOffset = -4 * kSystemPointerSize;
};
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
......
......@@ -14,8 +14,8 @@ namespace internal {
class EntryFrameConstants : public AllStatic {
public:
static constexpr int kCallerFPOffset =
-(StandardFrameConstants::kFixedFrameSizeFromFp + kSystemPointerSize);
static constexpr int kCallerFPOffset = -3 * kSystemPointerSize;
// Stack offsets for arguments passed to JSEntry.
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