Skip to content

Commit

Permalink
Fix totalILArgs for explicithis (#85347)
Browse files Browse the repository at this point in the history
* Fix totalILArgs for explicithis

* Fix missed places
  • Loading branch information
MichalPetryka authored Apr 26, 2023
1 parent e8b41db commit ff0f603
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,8 @@ struct CORINFO_SIG_INFO
CorInfoCallConv getCallConv() { return CorInfoCallConv((callConv & CORINFO_CALLCONV_MASK)); }
bool hasThis() { return ((callConv & CORINFO_CALLCONV_HASTHIS) != 0); }
bool hasExplicitThis() { return ((callConv & CORINFO_CALLCONV_EXPLICITTHIS) != 0); }
unsigned totalILArgs() { return (numArgs + (hasThis() ? 1 : 0)); }
bool hasImplicitThis() { return ((callConv & (CORINFO_CALLCONV_HASTHIS | CORINFO_CALLCONV_EXPLICITTHIS)) == CORINFO_CALLCONV_HASTHIS); }
unsigned totalILArgs() { return (numArgs + (hasImplicitThis() ? 1 : 0)); }
bool isVarArg() { return ((getCallConv() == CORINFO_CALLCONV_VARARG) || (getCallConv() == CORINFO_CALLCONV_NATIVEVARARG)); }
bool hasTypeArg() { return ((callConv & CORINFO_CALLCONV_PARAMTYPE) != 0); }
};
Expand Down
6 changes: 2 additions & 4 deletions src/coreclr/jit/inlinepolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,17 +846,15 @@ int DefaultPolicy::DetermineCallsiteNativeSizeEstimate(CORINFO_METHOD_INFO* meth
{
int callsiteSize = 55; // Direct call take 5 native bytes; indirect call takes 6 native bytes.

bool hasThis = methInfo->args.hasThis();

if (hasThis)
if (methInfo->args.hasImplicitThis())
{
callsiteSize += 30; // "mov" or "lea"
}

CORINFO_ARG_LIST_HANDLE argLst = methInfo->args.args;
COMP_HANDLE comp = m_RootCompiler->info.compCompHnd;

for (unsigned i = (hasThis ? 1 : 0); i < methInfo->args.totalILArgs(); i++, argLst = comp->getArgNext(argLst))
for (unsigned i = 0; i < methInfo->args.numArgs; i++, argLst = comp->getArgNext(argLst))
{
var_types sigType = (var_types)m_RootCompiler->eeGetArgType(argLst, &methInfo->args);

Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public unsafe struct CORINFO_SIG_INFO
private CorInfoCallConv getCallConv() { return (CorInfoCallConv)((callConv & CorInfoCallConv.CORINFO_CALLCONV_MASK)); }
private bool hasThis() { return ((callConv & CorInfoCallConv.CORINFO_CALLCONV_HASTHIS) != 0); }
private bool hasExplicitThis() { return ((callConv & CorInfoCallConv.CORINFO_CALLCONV_EXPLICITTHIS) != 0); }
private uint totalILArgs() { return (uint)(numArgs + (hasThis() ? 1 : 0)); }
private bool hasImplicitThis() { return ((callConv & (CorInfoCallConv.CORINFO_CALLCONV_HASTHIS | CorInfoCallConv.CORINFO_CALLCONV_EXPLICITTHIS)) == CorInfoCallConv.CORINFO_CALLCONV_HASTHIS); }
private uint totalILArgs() { return (uint)(numArgs + (hasImplicitThis() ? 1 : 0)); }
private bool isVarArg() { return ((getCallConv() == CorInfoCallConv.CORINFO_CALLCONV_VARARG) || (getCallConv() == CorInfoCallConv.CORINFO_CALLCONV_NATIVEVARARG)); }
internal bool hasTypeArg() { return ((callConv & CorInfoCallConv.CORINFO_CALLCONV_PARAMTYPE) != 0); }
};
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ struct CORINFO_SIG_INFO_SMALL
CorInfoCallConv getCallConv() { return CorInfoCallConv((callConv & CORINFO_CALLCONV_MASK)); }
bool hasThis() { return ((callConv & CORINFO_CALLCONV_HASTHIS) != 0); }
bool hasExplicitThis() { return ((callConv & CORINFO_CALLCONV_EXPLICITTHIS) != 0); }
unsigned totalILArgs() { return (numArgs + hasThis()); }
bool hasImplicitThis() { return ((callConv & (CORINFO_CALLCONV_HASTHIS | CORINFO_CALLCONV_EXPLICITTHIS)) == CORINFO_CALLCONV_HASTHIS); }
unsigned totalILArgs() { return (numArgs + (hasImplicitThis() ? 1 : 0)); }
bool isVarArg() { return ((getCallConv() == CORINFO_CALLCONV_VARARG) || (getCallConv() == CORINFO_CALLCONV_NATIVEVARARG)); }
bool hasTypeArg() { return ((callConv & CORINFO_CALLCONV_PARAMTYPE) != 0); }

Expand Down

0 comments on commit ff0f603

Please sign in to comment.