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

Commit 8604efa

Browse files
Merge pull request #6342 from BruceForstall/tailcall
RyuJIT/x86: implement tailcall via helper
2 parents 1bb9e2d + fe4ac43 commit 8604efa

File tree

7 files changed

+465
-148
lines changed

7 files changed

+465
-148
lines changed

src/jit/assertionprop.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,15 +1911,15 @@ void Compiler::optAssertionGen(GenTreePtr tree)
19111911
{
19121912
// Retrieve the 'this' arg
19131913
GenTreePtr thisArg = gtGetThisArg(tree);
1914-
#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_)
1914+
#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) || defined(_TARGET_ARM_)
19151915
if (thisArg == nullptr)
19161916
{
19171917
// For tail calls we lose the this pointer in the argument list but that's OK because a null check
19181918
// was made explicit, so we get the assertion when we walk the GT_IND in the argument list.
19191919
noway_assert(tree->gtCall.IsTailCall());
19201920
break;
19211921
}
1922-
#endif // _TARGET_AMD64_ || _TARGET_ARM_
1922+
#endif // _TARGET_X86_ || _TARGET_AMD64_ || _TARGET_ARM_
19231923
noway_assert(thisArg != nullptr);
19241924
assertionIndex = optCreateAssertion(thisArg, nullptr, OAK_NOT_EQUAL);
19251925
}

src/jit/codegencommon.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,10 +1391,6 @@ void CodeGenInterface::reloadFloatReg(var_types type, TempDsc* tm
13911391
regNumber CodeGenInterface::genGetThisArgReg(GenTreePtr call)
13921392
{
13931393
noway_assert(call->IsCall());
1394-
#if RETBUFARG_PRECEDES_THIS
1395-
if (call->AsCall()->HasRetBufArg())
1396-
return REG_ARG_1;
1397-
#endif // RETBUFARG_PRECEEDS_THIS
13981394
return REG_ARG_0;
13991395
}
14001396

@@ -7813,6 +7809,18 @@ void CodeGen::genFinalizeFrame()
78137809

78147810
// Set various registers as "modified" for special code generation scenarios: Edit & Continue, P/Invoke calls, etc.
78157811

7812+
#if defined(_TARGET_X86_)
7813+
if (compiler->compTailCallUsed)
7814+
{
7815+
// If we are generating a helper-based tailcall, we've set the tailcall helper "flags"
7816+
// argument to "1", indicating to the tailcall helper that we've saved the callee-saved
7817+
// registers (ebx, esi, edi). So, we need to make sure all the callee-saved registers
7818+
// actually get saved.
7819+
7820+
regSet.rsSetRegsModified(RBM_INT_CALLEE_SAVED);
7821+
}
7822+
#endif // _TARGET_X86_
7823+
78167824
#if defined(_TARGET_ARMARCH_)
78177825
// We need to determine if we will change SP larger than a specific amount to determine if we want to use a loop
78187826
// to touch stack pages, that will require multiple registers. See genAllocLclFrame() for details.

src/jit/compiler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ struct fgArgTabEntry
11401140
bool processed :1; // True when we have decided the evaluation order for this argument in the gtCallLateArgs
11411141
bool isHfaRegArg :1; // True when the argument is passed as a HFA in FP registers.
11421142
bool isBackFilled :1; // True when the argument fills a register slot skipped due to alignment requirements of previous arguments.
1143-
bool isNonStandard:1; // True if it is an arg that is passed in a reg other than a standard arg reg
1143+
bool isNonStandard:1; // True if it is an arg that is passed in a reg other than a standard arg reg, or is forced to be on the stack despite its arg list position.
11441144

11451145
#if defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
11461146
bool isStruct :1; // True if this is a struct arg
@@ -1279,7 +1279,6 @@ class fgArgInfo
12791279
unsigned GetNextSlotNum() { return nextSlotNum; }
12801280
bool HasRegArgs() { return hasRegArgs; }
12811281
bool HasStackArgs() { return hasStackArgs; }
1282-
12831282
};
12841283

12851284

src/jit/gentree.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8087,18 +8087,23 @@ void Compiler::gtDispNode(GenTreePtr tree,
80878087

80888088
// If we have an indent stack, don't add additional characters,
80898089
// as it will mess up the alignment.
8090-
if (tree->gtOper != GT_STMT && hasSeqNum && (indentStack == nullptr))
8090+
bool displayDotNum = tree->gtOper != GT_STMT && hasSeqNum && (indentStack == nullptr);
8091+
if (displayDotNum)
8092+
{
80918093
printf("N%03u.%02u ", prev->gtSeqNum, dotNum);
8094+
}
80928095
else
8096+
{
80938097
printf(" ");
8098+
}
80948099

80958100
if (tree->gtCostsInitialized)
80968101
{
80978102
printf("(%3u,%3u) ", tree->gtCostEx, tree->gtCostSz);
80988103
}
80998104
else
81008105
{
8101-
if (tree->gtOper != GT_STMT && hasSeqNum)
8106+
if (displayDotNum)
81028107
{
81038108
// Do better alignment in this case
81048109
printf(" ");

0 commit comments

Comments
 (0)