From 7771be315561041a2c1dcf11ac612fc19fc0636f Mon Sep 17 00:00:00 2001 From: petris Date: Tue, 25 Apr 2023 21:20:27 +0200 Subject: [PATCH 1/2] Fix totalILArgs for explicithis --- src/coreclr/inc/corinfo.h | 3 ++- src/coreclr/vm/interpreter.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 0b50a047b3f66e..9ea457224e8fa7 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -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); } }; diff --git a/src/coreclr/vm/interpreter.h b/src/coreclr/vm/interpreter.h index 51a82a6da047af..94866d174b8e49 100644 --- a/src/coreclr/vm/interpreter.h +++ b/src/coreclr/vm/interpreter.h @@ -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); } From 52c65a0112464530a3e635975c8c0cc8cf094e76 Mon Sep 17 00:00:00 2001 From: petris Date: Tue, 25 Apr 2023 22:18:39 +0200 Subject: [PATCH 2/2] Fix missed places --- src/coreclr/jit/inlinepolicy.cpp | 6 ++---- src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/coreclr/jit/inlinepolicy.cpp b/src/coreclr/jit/inlinepolicy.cpp index d11cc1e905f8fa..ebba45105bbd15 100644 --- a/src/coreclr/jit/inlinepolicy.cpp +++ b/src/coreclr/jit/inlinepolicy.cpp @@ -846,9 +846,7 @@ 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" } @@ -856,7 +854,7 @@ int DefaultPolicy::DetermineCallsiteNativeSizeEstimate(CORINFO_METHOD_INFO* meth 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); diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index b45184a5b68037..68895109bb56d9 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -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); } };