Skip to content

Commit

Permalink
JIT: arm64 osr funclet frame probing (#70916)
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 type 1, 3, and 5 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 #70263.
  • Loading branch information
AndyAyersMS committed Jun 23, 2022
1 parent d17741d commit 95d64e8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/coreclr/jit/codegenarm64.cpp
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 Expand Up @@ -1450,6 +1454,10 @@ void CodeGen::genFuncletProlog(BasicBlock* block)

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);
}
else
Expand Down

0 comments on commit 95d64e8

Please sign in to comment.