Skip to content

Commit de93e0a

Browse files
Update JIT interface to help reduce shared stubs (#118462)
* Update JIT interface to help reduce shared stubs In order to reduce the need for shared stubs, we need some additional information for vararg signatures. * Remove canGetVarArgsHandle * Remove canGetCookieForPInvokeCalliSig
1 parent b5c07d4 commit de93e0a

File tree

22 files changed

+79
-354
lines changed

22 files changed

+79
-354
lines changed

src/coreclr/inc/corinfo.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,12 +3206,6 @@ class ICorDynamicInfo : public ICorStaticInfo
32063206
void** ppIndirection = NULL
32073207
) = 0;
32083208

3209-
// returns true if a VM cookie can be generated for it (might be false due to cross-module
3210-
// inlining, in which case the inlining should be aborted)
3211-
virtual bool canGetCookieForPInvokeCalliSig(
3212-
CORINFO_SIG_INFO* szMetaSig
3213-
) = 0;
3214-
32153209
// Generate a cookie based on the signature to pass to INTOP_CALLI in the interpreter.
32163210
virtual void* GetCookieForInterpreterCalliSig(
32173211
CORINFO_SIG_INFO* szMetaSig) = 0;
@@ -3297,15 +3291,10 @@ class ICorDynamicInfo : public ICorStaticInfo
32973291
// registers a vararg sig & returns a VM cookie for it (which can contain other stuff)
32983292
virtual CORINFO_VARARGS_HANDLE getVarArgsHandle(
32993293
CORINFO_SIG_INFO *pSig,
3294+
CORINFO_METHOD_HANDLE methHnd,
33003295
void **ppIndirection = NULL
33013296
) = 0;
33023297

3303-
// returns true if a VM cookie can be generated for it (might be false due to cross-module
3304-
// inlining, in which case the inlining should be aborted)
3305-
virtual bool canGetVarArgsHandle(
3306-
CORINFO_SIG_INFO *pSig
3307-
) = 0;
3308-
33093298
// Allocate a string literal on the heap and return a handle to it
33103299
virtual InfoAccessType constructStringLiteral(
33113300
CORINFO_MODULE_HANDLE module,

src/coreclr/inc/icorjitinfoimpl_generated.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,6 @@ void* GetCookieForPInvokeCalliSig(
590590
void* GetCookieForInterpreterCalliSig(
591591
CORINFO_SIG_INFO* szMetaSig) override;
592592

593-
bool canGetCookieForPInvokeCalliSig(
594-
CORINFO_SIG_INFO* szMetaSig) override;
595-
596593
CORINFO_JUST_MY_CODE_HANDLE getJustMyCodeHandle(
597594
CORINFO_METHOD_HANDLE method,
598595
CORINFO_JUST_MY_CODE_HANDLE** ppIndirection) override;
@@ -628,11 +625,9 @@ CORINFO_CLASS_HANDLE getStaticFieldCurrentClass(
628625

629626
CORINFO_VARARGS_HANDLE getVarArgsHandle(
630627
CORINFO_SIG_INFO* pSig,
628+
CORINFO_METHOD_HANDLE methHnd,
631629
void** ppIndirection) override;
632630

633-
bool canGetVarArgsHandle(
634-
CORINFO_SIG_INFO* pSig) override;
635-
636631
InfoAccessType constructStringLiteral(
637632
CORINFO_MODULE_HANDLE module,
638633
mdToken metaTok,

src/coreclr/inc/jiteeversionguid.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737

3838
#include <minipal/guid.h>
3939

40-
constexpr GUID JITEEVersionIdentifier = { /* fafeaf26-740f-4e0a-b3f4-852fb3d5ccae */
41-
0xfafeaf26,
42-
0x740f,
43-
0x4e0a,
44-
{0xb3, 0xf4, 0x85, 0x2f, 0xb3, 0xd5, 0xcc, 0xae}
40+
constexpr GUID JITEEVersionIdentifier = { /* 7a8cbc56-9e19-4321-80b9-a0d2c578c945 */
41+
0x7a8cbc56,
42+
0x9e19,
43+
0x4321,
44+
{0x80, 0xb9, 0xa0, 0xd2, 0xc5, 0x78, 0xc9, 0x45}
4545
};
4646

4747
#endif // JIT_EE_VERSIONING_GUID_H

src/coreclr/jit/ICorJitInfo_names_generated.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ DEF_CLR_API(getLocationOfThisType)
146146
DEF_CLR_API(getAddressOfPInvokeTarget)
147147
DEF_CLR_API(GetCookieForPInvokeCalliSig)
148148
DEF_CLR_API(GetCookieForInterpreterCalliSig)
149-
DEF_CLR_API(canGetCookieForPInvokeCalliSig)
150149
DEF_CLR_API(getJustMyCodeHandle)
151150
DEF_CLR_API(GetProfilingHandle)
152151
DEF_CLR_API(getCallInfo)
153152
DEF_CLR_API(getStaticFieldContent)
154153
DEF_CLR_API(getObjectContent)
155154
DEF_CLR_API(getStaticFieldCurrentClass)
156155
DEF_CLR_API(getVarArgsHandle)
157-
DEF_CLR_API(canGetVarArgsHandle)
158156
DEF_CLR_API(constructStringLiteral)
159157
DEF_CLR_API(emptyStringLiteral)
160158
DEF_CLR_API(getFieldThreadLocalStoreID)

src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,15 +1396,6 @@ void* WrapICorJitInfo::GetCookieForInterpreterCalliSig(
13961396
return temp;
13971397
}
13981398

1399-
bool WrapICorJitInfo::canGetCookieForPInvokeCalliSig(
1400-
CORINFO_SIG_INFO* szMetaSig)
1401-
{
1402-
API_ENTER(canGetCookieForPInvokeCalliSig);
1403-
bool temp = wrapHnd->canGetCookieForPInvokeCalliSig(szMetaSig);
1404-
API_LEAVE(canGetCookieForPInvokeCalliSig);
1405-
return temp;
1406-
}
1407-
14081399
CORINFO_JUST_MY_CODE_HANDLE WrapICorJitInfo::getJustMyCodeHandle(
14091400
CORINFO_METHOD_HANDLE method,
14101401
CORINFO_JUST_MY_CODE_HANDLE** ppIndirection)
@@ -1474,23 +1465,15 @@ CORINFO_CLASS_HANDLE WrapICorJitInfo::getStaticFieldCurrentClass(
14741465

14751466
CORINFO_VARARGS_HANDLE WrapICorJitInfo::getVarArgsHandle(
14761467
CORINFO_SIG_INFO* pSig,
1468+
CORINFO_METHOD_HANDLE methHnd,
14771469
void** ppIndirection)
14781470
{
14791471
API_ENTER(getVarArgsHandle);
1480-
CORINFO_VARARGS_HANDLE temp = wrapHnd->getVarArgsHandle(pSig, ppIndirection);
1472+
CORINFO_VARARGS_HANDLE temp = wrapHnd->getVarArgsHandle(pSig, methHnd, ppIndirection);
14811473
API_LEAVE(getVarArgsHandle);
14821474
return temp;
14831475
}
14841476

1485-
bool WrapICorJitInfo::canGetVarArgsHandle(
1486-
CORINFO_SIG_INFO* pSig)
1487-
{
1488-
API_ENTER(canGetVarArgsHandle);
1489-
bool temp = wrapHnd->canGetVarArgsHandle(pSig);
1490-
API_LEAVE(canGetVarArgsHandle);
1491-
return temp;
1492-
}
1493-
14941477
InfoAccessType WrapICorJitInfo::constructStringLiteral(
14951478
CORINFO_MODULE_HANDLE module,
14961479
mdToken metaTok,

src/coreclr/jit/importercalls.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -652,24 +652,6 @@ var_types Compiler::impImportCall(OPCODE opcode,
652652
else if ((opcode == CEE_CALLI) && ((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_DEFAULT) &&
653653
((sig->callConv & CORINFO_CALLCONV_MASK) != CORINFO_CALLCONV_VARARG))
654654
{
655-
if (!info.compCompHnd->canGetCookieForPInvokeCalliSig(sig))
656-
{
657-
// Normally this only happens with inlining.
658-
// However, a generic method (or type) being NGENd into another module
659-
// can run into this issue as well. There's not an easy fall-back for AOT
660-
// so instead we fallback to JIT.
661-
if (compIsForInlining())
662-
{
663-
compInlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_EMBED_PINVOKE_COOKIE);
664-
}
665-
else
666-
{
667-
IMPL_LIMITATION("Can't get PInvoke cookie (cross module generics)");
668-
}
669-
670-
return TYP_UNDEF;
671-
}
672-
673655
GenTree* cookie = eeGetPInvokeCookie(sig);
674656

675657
// This cookie is required to be either a simple GT_CNS_INT or
@@ -766,13 +748,7 @@ var_types Compiler::impImportCall(OPCODE opcode,
766748
if ((sig->callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG)
767749
{
768750
void *varCookie, *pVarCookie;
769-
if (!info.compCompHnd->canGetVarArgsHandle(sig))
770-
{
771-
compInlineResult->NoteFatal(InlineObservation::CALLSITE_CANT_EMBED_VARARGS_COOKIE);
772-
return TYP_UNDEF;
773-
}
774-
775-
varCookie = info.compCompHnd->getVarArgsHandle(sig, &pVarCookie);
751+
varCookie = info.compCompHnd->getVarArgsHandle(sig, methHnd, &pVarCookie);
776752
assert((!varCookie) != (!pVarCookie));
777753
varArgsCookie = gtNewIconEmbHndNode(varCookie, pVarCookie, GTF_ICON_VARG_HDL, sig);
778754
}

src/coreclr/jit/inline.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ INLINE_OBSERVATION(ARG_HAS_NULL_THIS, bool, "this pointer argument is
128128
INLINE_OBSERVATION(ARG_NO_BASH_TO_INT, bool, "argument can't bash to int", FATAL, CALLSITE)
129129
INLINE_OBSERVATION(ARG_NO_BASH_TO_REF, bool, "argument can't bash to ref", FATAL, CALLSITE)
130130
INLINE_OBSERVATION(ARG_TYPES_INCOMPATIBLE, bool, "argument types incompatible", FATAL, CALLSITE)
131-
INLINE_OBSERVATION(CANT_EMBED_PINVOKE_COOKIE, bool, "can't embed pinvoke cookie", FATAL, CALLSITE)
132-
INLINE_OBSERVATION(CANT_EMBED_VARARGS_COOKIE, bool, "can't embed varargs cookie", FATAL, CALLSITE)
133131
INLINE_OBSERVATION(CANT_CLASS_INIT, bool, "can't class init", FATAL, CALLSITE)
134132
INLINE_OBSERVATION(COMPILATION_ERROR, bool, "compilation error", FATAL, CALLSITE)
135133
INLINE_OBSERVATION(COMPILATION_FAILURE, bool, "failed to compile", FATAL, CALLSITE)

src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,7 +3638,13 @@ private void getLocationOfThisType(CORINFO_METHOD_STRUCT_* context, ref CORINFO_
36383638
{ throw new NotImplementedException("GetCookieForInterpreterCalliSig"); }
36393639

36403640
private void* GetCookieForPInvokeCalliSig(CORINFO_SIG_INFO* szMetaSig, ref void* ppIndirection)
3641-
{ throw new NotImplementedException("GetCookieForPInvokeCalliSig"); }
3641+
{
3642+
#if READYTORUN
3643+
throw new RequiresRuntimeJitException($"{MethodBeingCompiled} -> {nameof(GetCookieForPInvokeCalliSig)}");
3644+
#else
3645+
throw new NotImplementedException(nameof(GetCookieForPInvokeCalliSig));
3646+
#endif
3647+
}
36423648
#pragma warning disable CA1822 // Mark members as static
36433649
private CORINFO_JUST_MY_CODE_HANDLE_* getJustMyCodeHandle(CORINFO_METHOD_STRUCT_* method, ref CORINFO_JUST_MY_CODE_HANDLE_* ppIndirection)
36443650
#pragma warning restore CA1822 // Mark members as static
@@ -3668,10 +3674,8 @@ private CORINFO_CONST_LOOKUP CreateConstLookupToSymbol(ISymbolNode symbol)
36683674
return null;
36693675
}
36703676

3671-
private IntPtr getVarArgsHandle(CORINFO_SIG_INFO* pSig, ref void* ppIndirection)
3677+
private IntPtr getVarArgsHandle(CORINFO_SIG_INFO* pSig, CORINFO_METHOD_STRUCT_* methHnd, ref void* ppIndirection)
36723678
{ throw new NotImplementedException("getVarArgsHandle"); }
3673-
private bool canGetVarArgsHandle(CORINFO_SIG_INFO* pSig)
3674-
{ throw new NotImplementedException("canGetVarArgsHandle"); }
36753679

36763680
private InfoAccessType emptyStringLiteral(ref void* ppValue)
36773681
{

0 commit comments

Comments
 (0)