Skip to content

Commit 39501f1

Browse files
committed
Remove stack probing under sp on Arm in src/coreclr/jit/codegenarm.cpp src/coreclr/jit/codegencommon.cpp
1 parent 8f7df34 commit 39501f1

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

src/coreclr/jit/codegenarm.cpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,28 +1849,22 @@ void CodeGen::genAllocLclFrame(unsigned frameSize, regNumber initReg, bool* pIni
18491849
{
18501850
GetEmitter()->emitIns_R_I(INS_sub, EA_PTRSIZE, REG_SPBASE, frameSize);
18511851
}
1852-
else if (frameSize < compiler->getVeryLargeFrameSize())
1853-
{
1854-
for (target_size_t probeOffset = pageSize; probeOffset <= frameSize; probeOffset += pageSize)
1855-
{
1856-
// Generate:
1857-
// movw initReg, -probeOffset
1858-
// ldr initReg, [SP + initReg]
1859-
1860-
instGen_Set_Reg_To_Imm(EA_PTRSIZE, initReg, -(ssize_t)probeOffset);
1861-
GetEmitter()->emitIns_R_R_R(INS_ldr, EA_PTRSIZE, initReg, REG_SPBASE, initReg);
1862-
}
1863-
1864-
regSet.verifyRegUsed(initReg);
1865-
*pInitRegZeroed = false; // The initReg does not contain zero
1866-
1867-
instGen_Set_Reg_To_Imm(EA_PTRSIZE, initReg, frameSize);
1868-
compiler->unwindPadding();
1869-
GetEmitter()->emitIns_R_R_R(INS_sub, EA_PTRSIZE, REG_SPBASE, REG_SPBASE, initReg);
1870-
}
18711852
else
18721853
{
1873-
assert(frameSize >= compiler->getVeryLargeFrameSize());
1854+
// Generate the following code:
1855+
//
1856+
// movw r4, #frameSize
1857+
// sub r4, sp, r4
1858+
// bl CORINFO_HELP_STACK_PROBE
1859+
// mov sp, r4
1860+
//
1861+
// If frameSize can not be encoded by movw immediate this becomes:
1862+
//
1863+
// movw r4, #frameSizeLo16
1864+
// movt r4, #frameSizeHi16
1865+
// sub r4, sp, r4
1866+
// bl CORINFO_HELP_STACK_PROBE
1867+
// mov sp, r4
18741868

18751869
genInstrWithConstant(INS_sub, EA_PTRSIZE, REG_STACK_PROBE_HELPER_ARG, REG_SPBASE, frameSize,
18761870
INS_FLAGS_DONT_CARE, REG_STACK_PROBE_HELPER_ARG);

src/coreclr/jit/codegencommon.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6632,10 +6632,8 @@ void CodeGen::genFinalizeFrame()
66326632
#endif // TARGET_X86
66336633

66346634
#ifdef TARGET_ARM
6635-
// Make sure that callee-saved registers used by call to a stack probing helper generated for very large stack
6636-
// frames
6637-
// (see `getVeryLargeFrameSize`) are pushed on stack.
6638-
if (compiler->compLclFrameSize >= compiler->getVeryLargeFrameSize())
6635+
// Make sure that callee-saved registers used by call to a stack probing helper generated are pushed on stack.
6636+
if (compiler->compLclFrameSize >= compiler->eeGetPageSize())
66396637
{
66406638
regSet.rsSetRegsModified(RBM_STACK_PROBE_HELPER_ARG | RBM_STACK_PROBE_HELPER_CALL_TARGET |
66416639
RBM_STACK_PROBE_HELPER_TRASH);

0 commit comments

Comments
 (0)