goto ALLOC_DONE;
}
- else if (!compiler->info.compInitMem && (amount < CORINFO_PAGE_SIZE)) // must be < not <=
+ else if (!compiler->info.compInitMem && (amount < compiler->eeGetPageSize())) // must be < not <=
{
// Since the size is a page or less, simply adjust the SP value
// The SP might already be in the guard page, must touch it BEFORE
getEmitter()->emitIns_R_R_I(INS_ldr, EA_4BYTE, REG_ZR, REG_SPBASE, 0);
// decrement SP by PAGE_SIZE
- getEmitter()->emitIns_R_R_I(INS_sub, EA_PTRSIZE, regTmp, REG_SPBASE, CORINFO_PAGE_SIZE);
+ getEmitter()->emitIns_R_R_I(INS_sub, EA_PTRSIZE, regTmp, REG_SPBASE, compiler->eeGetPageSize());
getEmitter()->emitIns_R_R(INS_cmp, EA_PTRSIZE, regTmp, regCnt);
emitJumpKind jmpLTU = genJumpKindForOper(GT_LT, CK_UNSIGNED);
if (frameSize == 0)
return;
+ const size_t pageSize = compiler->eeGetPageSize();
+
#ifdef _TARGET_ARM_
assert(!compiler->info.compPublishStubParam || (REG_SECRET_STUB_PARAM != initReg));
#endif // _TARGET_ARM_
}
else
#endif // _TARGET_XARCH_
- if (frameSize < CORINFO_PAGE_SIZE)
+ if (frameSize < pageSize)
{
#ifndef _TARGET_ARM64_
// Frame size is (0x0008..0x1000)
inst_RV_IV(INS_sub, REG_SPBASE, frameSize, EA_PTRSIZE);
#endif // !_TARGET_ARM64_
}
- else if (frameSize < VERY_LARGE_FRAME_SIZE)
+ else if (frameSize < compiler->getVeryLargeFrameSize())
{
// Frame size is (0x1000..0x3000)
#if CPU_LOAD_STORE_ARCH
- instGen_Set_Reg_To_Imm(EA_PTRSIZE, initReg, -CORINFO_PAGE_SIZE);
+ instGen_Set_Reg_To_Imm(EA_PTRSIZE, initReg, -(ssize_t)pageSize);
getEmitter()->emitIns_R_R_R(INS_ldr, EA_4BYTE, initReg, REG_SPBASE, initReg);
regTracker.rsTrackRegTrash(initReg);
*pInitRegZeroed = false; // The initReg does not contain zero
#else
getEmitter()->emitIns_AR_R(INS_TEST, EA_PTRSIZE,
- REG_EAX, REG_SPBASE, -CORINFO_PAGE_SIZE);
+ REG_EAX, REG_SPBASE, -(int)pageSize);
#endif
if (frameSize >= 0x2000)
{
#if CPU_LOAD_STORE_ARCH
- instGen_Set_Reg_To_Imm(EA_PTRSIZE, initReg, -2 * CORINFO_PAGE_SIZE);
+ instGen_Set_Reg_To_Imm(EA_PTRSIZE, initReg, -2 * (ssize_t)pageSize);
getEmitter()->emitIns_R_R_R(INS_ldr, EA_4BYTE, initReg, REG_SPBASE, initReg);
regTracker.rsTrackRegTrash(initReg);
#else
getEmitter()->emitIns_AR_R(INS_TEST, EA_PTRSIZE,
- REG_EAX, REG_SPBASE, -2 * CORINFO_PAGE_SIZE);
+ REG_EAX, REG_SPBASE, -2 * (int)pageSize);
#endif
}
else
{
// Frame size >= 0x3000
- assert(frameSize >= VERY_LARGE_FRAME_SIZE);
+ assert(frameSize >= compiler->getVeryLargeFrameSize());
// Emit the following sequence to 'tickle' the pages.
// Note it is important that stack pointer not change until this is
getEmitter()->emitIns_R_R_R(INS_ldr, EA_4BYTE, rTemp, REG_SPBASE, rOffset);
regTracker.rsTrackRegTrash(rTemp);
#if defined(_TARGET_ARM_)
- getEmitter()->emitIns_R_I(INS_sub, EA_PTRSIZE, rOffset, CORINFO_PAGE_SIZE);
+ getEmitter()->emitIns_R_I(INS_sub, EA_PTRSIZE, rOffset, pageSize);
#elif defined(_TARGET_ARM64_)
- getEmitter()->emitIns_R_R_I(INS_sub, EA_PTRSIZE, rOffset, rOffset, CORINFO_PAGE_SIZE);
+ getEmitter()->emitIns_R_R_I(INS_sub, EA_PTRSIZE, rOffset, rOffset, pageSize);
#endif // _TARGET_ARM64_
getEmitter()->emitIns_R_R(INS_cmp, EA_PTRSIZE, rOffset, rLimit);
getEmitter()->emitIns_J(INS_bhi, NULL, -4);
// jge loop 2
getEmitter()->emitIns_R_ARR(INS_TEST, EA_PTRSIZE, initReg, REG_SPBASE, initReg, 0);
- inst_RV_IV(INS_sub, initReg, CORINFO_PAGE_SIZE, EA_PTRSIZE);
+ inst_RV_IV(INS_sub, initReg, pageSize, EA_PTRSIZE);
inst_RV_IV(INS_cmp, initReg, -((ssize_t)frameSize), EA_PTRSIZE);
int bytesForBackwardJump;
#if defined(_TARGET_ARMARCH_)
// We need to determine if we will change SP larger than a specific amount to determine if we want to use a loop
// to touch stack pages, that will require multiple registers. See genAllocLclFrame() for details.
- if (compiler->compLclFrameSize >= VERY_LARGE_FRAME_SIZE)
+ if (compiler->compLclFrameSize >= compiler->getVeryLargeFrameSize())
{
regSet.rsSetRegsModified(VERY_LARGE_FRAME_SIZE_REG_MASK);
}
#endif // _TARGET_ARM_
#if defined(_TARGET_XARCH_)
- if (compiler->compLclFrameSize >= VERY_LARGE_FRAME_SIZE)
+ if (compiler->compLclFrameSize >= compiler->getVeryLargeFrameSize())
{
// We currently must use REG_EAX on x86 here
// because the loop's backwards branch depends upon the size of EAX encodings
// of bytes, to set up a frame in the unmanaged code..
static_assert_no_msg(
- CORINFO_STACKPROBE_DEPTH + JIT_RESERVED_STACK < CORINFO_PAGE_SIZE);
+ CORINFO_STACKPROBE_DEPTH + JIT_RESERVED_STACK < compiler->eeGetPageSize());
JITDUMP("Emitting stack probe:\n");
getEmitter()->emitIns_AR_R(INS_TEST, EA_PTRSIZE,
// Re-bias amount to be number of bytes to adjust the SP
amount <<= STACK_ALIGN_SHIFT;
size->gtIntCon.gtIconVal = amount; // update the GT_CNS value in the node
- if (amount < CORINFO_PAGE_SIZE) // must be < not <=
+ if (amount < compiler->eeGetPageSize()) // must be < not <=
{
// Since the size is a page or less, simply adjust ESP
inst_RV_RV(INS_mov, regTemp, REG_SPBASE, TYP_I_IMPL);
regTracker.rsTrackRegTrash(regTemp);
- inst_RV_IV(INS_sub, regTemp, CORINFO_PAGE_SIZE, EA_PTRSIZE);
+ inst_RV_IV(INS_sub, regTemp, compiler->eeGetPageSize(), EA_PTRSIZE);
inst_RV_RV(INS_mov, REG_SPBASE, regTemp, TYP_I_IMPL);
genRecoverReg(size, RBM_ALLINT, RegSet::KEEP_REG); // not purely the 'size' tree anymore; though it is derived from 'size'
goto ALLOC_DONE;
}
- else if (!compiler->info.compInitMem && (amount < CORINFO_PAGE_SIZE)) // must be < not <=
+ else if (!compiler->info.compInitMem && (amount < compiler->eeGetPageSize())) // must be < not <=
{
// Since the size is less than a page, simply adjust ESP.
// ESP might already be in the guard page, so we must touch it BEFORE
regNumber regTmp = genRegNumFromMask(tmpRegsMask);
inst_RV_RV(INS_mov, regTmp, REG_SPBASE, TYP_I_IMPL);
- inst_RV_IV(INS_sub, regTmp, CORINFO_PAGE_SIZE, EA_PTRSIZE);
+ inst_RV_IV(INS_sub, regTmp, compiler->eeGetPageSize(), EA_PTRSIZE);
inst_RV_RV(INS_mov, REG_SPBASE, regTmp, TYP_I_IMPL);
inst_RV_RV(INS_cmp, REG_SPBASE, regCnt, TYP_I_IMPL);
GenTreePtr eeGetPInvokeCookie(CORINFO_SIG_INFO *szMetaSig);
+ // Returns the page size for the target machine as reported by the EE.
+ inline size_t eeGetPageSize() const
+ {
+ return CORINFO_PAGE_SIZE;
+ }
+
+ // Returns the frame size at which we will generate a loop to probe the stack.
+ inline size_t getVeryLargeFrameSize() const
+ {
+#ifdef _TARGET_ARM_
+ // The looping probe code is 40 bytes, whereas the straight-line probing for
+ // the (0x2000..0x3000) case is 44, so use looping for anything 0x2000 bytes
+ // or greater, to generate smaller code.
+ return 2 * eeGetPageSize();
+#else
+ return 3 * eeGetPageSize();
+#endif
+ }
+
// Exceptions
unsigned eeGetEHcount (CORINFO_METHOD_HANDLE handle);
/*****************************************************************************/
-// Define the frame size at which we will generate a loop to probe the stack.
-// VERY_LARGE_FRAME_SIZE_REG_MASK is the set of registers we need to use for the probing loop.
-
-#ifdef _TARGET_ARM_
-// The looping probe code is 40 bytes, whereas the straight-line probing for
-// the (0x2000..0x3000) case is 44, so use looping for anything 0x2000 bytes
-// or greater, to generate smaller code.
-
-#define VERY_LARGE_FRAME_SIZE (2 * CORINFO_PAGE_SIZE)
-#else
-#define VERY_LARGE_FRAME_SIZE (3 * CORINFO_PAGE_SIZE)
-#endif
+// VERY_LARGE_FRAME_SIZE_REG_MASK is the set of registers we need to use for
+// the probing loop generated for very large stack frames (see `getVeryLargeFrameSize`).
#ifdef _TARGET_ARM_
#define VERY_LARGE_FRAME_SIZE_REG_MASK (RBM_R4 | RBM_R5 | RBM_R6)
else if (!compiler->info.compInitMem)
{
// No need to initialize allocated stack space.
- if (sizeVal < CORINFO_PAGE_SIZE)
+ if (sizeVal < compiler->eeGetPageSize())
{
info->internalIntCount = 0;
}
else if (!compiler->info.compInitMem)
{
// No need to initialize allocated stack space.
- if (sizeVal < CORINFO_PAGE_SIZE)
+ if (sizeVal < compiler->eeGetPageSize())
{
info->internalIntCount = 0;
}
return (SKIP_PUSH_REG(base, offset));
}
- if (size >= CORINFO_PAGE_SIZE)
+ if (size >= OS_PAGE_SIZE)
{
- if (size < (3 * CORINFO_PAGE_SIZE))
+ if (size < (3 * OS_PAGE_SIZE))
{
- // add 7 bytes for one or two TEST EAX, [ESP+CORINFO_PAGE_SIZE]
- offset += (size / CORINFO_PAGE_SIZE) * 7;
+ // add 7 bytes for one or two TEST EAX, [ESP+OS_PAGE_SIZE]
+ offset += (size / OS_PAGE_SIZE) * 7;
}
else
{