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

Commit 3d7c803

Browse files
author
Sergey Andreenko
authored
Small clean up of stackEntry (#10820)
Make all stackDepth equal unsigned int. Delete possible wrong function (the comment said : "// used in the inliner, where we can assume typesafe code. please don't use in the importer!!", but it was used). Delete methods, that used arguments as output buffers. * delete code without effects
1 parent a6c2f78 commit 3d7c803

File tree

3 files changed

+33
-61
lines changed

3 files changed

+33
-61
lines changed

src/jit/block.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ enum ThisInitState
139139

140140
struct EntryState
141141
{
142-
ThisInitState thisInitialized : 8; // used to track whether the this ptr is initialized (we could use
143-
// fewer bits here)
144-
unsigned esStackDepth : 24; // size of esStack
145-
StackEntry* esStack; // ptr to stack
142+
ThisInitState thisInitialized; // used to track whether the this ptr is initialized.
143+
unsigned esStackDepth; // size of esStack
144+
StackEntry* esStack; // ptr to stack
146145
};
147146

148147
// Enumeration of the kinds of memory whose state changes the compiler tracks

src/jit/compiler.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,13 +2875,10 @@ class Compiler
28752875
bool impILConsumesAddr(const BYTE* codeAddr, CORINFO_METHOD_HANDLE fncHandle, CORINFO_MODULE_HANDLE scpHandle);
28762876

28772877
void impResolveToken(const BYTE* addr, CORINFO_RESOLVED_TOKEN* pResolvedToken, CorInfoTokenKind kind);
2878-
void impPushOnStackNoType(GenTreePtr tree);
28792878

28802879
void impPushOnStack(GenTreePtr tree, typeInfo ti);
2881-
void impPushNullObjRefOnStack();
2882-
StackEntry impPopStack();
2883-
StackEntry impPopStack(CORINFO_CLASS_HANDLE& structTypeRet);
2884-
GenTreePtr impPopStack(typeInfo& ti);
2880+
void impPushNullObjRefOnStack();
2881+
StackEntry impPopStack();
28852882
StackEntry& impStackTop(unsigned n = 0);
28862883
unsigned impStackHeight();
28872884

src/jit/importer.cpp

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -145,24 +145,6 @@ void Compiler::impPushOnStack(GenTreePtr tree, typeInfo ti)
145145
}
146146
}
147147

148-
/******************************************************************************/
149-
// used in the inliner, where we can assume typesafe code. please don't use in the importer!!
150-
inline void Compiler::impPushOnStackNoType(GenTreePtr tree)
151-
{
152-
assert(verCurrentState.esStackDepth < impStkSize);
153-
INDEBUG(verCurrentState.esStack[verCurrentState.esStackDepth].seTypeInfo = typeInfo());
154-
verCurrentState.esStack[verCurrentState.esStackDepth++].val = tree;
155-
156-
if ((tree->gtType == TYP_LONG) && (compLongUsed == false))
157-
{
158-
compLongUsed = true;
159-
}
160-
else if (((tree->gtType == TYP_FLOAT) || (tree->gtType == TYP_DOUBLE)) && (compFloatingPointUsed == false))
161-
{
162-
compFloatingPointUsed = true;
163-
}
164-
}
165-
166148
inline void Compiler::impPushNullObjRefOnStack()
167149
{
168150
impPushOnStack(gtNewIconNode(0, TYP_REF), typeInfo(TI_NULL));
@@ -322,20 +304,6 @@ StackEntry Compiler::impPopStack()
322304
return verCurrentState.esStack[--verCurrentState.esStackDepth];
323305
}
324306

325-
StackEntry Compiler::impPopStack(CORINFO_CLASS_HANDLE& structType)
326-
{
327-
StackEntry ret = impPopStack();
328-
structType = verCurrentState.esStack[verCurrentState.esStackDepth].seTypeInfo.GetClassHandle();
329-
return (ret);
330-
}
331-
332-
GenTreePtr Compiler::impPopStack(typeInfo& ti)
333-
{
334-
StackEntry ret = impPopStack();
335-
ti = ret.seTypeInfo;
336-
return (ret.val);
337-
}
338-
339307
/*****************************************************************************
340308
*
341309
* Peep at n'th (0-based) tree on the top of the stack.
@@ -5093,8 +5061,9 @@ void Compiler::impImportAndPushBox(CORINFO_RESOLVED_TOKEN* pResolvedToken)
50935061
impSpillSpecialSideEff();
50945062

50955063
// Now get the expression to box from the stack.
5096-
CORINFO_CLASS_HANDLE operCls;
5097-
GenTreePtr exprToBox = impPopStack(operCls).val;
5064+
StackEntry se = impPopStack();
5065+
CORINFO_CLASS_HANDLE operCls = se.seTypeInfo.GetClassHandle();
5066+
GenTreePtr exprToBox = se.val;
50985067

50995068
CorInfoHelpFunc boxHelper = info.compCompHnd->getBoxHelper(pResolvedToken->hClass);
51005069
if (boxHelper == CORINFO_HELP_BOX)
@@ -10052,7 +10021,8 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1005210021
/* Pop the value being assigned */
1005310022

1005410023
{
10055-
StackEntry se = impPopStack(clsHnd);
10024+
StackEntry se = impPopStack();
10025+
clsHnd = se.seTypeInfo.GetClassHandle();
1005610026
op1 = se.val;
1005710027
tiRetVal = se.seTypeInfo;
1005810028
}
@@ -11916,14 +11886,12 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1191611886
break;
1191711887

1191811888
case CEE_POP:
11919-
if (tiVerificationNeeded)
11920-
{
11921-
impStackTop(0);
11922-
}
11923-
11889+
{
1192411890
/* Pull the top value from the stack */
1192511891

11926-
op1 = impPopStack(clsHnd).val;
11892+
StackEntry se = impPopStack();
11893+
clsHnd = se.seTypeInfo.GetClassHandle();
11894+
op1 = se.val;
1192711895

1192811896
/* Get hold of the type of the value being duplicated */
1192911897

@@ -11974,10 +11942,11 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1197411942
}
1197511943

1197611944
/* No side effects - just throw the <BEEP> thing away */
11977-
break;
11945+
}
11946+
break;
1197811947

1197911948
case CEE_DUP:
11980-
11949+
{
1198111950
if (tiVerificationNeeded)
1198211951
{
1198311952
// Dup could start the begining of delegate creation sequence, remember that
@@ -11988,7 +11957,9 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1198811957
// If the expression to dup is simple, just clone it.
1198911958
// Otherwise spill it to a temp, and reload the temp
1199011959
// twice.
11991-
op1 = impPopStack(tiRetVal);
11960+
StackEntry se = impPopStack();
11961+
tiRetVal = se.seTypeInfo;
11962+
op1 = se.val;
1199211963

1199311964
if (!opts.compDbgCode && !op1->IsIntegralConst(0) && !op1->IsFPZero() && !op1->IsLocal())
1199411965
{
@@ -12010,8 +11981,8 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1201011981
assert(!(op1->gtFlags & GTF_GLOB_EFFECT) && !(op2->gtFlags & GTF_GLOB_EFFECT));
1201111982
impPushOnStack(op1, tiRetVal);
1201211983
impPushOnStack(op2, tiRetVal);
12013-
12014-
break;
11984+
}
11985+
break;
1201511986

1201611987
case CEE_STIND_I1:
1201711988
lclTyp = TYP_BYTE;
@@ -12928,8 +12899,10 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1292812899

1292912900
if (opcode == CEE_LDFLD || opcode == CEE_LDFLDA)
1293012901
{
12931-
tiObj = &impStackTop().seTypeInfo;
12932-
obj = impPopStack(objType).val;
12902+
tiObj = &impStackTop().seTypeInfo;
12903+
StackEntry se = impPopStack();
12904+
objType = se.seTypeInfo.GetClassHandle();
12905+
obj = se.val;
1293312906

1293412907
if (impIsThis(obj))
1293512908
{
@@ -13311,8 +13284,10 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1331113284
typeInfo tiVal;
1331213285

1331313286
/* Pull the value from the stack */
13314-
op2 = impPopStack(tiVal);
13315-
clsHnd = tiVal.GetClassHandle();
13287+
StackEntry se = impPopStack();
13288+
op2 = se.val;
13289+
tiVal = se.seTypeInfo;
13290+
clsHnd = tiVal.GetClassHandle();
1331613291

1331713292
if (opcode == CEE_STFLD)
1331813293
{
@@ -14552,7 +14527,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
1455214527
op1 = gtNewOperNode(GT_IND, TYP_REF, op1);
1455314528
op1->gtFlags |= GTF_EXCEPT | GTF_GLOB_REF;
1455414529

14555-
impPushOnStackNoType(op1);
14530+
impPushOnStack(op1, typeInfo());
1455614531
opcode = CEE_STIND_REF;
1455714532
lclTyp = TYP_REF;
1455814533
goto STIND_POST_VERIFY;
@@ -15050,7 +15025,8 @@ bool Compiler::impReturnInstruction(BasicBlock* block, int prefixFlags, OPCODE&
1505015025

1505115026
if (info.compRetType != TYP_VOID)
1505215027
{
15053-
StackEntry se = impPopStack(retClsHnd);
15028+
StackEntry se = impPopStack();
15029+
retClsHnd = se.seTypeInfo.GetClassHandle();
1505415030
op2 = se.val;
1505515031

1505615032
if (!compIsForInlining())

0 commit comments

Comments
 (0)