diff options
author | Pat Gavlin <pagavlin@microsoft.com> | 2016-05-16 14:05:17 -0700 |
---|---|---|
committer | Pat Gavlin <pagavlin@microsoft.com> | 2016-05-17 12:00:38 -0700 |
commit | e8ee195d3fc8e6cbece1e0a69fc0586149a21a2f (patch) | |
tree | ed86601f9490805fd2a8613dfdb1607792897623 | |
parent | 182bea3c657856c90e9c5c0bab32bdc63c35352e (diff) | |
download | coreclr-e8ee195d3fc8e6cbece1e0a69fc0586149a21a2f.tar.gz coreclr-e8ee195d3fc8e6cbece1e0a69fc0586149a21a2f.tar.bz2 coreclr-e8ee195d3fc8e6cbece1e0a69fc0586149a21a2f.zip |
Encapsulate or replace references to CORINFO_PAGE_SIZE.
This symbol will be replaced with a new field in CORINFO_EE_INFO as part of #4912.
These changes prepare the JIT and EE for that change by (respectively) encapsulating
references to CORINFO_PAGE_SIZE in Compiler::eeGetPageSize and replacing
CORINFO_PAGE_SIZE with OS_PAGE_SIZE.
-rw-r--r-- | src/jit/codegenarm64.cpp | 4 | ||||
-rw-r--r-- | src/jit/codegencommon.cpp | 28 | ||||
-rw-r--r-- | src/jit/codegenlegacy.cpp | 4 | ||||
-rw-r--r-- | src/jit/codegenxarch.cpp | 4 | ||||
-rw-r--r-- | src/jit/compiler.h | 33 | ||||
-rw-r--r-- | src/jit/lowerarm64.cpp | 2 | ||||
-rw-r--r-- | src/jit/lowerxarch.cpp | 2 | ||||
-rw-r--r-- | src/vm/eetwain.cpp | 8 |
8 files changed, 48 insertions, 37 deletions
diff --git a/src/jit/codegenarm64.cpp b/src/jit/codegenarm64.cpp index 8b78390023..574e438a70 100644 --- a/src/jit/codegenarm64.cpp +++ b/src/jit/codegenarm64.cpp @@ -3523,7 +3523,7 @@ CodeGen::genLclHeap(GenTreePtr tree) 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 @@ -3636,7 +3636,7 @@ CodeGen::genLclHeap(GenTreePtr tree) 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); diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index 7a9b9f9ef9..0ce079c6d3 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -5648,6 +5648,8 @@ void CodeGen::genAllocLclFrame(unsigned frameSize, 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_ @@ -5660,36 +5662,36 @@ void CodeGen::genAllocLclFrame(unsigned frameSize, } 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 } @@ -5709,7 +5711,7 @@ void CodeGen::genAllocLclFrame(unsigned frameSize, 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 @@ -5772,9 +5774,9 @@ void CodeGen::genAllocLclFrame(unsigned frameSize, 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); @@ -5806,7 +5808,7 @@ void CodeGen::genAllocLclFrame(unsigned frameSize, // 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; @@ -7712,7 +7714,7 @@ void CodeGen::genFinalizeFrame() #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); } @@ -8216,7 +8218,7 @@ void CodeGen::genFnProlog() #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 @@ -10166,7 +10168,7 @@ void CodeGen::genGenerateStackProbe() // 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, diff --git a/src/jit/codegenlegacy.cpp b/src/jit/codegenlegacy.cpp index 93a1956336..248ed5ba15 100644 --- a/src/jit/codegenlegacy.cpp +++ b/src/jit/codegenlegacy.cpp @@ -21064,7 +21064,7 @@ regNumber CodeGen::genLclHeap(GenTreePtr size) // 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 @@ -21249,7 +21249,7 @@ regNumber CodeGen::genLclHeap(GenTreePtr size) 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' diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp index 506e1e60ed..b35268e225 100644 --- a/src/jit/codegenxarch.cpp +++ b/src/jit/codegenxarch.cpp @@ -3008,7 +3008,7 @@ CodeGen::genLclHeap(GenTreePtr tree) 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 @@ -3118,7 +3118,7 @@ CodeGen::genLclHeap(GenTreePtr tree) 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); diff --git a/src/jit/compiler.h b/src/jit/compiler.h index 4c3c54824f..a3f1279484 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -6361,6 +6361,25 @@ public : 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); @@ -9101,18 +9120,8 @@ extern const BYTE genActualTypes[]; /*****************************************************************************/ -// 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) diff --git a/src/jit/lowerarm64.cpp b/src/jit/lowerarm64.cpp index b3475cd4a9..c58d4f1379 100644 --- a/src/jit/lowerarm64.cpp +++ b/src/jit/lowerarm64.cpp @@ -815,7 +815,7 @@ void Lowering::TreeNodeInfoInit(GenTree* stmt) else if (!compiler->info.compInitMem) { // No need to initialize allocated stack space. - if (sizeVal < CORINFO_PAGE_SIZE) + if (sizeVal < compiler->eeGetPageSize()) { info->internalIntCount = 0; } diff --git a/src/jit/lowerxarch.cpp b/src/jit/lowerxarch.cpp index e311dddaba..354dc985bf 100644 --- a/src/jit/lowerxarch.cpp +++ b/src/jit/lowerxarch.cpp @@ -1399,7 +1399,7 @@ void Lowering::TreeNodeInfoInit(GenTree* stmt) else if (!compiler->info.compInitMem) { // No need to initialize allocated stack space. - if (sizeVal < CORINFO_PAGE_SIZE) + if (sizeVal < compiler->eeGetPageSize()) { info->internalIntCount = 0; } diff --git a/src/vm/eetwain.cpp b/src/vm/eetwain.cpp index 28bd1ce28d..69eb177542 100644 --- a/src/vm/eetwain.cpp +++ b/src/vm/eetwain.cpp @@ -3002,12 +3002,12 @@ unsigned SKIP_ALLOC_FRAME(int size, PTR_CBYTE base, unsigned offset) 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 { |