From 3d611730c50e9f2074b44a16746f8ff295101b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 12 Nov 2025 11:22:56 +0100 Subject: [PATCH 1/3] Report `CORINFO_CALLCONV_GENERIC` to JIT Apparently we got away without reporting this until the test in #121130 was added. Not reporting the calling convention results in this not kicking in: https://github.com/dotnet/runtime/blob/5e97723bdd8eb9eff95c52b7120cec6bfb5a0a19/src/coreclr/jit/importer.cpp#L7291-L7297 And failing the test. --- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 1 + src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs | 9 +++++++++ .../tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs | 3 +++ 3 files changed, 13 insertions(+) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 0539dd033922aa..2d741dbe3ea518 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -881,6 +881,7 @@ private void Get_CORINFO_SIG_INFO(MethodSignature signature, CORINFO_SIG_INFO* s if (!signature.IsStatic) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_HASTHIS; if (signature.IsExplicitThis) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_EXPLICITTHIS; + if (signature.IsGeneric) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_GENERIC; TypeDesc returnType = signature.ReturnType; diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index 96d4c0b163507e..c02e4205d2e1d3 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -23,6 +23,7 @@ public enum MethodSignatureFlags Static = 0x0010, ExplicitThis = 0x0020, + Generic = 0x0040, } public enum EmbeddedSignatureDataKind @@ -138,6 +139,14 @@ public bool IsExplicitThis } } + public bool IsGeneric + { + get + { + return (_flags & MethodSignatureFlags.Generic) != 0; + } + } + public int GenericParameterCount { get diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs index e68a0428170925..fa024f8938c2a1 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs @@ -383,6 +383,9 @@ private MethodSignature ParseMethodSignatureImpl(bool skipEmbeddedSignatureData) if (header.HasExplicitThis) flags |= MethodSignatureFlags.ExplicitThis; + if (header.IsGeneric) + flags |= MethodSignatureFlags.Generic; + int arity = header.IsGeneric ? _reader.ReadCompressedInteger() : 0; int count = _reader.ReadCompressedInteger(); From a19b2dc04d86bbb6c3142107e2a42af5e7ed39b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 12 Nov 2025 23:43:07 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Jan Kotas --- src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 2d741dbe3ea518..93b63e1d0af186 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -881,7 +881,8 @@ private void Get_CORINFO_SIG_INFO(MethodSignature signature, CORINFO_SIG_INFO* s if (!signature.IsStatic) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_HASTHIS; if (signature.IsExplicitThis) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_EXPLICITTHIS; - if (signature.IsGeneric) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_GENERIC; + + if (signature.GenericParameterCount != 0) sig->callConv |= CorInfoCallConv.CORINFO_CALLCONV_GENERIC; TypeDesc returnType = signature.ReturnType; From 1443b963a97851e8b463008a2e9db1b6f9eec5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 12 Nov 2025 23:46:35 +0100 Subject: [PATCH 3/3] FB --- src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs | 9 --------- .../tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs | 3 --- 2 files changed, 12 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs index c02e4205d2e1d3..96d4c0b163507e 100644 --- a/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs +++ b/src/coreclr/tools/Common/TypeSystem/Common/MethodDesc.cs @@ -23,7 +23,6 @@ public enum MethodSignatureFlags Static = 0x0010, ExplicitThis = 0x0020, - Generic = 0x0040, } public enum EmbeddedSignatureDataKind @@ -139,14 +138,6 @@ public bool IsExplicitThis } } - public bool IsGeneric - { - get - { - return (_flags & MethodSignatureFlags.Generic) != 0; - } - } - public int GenericParameterCount { get diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs index fa024f8938c2a1..e68a0428170925 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs @@ -383,9 +383,6 @@ private MethodSignature ParseMethodSignatureImpl(bool skipEmbeddedSignatureData) if (header.HasExplicitThis) flags |= MethodSignatureFlags.ExplicitThis; - if (header.IsGeneric) - flags |= MethodSignatureFlags.Generic; - int arity = header.IsGeneric ? _reader.ReadCompressedInteger() : 0; int count = _reader.ReadCompressedInteger();