@@ -106,11 +106,13 @@ InterpreterMethodInfo::InterpreterMethodInfo(CEEInfo* comp, CORINFO_METHOD_INFO*
106
106
#endif
107
107
SetFlag<Flag_hasRetBuffArg>(hasRetBuff);
108
108
109
- MetaSig sig (reinterpret_cast <MethodDesc*>(methInfo->ftn ));
109
+ MethodDesc* targetMD = reinterpret_cast <MethodDesc*>(methInfo->ftn );
110
+ MetaSig sig (targetMD);
110
111
SetFlag<Flag_hasGenericsContextArg>((methInfo->args .callConv & CORINFO_CALLCONV_PARAMTYPE) != 0 );
111
112
SetFlag<Flag_isVarArg>((methInfo->args .callConv & CORINFO_CALLCONV_VARARG) != 0 );
112
113
SetFlag<Flag_typeHasGenericArgs>(methInfo->args .sigInst .classInstCount > 0 );
113
114
SetFlag<Flag_methHasGenericArgs>(methInfo->args .sigInst .methInstCount > 0 );
115
+ SetFlag<Flag_unmanagedCallersOnly>(targetMD->HasUnmanagedCallersOnlyAttribute ());
114
116
_ASSERTE_MSG (!GetFlag<Flag_hasGenericsContextArg>()
115
117
|| ((GetFlag<Flag_typeHasGenericArgs>() && !(GetFlag<Flag_hasThisArg>() && GetFlag<Flag_thisArgIsObjPtr>())) || GetFlag<Flag_methHasGenericArgs>()),
116
118
" If the method takes a generic parameter, is a static method of generic class (or meth of a value class), and/or itself takes generic parameters" );
@@ -820,15 +822,15 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
820
822
*ppInterpMethodInfo = interpMethInfo;
821
823
}
822
824
interpMethInfo->m_stubNum = s_interpreterStubNum;
823
- MethodDesc* methodDesc = reinterpret_cast <MethodDesc*>(info->ftn );
824
825
if (!jmpCall)
825
826
{
826
827
interpMethInfo = RecordInterpreterMethodInfoForMethodHandle (info->ftn , interpMethInfo);
827
828
}
828
829
830
+ MethodDesc* pMD = reinterpret_cast <MethodDesc*>(info->ftn );
829
831
#if FEATURE_INTERPRETER_DEADSIMPLE_OPT
830
832
unsigned offsetOfLd;
831
- if (IsDeadSimpleGetter (comp, methodDesc , &offsetOfLd))
833
+ if (IsDeadSimpleGetter (comp, pMD , &offsetOfLd))
832
834
{
833
835
interpMethInfo->SetFlag <InterpreterMethodInfo::Flag_methIsDeadSimpleGetter>(true );
834
836
if (offsetOfLd == ILOffsetOfLdFldInDeadSimpleInstanceGetterDbg)
@@ -892,7 +894,6 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
892
894
// In the IL stub case, which uses eax, it would be problematic to do this sharing.
893
895
894
896
StubLinkerCPU sl;
895
- MethodDesc* pMD = reinterpret_cast <MethodDesc*>(info->ftn );
896
897
if (!jmpCall)
897
898
{
898
899
sl.Init ();
@@ -918,7 +919,7 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
918
919
#endif
919
920
}
920
921
921
- MetaSig sig (methodDesc );
922
+ MetaSig sig (pMD );
922
923
923
924
unsigned totalArgs = info->args .numArgs ;
924
925
unsigned sigArgsPlusThis = totalArgs;
@@ -956,7 +957,7 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
956
957
totalArgs++; sigArgsPlusThis++;
957
958
}
958
959
959
- if (methodDesc ->HasRetBuffArg ())
960
+ if (pMD ->HasRetBuffArg ())
960
961
{
961
962
hasRetBuff = true ;
962
963
retBuffArgIndex = totalArgs;
@@ -1403,7 +1404,9 @@ CorJitResult Interpreter::GenerateInterpreterStub(CEEInfo* comp,
1403
1404
interpretMethodFunc = reinterpret_cast <PCODE>(&InterpretMethodDouble);
1404
1405
break ;
1405
1406
default :
1406
- interpretMethodFunc = reinterpret_cast <PCODE>(&InterpretMethod);
1407
+ interpretMethodFunc = interpMethInfo->GetFlag <InterpreterMethodInfo::Flag_unmanagedCallersOnly>()
1408
+ ? reinterpret_cast <PCODE>(&ReversePInvokeInterpretMethod)
1409
+ : reinterpret_cast <PCODE>(&InterpretMethod);
1407
1410
break ;
1408
1411
}
1409
1412
// The argument registers have been pushed by now, so we can use them.
@@ -1921,6 +1924,18 @@ HCIMPL3(INT64, InterpretMethod, struct InterpreterMethodInfo* interpMethInfo, BY
1921
1924
}
1922
1925
HCIMPLEND
1923
1926
1927
+ // static
1928
+ HCIMPL3_RAW (INT64, ReversePInvokeInterpretMethod, struct InterpreterMethodInfo * interpMethInfo, BYTE* ilArgs, void * stubContext)
1929
+ {
1930
+ FCALL_CONTRACT;
1931
+
1932
+ _ASSERTE (CURRENT_THREAD == NULL || !CURRENT_THREAD->PreemptiveGCDisabled ());
1933
+
1934
+ GCX_COOP ();
1935
+ return HCCALL3 (InterpretMethod, interpMethInfo, ilArgs, stubContext);
1936
+ }
1937
+ HCIMPLEND_RAW
1938
+
1924
1939
bool Interpreter::IsInCalleesFrames (void * stackPtr)
1925
1940
{
1926
1941
// We assume a downwards_growing stack.
0 commit comments