summaryrefslogtreecommitdiff
path: root/src/ToolBox
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2018-06-19 05:58:44 -0700
committerGitHub <noreply@github.com>2018-06-19 05:58:44 -0700
commit10111af6ba5e18f4a9b9c6eb80d49ed545604cfa (patch)
tree83b8f6dd6f8604165d2856a14008d11c6bb3119a /src/ToolBox
parent57375e5cd91b3554e0e9690bba56d7fc341f8ce7 (diff)
downloadcoreclr-10111af6ba5e18f4a9b9c6eb80d49ed545604cfa.tar.gz
coreclr-10111af6ba5e18f4a9b9c6eb80d49ed545604cfa.tar.bz2
coreclr-10111af6ba5e18f4a9b9c6eb80d49ed545604cfa.zip
PInvoke calli support for CoreRT (#18534)
* Ifdef out NGen-specific PInvoke calli inlining limitation for CoreCLR This limitation seems to be a left-over from effort to eliminate JITing with fragile NGen. * Delete dead partial-trust related code * Allow PInvoke stub inlining * Add convertCalliToCall JIT/EE interface method * Update superpmi
Diffstat (limited to 'src/ToolBox')
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h2
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/lwmlist.h1
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp35
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/methodcontext.h5
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp8
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp6
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp5
-rw-r--r--src/ToolBox/superpmi/superpmi/icorjitinfo.cpp6
8 files changed, 68 insertions, 0 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
index 61d1785b51..6645626c24 100644
--- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
+++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
@@ -906,6 +906,8 @@ void MethodCompileComplete(CORINFO_METHOD_HANDLE methHnd);
// return a thunk that will copy the arguments for the given signature.
void* getTailCallCopyArgsThunk(CORINFO_SIG_INFO* pSig, CorInfoHelperTailCallSpecialHandling flags);
+bool convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert);
+
// return memory manager that the JIT can use to allocate a regular memory
IEEMemoryManager* getMemoryManager();
diff --git a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
index 6a8b77e246..df9f43587a 100644
--- a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
+++ b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
@@ -35,6 +35,7 @@ LWM(CompareTypesForCast, DLDL, DWORD)
LWM(CompareTypesForEquality, DLDL, DWORD)
LWM(CompileMethod, DWORD, Agnostic_CompileMethod)
LWM(ConstructStringLiteral, DLD, DLD)
+LWM(ConvertPInvokeCalliToCall, DLD, DWORDLONG)
LWM(EmbedClassHandle, DWORDLONG, DLDL)
LWM(EmbedFieldHandle, DWORDLONG, DLDL)
LWM(EmbedGenericHandle, Agnostic_EmbedGenericHandle, Agnostic_CORINFO_GENERICHANDLE_RESULT)
diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
index aa806c31df..b5de52feaf 100644
--- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
+++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
@@ -2436,6 +2436,41 @@ InfoAccessType MethodContext::repConstructStringLiteral(CORINFO_MODULE_HANDLE mo
return (InfoAccessType)temp2.B;
}
+void MethodContext::recConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert, bool result)
+{
+ if (ConvertPInvokeCalliToCall == nullptr)
+ ConvertPInvokeCalliToCall = new LightWeightMap<DLD, DWORDLONG>();
+
+ DLD key;
+ ZeroMemory(&key, sizeof(DLD)); // We use the input structs as a key and use memcmp to compare.. so we need to zero
+ // out padding too
+ key.A = (DWORDLONG)pResolvedToken->tokenScope;
+ key.B = (DWORD)pResolvedToken->token;
+
+ DWORDLONG value = (DWORDLONG)(result ? pResolvedToken->hMethod : 0);
+
+ ConvertPInvokeCalliToCall->Add(key, value);
+ DEBUG_REC(dmpConvertPInvokeCalliToCall(key, value));
+}
+void MethodContext::dmpConvertPInvokeCalliToCall(DLD key, DWORDLONG value)
+{
+ printf("ConvertPInvokeCalliToCall key mod-%016llX tok-%08X, value %016llX", key.A, key.B, value);
+}
+bool MethodContext::repConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert)
+{
+ DLD key;
+ ZeroMemory(&key, sizeof(DLD)); // We use the input structs as a key and use memcmp to compare.. so we need to zero
+ // out padding too
+ key.A = (DWORDLONG)pResolvedToken->tokenScope;
+ key.B = (DWORD)pResolvedToken->token;
+
+ DWORDLONG value = ConvertPInvokeCalliToCall->Get(key);
+ DEBUG_REP(dmpGetArgType(key, value));
+
+ pResolvedToken->hMethod = (CORINFO_METHOD_HANDLE)value;
+ return value != 0;
+}
+
void MethodContext::recEmptyStringLiteral(void** pValue, InfoAccessType result)
{
if (EmptyStringLiteral == nullptr)
diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
index b7f19a345a..ac7acf1ea1 100644
--- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
+++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
@@ -805,6 +805,10 @@ public:
void dmpConstructStringLiteral(DLD key, DLD value);
InfoAccessType repConstructStringLiteral(CORINFO_MODULE_HANDLE module, mdToken metaTok, void** ppValue);
+ void recConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert, bool result);
+ void dmpConvertPInvokeCalliToCall(DLD key, DWORDLONG value);
+ bool repConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert);
+
void recEmptyStringLiteral(void** ppValue, InfoAccessType result);
void dmpEmptyStringLiteral(DWORD key, DLD value);
InfoAccessType repEmptyStringLiteral(void** ppValue);
@@ -1311,6 +1315,7 @@ enum mcPackets
Packet_CompareTypesForEquality = 164, // Added 10/4/17
Packet_CompileMethod = 143, // retired as 141 on 2013/07/09
Packet_ConstructStringLiteral = 15,
+ Packet_ConvertPInvokeCalliToCall = 169, // Added 4/29/18
Packet_EmbedClassHandle = 16,
Packet_EmbedFieldHandle = 17,
Packet_EmbedGenericHandle = 18,
diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
index d63a8acb90..5d70a5488f 100644
--- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
@@ -1825,6 +1825,14 @@ InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE mo
return temp;
}
+bool interceptor_ICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert)
+{
+ mc->cr->AddCall("convertPInvokeCalliToCall");
+ bool result = original_ICorJitInfo->convertPInvokeCalliToCall(pResolvedToken, fMustConvert);
+ mc->recConvertPInvokeCalliToCall(pResolvedToken, fMustConvert, result);
+ return result;
+}
+
InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue)
{
mc->cr->AddCall("emptyStringLiteral");
diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
index 1b18072f41..316fd8c1ed 100644
--- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
@@ -1412,6 +1412,12 @@ InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE mo
return original_ICorJitInfo->constructStringLiteral(module, metaTok, ppValue);
}
+bool interceptor_ICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert)
+{
+ mcs->AddCall("convertPInvokeCalliToCall");
+ return original_ICorJitInfo->convertPInvokeCalliToCall(pResolvedToken, fMustConvert);
+}
+
InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue)
{
mcs->AddCall("emptyStringLiteral");
diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
index ac7a6d9f30..97c434755e 100644
--- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
@@ -1266,6 +1266,11 @@ InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE mo
return original_ICorJitInfo->constructStringLiteral(module, metaTok, ppValue);
}
+bool interceptor_ICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert)
+{
+ return original_ICorJitInfo->convertPInvokeCalliToCall(pResolvedToken, fMustConvert);
+}
+
InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue)
{
return original_ICorJitInfo->emptyStringLiteral(ppValue);
diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
index 852b1147e6..43ac5a8502 100644
--- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
@@ -1580,6 +1580,12 @@ void* MyICJI::getTailCallCopyArgsThunk(CORINFO_SIG_INFO* pSig, CorInfoHelperTail
return jitInstance->mc->repGetTailCallCopyArgsThunk(pSig, flags);
}
+bool MyICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert)
+{
+ jitInstance->mc->cr->AddCall("convertPInvokeCalliToCall");
+ return jitInstance->mc->repConvertPInvokeCalliToCall(pResolvedToken, fMustConvert);
+}
+
// Stuff directly on ICorJitInfo
// Returns extended flags for a particular compilation instance.