Skip to content

Commit

Permalink
JIT: arm64 osr funclet frame probing
Browse files Browse the repository at this point in the history
We currently need to pad OSR funclet frames with the full size of the
Tier0 frame, and this paddign sits above the register save area. For
large Tier0 frames we thus need to probe the stack in the OSR prolog
for type1 and type3 frames, before doing the initial SP adjustment and
save.

Longer term the plan is to revise arm64 OSR so we will not need to
do this padding; at that point we can remove this extra probing.

Fixes dotnet#70263.
  • Loading branch information
AndyAyersMS committed Jun 22, 2022
1 parent d3f7e01 commit 1b8006f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,10 +1377,12 @@ void CodeGen::genFuncletProlog(BasicBlock* block)

if (genFuncletInfo.fiFrameType == 1)
{
// With OSR we may see large values for fiSpDelta1
// (we really need to probe the frame, sigh)
if (compiler->opts.IsOSR())
{
// With OSR we may see large values for fiSpDelta1.
// We repurpose genAllocLclFram to do the necessary probing.
bool scratchRegIsZero = false;
genAllocLclFrame(-genFuncletInfo.fiSpDelta1, REG_SCRATCH, &scratchRegIsZero, maskArgRegsLiveIn);
genStackPointerAdjustment(genFuncletInfo.fiSpDelta1, REG_SCRATCH, nullptr, /* reportUnwindData */ true);
GetEmitter()->emitIns_R_R_R_I(INS_stp, EA_PTRSIZE, REG_FP, REG_LR, REG_SPBASE, 0);
compiler->unwindSaveRegPair(REG_FP, REG_LR, 0);
Expand Down Expand Up @@ -1416,10 +1418,12 @@ void CodeGen::genFuncletProlog(BasicBlock* block)
}
else if (genFuncletInfo.fiFrameType == 3)
{
// With OSR we may see large values for fiSpDelta1
// (we really need to probe the frame, sigh)
if (compiler->opts.IsOSR())
{
// With OSR we may see large values for fiSpDelta1
// We repurpose genAllocLclFram to do the necessary probing.
bool scratchRegIsZero = false;
genAllocLclFrame(-genFuncletInfo.fiSpDelta1, REG_SCRATCH, &scratchRegIsZero, maskArgRegsLiveIn);
genStackPointerAdjustment(genFuncletInfo.fiSpDelta1, REG_SCRATCH, nullptr, /* reportUnwindData */ true);
GetEmitter()->emitIns_R_R_R_I(INS_stp, EA_PTRSIZE, REG_FP, REG_LR, REG_SPBASE, 0);
compiler->unwindSaveRegPair(REG_FP, REG_LR, 0);
Expand Down

0 comments on commit 1b8006f

Please sign in to comment.