Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ef74ed6

Browse files
echesakovjkotas
authored andcommitted
Clean up clrjit from using sizeof(void*) when meant TARGET_POINTER_SIZE (#15524)
1 parent 3c958f3 commit ef74ed6

17 files changed

+126
-125
lines changed

src/jit/codegencommon.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,7 +3113,7 @@ void CodeGen::genGenerateCode(void** codePtr, ULONG* nativeSizeOfCode)
31133113
// and thus saved on the frame).
31143114

31153115
// Compute the maximum estimated spill temp size.
3116-
unsigned maxTmpSize = sizeof(double) + sizeof(float) + sizeof(__int64) + sizeof(void*);
3116+
unsigned maxTmpSize = sizeof(double) + sizeof(float) + sizeof(__int64) + TARGET_POINTER_SIZE;
31173117

31183118
maxTmpSize += (compiler->tmpDoubleSpillMax * sizeof(double)) + (compiler->tmpIntSpillMax * sizeof(int));
31193119

@@ -5122,7 +5122,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere
51225122
// idea of how to ignore it.
51235123

51245124
// On Arm, a long can be passed in register
5125-
noway_assert(genTypeSize(genActualType(varDsc->TypeGet())) == sizeof(void*));
5125+
noway_assert(genTypeSize(genActualType(varDsc->TypeGet())) == TARGET_POINTER_SIZE);
51265126
#endif
51275127
#endif //_TARGET_64BIT_
51285128

@@ -5618,7 +5618,7 @@ void CodeGen::genCheckUseBlockInit()
56185618
initStkLclCnt += varDsc->lvStructGcCount;
56195619
}
56205620

5621-
if ((compiler->lvaLclSize(varNum) > (3 * sizeof(void*))) && (largeGcStructs <= 4))
5621+
if ((compiler->lvaLclSize(varNum) > (3 * TARGET_POINTER_SIZE)) && (largeGcStructs <= 4))
56225622
{
56235623
largeGcStructs++;
56245624
}
@@ -9151,10 +9151,10 @@ void CodeGen::genFnProlog()
91519151
if (compiler->ehNeedsShadowSPslots() && !compiler->info.compInitMem)
91529152
{
91539153
// The last slot is reserved for ICodeManager::FixContext(ppEndRegion)
9154-
unsigned filterEndOffsetSlotOffs = compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - (sizeof(void*));
9154+
unsigned filterEndOffsetSlotOffs = compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - TARGET_POINTER_SIZE;
91559155

91569156
// Zero out the slot for nesting level 0
9157-
unsigned firstSlotOffs = filterEndOffsetSlotOffs - (sizeof(void*));
9157+
unsigned firstSlotOffs = filterEndOffsetSlotOffs - TARGET_POINTER_SIZE;
91589158

91599159
if (!initRegZeroed)
91609160
{
@@ -9779,7 +9779,7 @@ void CodeGen::genFnEpilog(BasicBlock* block)
97799779
/* Add 'compiler->compLclFrameSize' to ESP */
97809780
/* Use pop ECX to increment ESP by 4, unless compiler->compJmpOpUsed is true */
97819781

9782-
if ((compiler->compLclFrameSize == sizeof(void*)) && !compiler->compJmpOpUsed)
9782+
if ((compiler->compLclFrameSize == TARGET_POINTER_SIZE) && !compiler->compJmpOpUsed)
97839783
{
97849784
inst_RV(INS_pop, REG_ECX, TYP_I_IMPL);
97859785
regTracker.rsTrackRegTrash(REG_ECX);
@@ -10008,8 +10008,8 @@ void CodeGen::genFnEpilog(BasicBlock* block)
1000810008

1000910009
if (fCalleePop)
1001010010
{
10011-
noway_assert(compiler->compArgSize >= intRegState.rsCalleeRegArgCount * sizeof(void*));
10012-
stkArgSize = compiler->compArgSize - intRegState.rsCalleeRegArgCount * sizeof(void*);
10011+
noway_assert(compiler->compArgSize >= intRegState.rsCalleeRegArgCount * REGSIZE_BYTES);
10012+
stkArgSize = compiler->compArgSize - intRegState.rsCalleeRegArgCount * REGSIZE_BYTES;
1001310013

1001410014
noway_assert(compiler->compArgSize < 0x10000); // "ret" only has 2 byte operand
1001510015
}
@@ -11948,7 +11948,7 @@ void CodeGen::genSetScopeInfo(unsigned which,
1194811948

1194911949
noway_assert(cookieOffset < varOffset);
1195011950
unsigned offset = varOffset - cookieOffset;
11951-
unsigned stkArgSize = compiler->compArgSize - intRegState.rsCalleeRegArgCount * sizeof(void*);
11951+
unsigned stkArgSize = compiler->compArgSize - intRegState.rsCalleeRegArgCount * REGSIZE_BYTES;
1195211952
noway_assert(offset < stkArgSize);
1195311953
offset = stkArgSize - offset;
1195411954

src/jit/codegenlegacy.cpp

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5090,11 +5090,12 @@ void CodeGen::genCodeForTreeLeaf(GenTreePtr tree, regMaskTP destReg, regMaskTP b
50905090
// The last slot is reserved for ICodeManager::FixContext(ppEndRegion)
50915091
unsigned filterEndOffsetSlotOffs;
50925092
PREFIX_ASSUME(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) >
5093-
sizeof(void*)); // below doesn't underflow.
5094-
filterEndOffsetSlotOffs = (unsigned)(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - (sizeof(void*)));
5093+
TARGET_POINTER_SIZE); // below doesn't underflow.
5094+
filterEndOffsetSlotOffs =
5095+
(unsigned)(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - TARGET_POINTER_SIZE);
50955096

50965097
unsigned curNestingSlotOffs;
5097-
curNestingSlotOffs = filterEndOffsetSlotOffs - ((finallyNesting + 1) * sizeof(void*));
5098+
curNestingSlotOffs = filterEndOffsetSlotOffs - ((finallyNesting + 1) * TARGET_POINTER_SIZE);
50985099
instGen_Store_Imm_Into_Lcl(TYP_I_IMPL, EA_PTRSIZE, 0, compiler->lvaShadowSPslotsVar, curNestingSlotOffs);
50995100
reg = REG_STK;
51005101
break;
@@ -13047,14 +13048,14 @@ void CodeGen::genCodeForBBlist()
1304713048
// The last slot is reserved for ICodeManager::FixContext(ppEndRegion)
1304813049
unsigned filterEndOffsetSlotOffs;
1304913050
filterEndOffsetSlotOffs =
13050-
(unsigned)(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - (sizeof(void*)));
13051+
(unsigned)(compiler->lvaLclSize(compiler->lvaShadowSPslotsVar) - TARGET_POINTER_SIZE);
1305113052

1305213053
unsigned curNestingSlotOffs;
13053-
curNestingSlotOffs = (unsigned)(filterEndOffsetSlotOffs - ((finallyNesting + 1) * sizeof(void*)));
13054+
curNestingSlotOffs = (unsigned)(filterEndOffsetSlotOffs - ((finallyNesting + 1) * TARGET_POINTER_SIZE));
1305413055

1305513056
// Zero out the slot for the next nesting level
1305613057
instGen_Store_Imm_Into_Lcl(TYP_I_IMPL, EA_PTRSIZE, 0, compiler->lvaShadowSPslotsVar,
13057-
curNestingSlotOffs - sizeof(void*));
13058+
curNestingSlotOffs - TARGET_POINTER_SIZE);
1305813059

1305913060
instGen_Store_Imm_Into_Lcl(TYP_I_IMPL, EA_PTRSIZE, LCL_FINALLY_MARK, compiler->lvaShadowSPslotsVar,
1306013061
curNestingSlotOffs);
@@ -15977,7 +15978,8 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1597715978
addrReg = 0;
1597815979

1597915980
// Get the number of BYTES to copy to the stack
15980-
opsz = roundUp(compiler->info.compCompHnd->getClassSize(arg->gtObj.gtClass), sizeof(void*));
15981+
opsz = roundUp(compiler->info.compCompHnd->getClassSize(arg->gtObj.gtClass),
15982+
TARGET_POINTER_SIZE);
1598115983
size_t bytesToBeCopied = opsz;
1598215984

1598315985
// postponedFields is true if we have any postponed fields
@@ -16020,14 +16022,14 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1602016022
if (fieldVarDsc->lvStackAligned())
1602116023
{
1602216024
if (fieldVarDsc->lvExactSize != 2 * sizeof(unsigned) &&
16023-
fieldVarDsc->lvFldOffset + sizeof(void*) != bytesToBeCopied)
16025+
fieldVarDsc->lvFldOffset + TARGET_POINTER_SIZE != bytesToBeCopied)
1602416026
{
1602516027
// Might need 4-bytes paddings for fields other than LONG and DOUBLE.
1602616028
// Just push some junk (i.e EAX) on the stack.
1602716029
inst_RV(INS_push, REG_EAX, TYP_INT);
1602816030
genSinglePush();
1602916031

16030-
bytesToBeCopied -= sizeof(void*);
16032+
bytesToBeCopied -= TARGET_POINTER_SIZE;
1603116033
}
1603216034

1603316035
// If we have an expectedAlignedOffset make sure that this push instruction
@@ -16060,11 +16062,11 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1606016062
}
1606116063
else
1606216064
{
16063-
getEmitter()->emitIns_S(INS_push, EA_4BYTE, varNum, sizeof(void*));
16065+
getEmitter()->emitIns_S(INS_push, EA_4BYTE, varNum, TARGET_POINTER_SIZE);
1606416066
genSinglePush();
1606516067
}
1606616068

16067-
bytesToBeCopied -= sizeof(void*);
16069+
bytesToBeCopied -= TARGET_POINTER_SIZE;
1606816070
}
1606916071

1607016072
// Push the "upper half" of DOUBLE var if it is not enregistered.
@@ -16073,11 +16075,11 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1607316075
{
1607416076
if (!fieldVarDsc->lvRegister)
1607516077
{
16076-
getEmitter()->emitIns_S(INS_push, EA_4BYTE, varNum, sizeof(void*));
16078+
getEmitter()->emitIns_S(INS_push, EA_4BYTE, varNum, TARGET_POINTER_SIZE);
1607716079
genSinglePush();
1607816080
}
1607916081

16080-
bytesToBeCopied -= sizeof(void*);
16082+
bytesToBeCopied -= TARGET_POINTER_SIZE;
1608116083
}
1608216084

1608316085
//
@@ -16156,7 +16158,7 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1615616158
genSinglePush();
1615716159
}
1615816160

16159-
bytesToBeCopied -= sizeof(void*);
16161+
bytesToBeCopied -= TARGET_POINTER_SIZE;
1616016162
}
1616116163
else // not stack aligned
1616216164
{
@@ -16171,11 +16173,12 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1617116173
// This should never change until it is set back to UINT_MAX by an aligned
1617216174
// offset
1617316175
noway_assert(expectedAlignedOffset ==
16174-
roundUp(fieldVarDsc->lvFldOffset, sizeof(void*)) - sizeof(void*));
16176+
roundUp(fieldVarDsc->lvFldOffset, TARGET_POINTER_SIZE) -
16177+
TARGET_POINTER_SIZE);
1617516178
}
1617616179

1617716180
expectedAlignedOffset =
16178-
roundUp(fieldVarDsc->lvFldOffset, sizeof(void*)) - sizeof(void*);
16181+
roundUp(fieldVarDsc->lvFldOffset, TARGET_POINTER_SIZE) - TARGET_POINTER_SIZE;
1617916182

1618016183
noway_assert(expectedAlignedOffset < bytesToBeCopied);
1618116184

@@ -16302,8 +16305,8 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1630216305
noway_assert(arg->gtObj.gtOp1->InReg());
1630316306
regNumber reg = arg->gtObj.gtOp1->gtRegNum;
1630416307
// Get the number of DWORDS to copy to the stack
16305-
opsz = roundUp(compiler->info.compCompHnd->getClassSize(arg->gtObj.gtClass), sizeof(void*));
16306-
unsigned slots = (unsigned)(opsz / sizeof(void*));
16308+
opsz = roundUp(compiler->info.compCompHnd->getClassSize(arg->gtObj.gtClass), sizeof(DWORD));
16309+
unsigned slots = (unsigned)(opsz / sizeof(DWORD));
1630716310

1630816311
BYTE* gcLayout = new (compiler, CMK_Codegen) BYTE[slots];
1630916312

@@ -16355,7 +16358,7 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1635516358

1635616359
if (opsz & 0x4)
1635716360
{
16358-
stkDisp -= sizeof(void*);
16361+
stkDisp -= TARGET_POINTER_SIZE;
1635916362
getEmitter()->emitIns_AR_R(INS_push, EA_4BYTE, REG_NA, reg, stkDisp);
1636016363
genSinglePush();
1636116364
}
@@ -16367,7 +16370,7 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1636716370
{
1636816371
getEmitter()->emitIns_R_AR(INS_movq, EA_8BYTE, xmmReg, reg, curDisp);
1636916372
getEmitter()->emitIns_AR_R(INS_movq, EA_8BYTE, xmmReg, REG_SPBASE, curDisp);
16370-
curDisp += 2 * sizeof(void*);
16373+
curDisp += 2 * TARGET_POINTER_SIZE;
1637116374
}
1637216375
noway_assert(curDisp == stkDisp);
1637316376
}
@@ -16385,7 +16388,7 @@ size_t CodeGen::genPushArgList(GenTreeCall* call)
1638516388
noway_assert(gcLayout[i] == TYPE_GC_BYREF);
1638616389
fieldSize = EA_BYREF;
1638716390
}
16388-
getEmitter()->emitIns_AR_R(INS_push, fieldSize, REG_NA, reg, i * sizeof(void*));
16391+
getEmitter()->emitIns_AR_R(INS_push, fieldSize, REG_NA, reg, i * TARGET_POINTER_SIZE);
1638916392
genSinglePush();
1639016393
}
1639116394
}
@@ -19290,7 +19293,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
1929019293
/* Keep track of ESP for EBP-less frames */
1929119294
genSinglePush();
1929219295

19293-
argSize += sizeof(void*);
19296+
argSize += REGSIZE_BYTES;
1929419297

1929519298
#elif defined(_TARGET_ARM_)
1929619299

@@ -19683,16 +19686,16 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
1968319686
// Push the count of the incoming stack arguments
1968419687

1968519688
unsigned nOldStkArgs =
19686-
(unsigned)((compiler->compArgSize - (intRegState.rsCalleeRegArgCount * sizeof(void*))) / sizeof(void*));
19689+
(unsigned)((compiler->compArgSize - (intRegState.rsCalleeRegArgCount * REGSIZE_BYTES)) / REGSIZE_BYTES);
1968719690
getEmitter()->emitIns_I(INS_push, EA_4BYTE, nOldStkArgs);
1968819691
genSinglePush(); // Keep track of ESP for EBP-less frames
19689-
args += sizeof(void*);
19692+
args += REGSIZE_BYTES;
1969019693

1969119694
// Push the count of the outgoing stack arguments
1969219695

19693-
getEmitter()->emitIns_I(INS_push, EA_4BYTE, argSize / sizeof(void*));
19696+
getEmitter()->emitIns_I(INS_push, EA_4BYTE, argSize / REGSIZE_BYTES);
1969419697
genSinglePush(); // Keep track of ESP for EBP-less frames
19695-
args += sizeof(void*);
19698+
args += REGSIZE_BYTES;
1969619699

1969719700
// Push info about the callee-saved registers to be restored
1969819701
// For now, we always spill all registers if compiler->compTailCallUsed
@@ -19701,13 +19704,13 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
1970119704
(fTailCallTargetIsVSD ? 0x2 : 0x0); // Stub dispatch flag
1970219705
getEmitter()->emitIns_I(INS_push, EA_4BYTE, calleeSavedRegInfo);
1970319706
genSinglePush(); // Keep track of ESP for EBP-less frames
19704-
args += sizeof(void*);
19707+
args += REGSIZE_BYTES;
1970519708

1970619709
// Push the address of the target function
1970719710

1970819711
getEmitter()->emitIns_R(INS_push, EA_4BYTE, REG_TAILCALL_ADDR);
1970919712
genSinglePush(); // Keep track of ESP for EBP-less frames
19710-
args += sizeof(void*);
19713+
args += REGSIZE_BYTES;
1971119714

1971219715
#else // _TARGET_X86_
1971319716

src/jit/compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ unsigned Compiler::compGetTypeSize(CorInfoType cit, CORINFO_CLASS_HANDLE clsHnd)
21792179
}
21802180
else if (cit == CORINFO_TYPE_REFANY)
21812181
{
2182-
sigSize = 2 * sizeof(void*);
2182+
sigSize = 2 * TARGET_POINTER_SIZE;
21832183
}
21842184
return sigSize;
21852185
}

src/jit/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ class LclVarDsc
743743
bool lvStackAligned() const
744744
{
745745
assert(lvIsStructField);
746-
return ((lvFldOffset % sizeof(void*)) == 0);
746+
return ((lvFldOffset % TARGET_POINTER_SIZE) == 0);
747747
}
748748
bool lvNormalizeOnLoad() const
749749
{

src/jit/compiler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,7 @@ inline void LclVarDsc::addPrefReg(regMaskTP regMask, Compiler* comp)
21312131

21322132
#ifdef _TARGET_ARM_
21332133
// Don't set a preferred register for a TYP_STRUCT that takes more than one register slot
2134-
if ((lvType == TYP_STRUCT) && (lvSize() > sizeof(void*)))
2134+
if ((lvType == TYP_STRUCT) && (lvSize() > REGSIZE_BYTES))
21352135
return;
21362136
#endif
21372137

src/jit/ee_il_dll.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ unsigned Compiler::eeGetArgSize(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO*
441441
return structSize; // TODO: roundUp() needed here?
442442
}
443443
#endif // FEATURE_UNIX_AMD64_STRUCT_PASSING
444-
return sizeof(size_t);
444+
return TARGET_POINTER_SIZE;
445445

446446
#else // !_TARGET_AMD64_
447447

@@ -454,7 +454,7 @@ unsigned Compiler::eeGetArgSize(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO*
454454
unsigned structSize = info.compCompHnd->getClassSize(argClass);
455455

456456
// make certain the EE passes us back the right thing for refanys
457-
assert(argTypeJit != CORINFO_TYPE_REFANY || structSize == 2 * sizeof(void*));
457+
assert(argTypeJit != CORINFO_TYPE_REFANY || structSize == 2 * TARGET_POINTER_SIZE);
458458

459459
// For each target that supports passing struct args in multiple registers
460460
// apply the target specific rules for them here:

0 commit comments

Comments
 (0)