Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[WIP] Remove tailcall limitations on unix64 and arm64 #25932

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,8 +1647,10 @@ void CodeGen::genPutArgStkFieldList(GenTreePutArgStk* putArgStk, unsigned outArg
unsigned thisFieldOffset = argOffset + fieldListPtr->gtFieldOffset;
getEmitter()->emitIns_S_R(ins_Store(type), attr, reg, outArgVarNum, thisFieldOffset);

// We can't write beyond the arg area
assert((thisFieldOffset + EA_SIZE_IN_BYTES(attr)) <= compiler->lvaLclSize(outArgVarNum));
// We can't write beyond the arg area unless this is a tail call, in which case we use
// the first stack arg as the base of the incoming arg area.
assert(putArgStk->gtCall->IsFastTailCall() ||
(thisFieldOffset + EA_SIZE_IN_BYTES(attr)) <= compiler->lvaLclSize(outArgVarNum));
}
}
#endif // !_TARGET_X86_
Expand Down
1 change: 0 additions & 1 deletion src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8733,7 +8733,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

#if FEATURE_FASTTAILCALL
size_t compArgStackSize; // Incoming argument stack size in bytes
bool compHasMultiSlotArgs; // Caller has >8 byte sized struct parameter
#endif // FEATURE_FASTTAILCALL

unsigned compRetBuffArg; // position of hidden return param var (0, 1) (BAD_VAR_NUM means not present);
Expand Down
7 changes: 3 additions & 4 deletions src/jit/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,14 @@
#define UNIX_AMD64_ABI_ONLY(x)
#endif // defined(UNIX_AMD64_ABI)

#if defined(UNIX_AMD64_ABI) || !defined(_TARGET_64BIT_) || (defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_))
#if defined(UNIX_AMD64_ABI) || !defined(_TARGET_64BIT_) || defined(_TARGET_ARM64_)
#define FEATURE_PUT_STRUCT_ARG_STK 1
#define PUT_STRUCT_ARG_STK_ONLY_ARG(x) , x
#define PUT_STRUCT_ARG_STK_ONLY(x) x
#else // !(defined(UNIX_AMD64_ABI) && defined(_TARGET_64BIT_) && !(defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_))
#else
#define PUT_STRUCT_ARG_STK_ONLY_ARG(x)
#define PUT_STRUCT_ARG_STK_ONLY(x)
#endif // !(defined(UNIX_AMD64_ABI) && defined(_TARGET_64BIT_) && !(defined(_TARGET_WINDOWS_) &&
// defined(_TARGET_ARM64_))
#endif

#if defined(UNIX_AMD64_ABI)
#define UNIX_AMD64_ABI_ONLY_ARG(x) , x
Expand Down
11 changes: 3 additions & 8 deletions src/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ void Compiler::lvaInitArgs(InitVarDscInfo* varDscInfo)
// We can get register usage information using codeGen->intRegState and
// codeGen->floatRegState
info.compArgStackSize = varDscInfo->stackArgSize;
info.compHasMultiSlotArgs = varDscInfo->hasMultiSlotStruct;
#endif // FEATURE_FASTTAILCALL

// The total argument size must be aligned.
Expand Down Expand Up @@ -851,7 +850,6 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
if (cSlots == 2)
{
varDsc->lvOtherArgReg = genMapRegArgNumToRegNum(firstAllocatedRegArgNum + 1, TYP_I_IMPL);
varDscInfo->hasMultiSlotStruct = true;
}
}
#elif defined(UNIX_AMD64_ABI)
Expand All @@ -864,7 +862,6 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
{
secondEightByteType = GetEightByteType(structDesc, 1);
secondAllocatedRegArgNum = varDscInfo->allocRegArg(secondEightByteType, 1);
varDscInfo->hasMultiSlotStruct = true;
}

if (secondEightByteType != TYP_UNDEF)
Expand Down Expand Up @@ -1004,11 +1001,7 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo)
#endif // _TARGET_XXX_

#if FEATURE_FASTTAILCALL
if (cSlots > 1)
{
varDscInfo->hasMultiSlotStruct = true;
}

varDsc->lvStkOffs = varDscInfo->stackArgSize;
varDscInfo->stackArgSize += roundUp(argSize, TARGET_POINTER_SIZE);
#endif // FEATURE_FASTTAILCALL
}
Expand Down Expand Up @@ -1102,6 +1095,7 @@ void Compiler::lvaInitGenericsCtxt(InitVarDscInfo* varDscInfo)
// returns false.
varDsc->lvOnFrame = true;
#if FEATURE_FASTTAILCALL
varDsc->lvStkOffs = varDscInfo->stackArgSize;
varDscInfo->stackArgSize += TARGET_POINTER_SIZE;
#endif // FEATURE_FASTTAILCALL
}
Expand Down Expand Up @@ -1171,6 +1165,7 @@ void Compiler::lvaInitVarArgsHandle(InitVarDscInfo* varDscInfo)
// returns false.
varDsc->lvOnFrame = true;
#if FEATURE_FASTTAILCALL
varDsc->lvStkOffs = varDscInfo->stackArgSize;
varDscInfo->stackArgSize += TARGET_POINTER_SIZE;
#endif // FEATURE_FASTTAILCALL
}
Expand Down
Loading