diff options
author | Fei Peng <fei.peng@intel.com> | 2017-12-06 20:01:18 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-12-06 23:01:18 -0500 |
commit | ee743a7bd51a327b692a557759c37553ac4760e2 (patch) | |
tree | 9d82762d7fcc57110ca856a8ca98e55a4bfefdf3 /src/ToolBox | |
parent | 688b75c143aa0e080f386a04c74b13b3fc9877bf (diff) | |
download | coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.tar.gz coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.tar.bz2 coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.zip |
new intrinsic type support (#15340)
Diffstat (limited to 'src/ToolBox')
8 files changed, 178 insertions, 1 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h index 5c6dc4fc04..e0a5886e76 100644 --- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h +++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h @@ -271,6 +271,10 @@ CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls); // for completeness const char* getClassName(CORINFO_CLASS_HANDLE cls); +const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName); + +CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index); + // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen // If fNamespace=TRUE, include the namespace/enclosing classes // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters diff --git a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h index b0cb7ad3c8..467d28ac55 100644 --- a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h +++ b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h @@ -68,6 +68,8 @@ LWM(GetClassDomainID, DWORDLONG, DLD) LWM(GetClassGClayout, DWORDLONG, Agnostic_GetClassGClayout) LWM(GetClassModuleIdForStatics, DWORDLONG, Agnostic_GetClassModuleIdForStatics) LWM(GetClassName, DWORDLONG, DWORD) +LWM(GetClassNameFromMetadata, DLD, DD) +LWM(GetTypeInstantiationArgument, DWORDLONG, DWORDLONG) LWM(GetClassNumInstanceFields, DWORDLONG, DWORD) LWM(GetClassSize, DWORDLONG, DWORD) LWM(GetCookieForPInvokeCalliSig, GetCookieForPInvokeCalliSigValue, DLDL) diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index 3a9f48feea..581b2286d8 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -5683,6 +5683,113 @@ const char* MethodContext::repGetClassName(CORINFO_CLASS_HANDLE cls) return name; } +void MethodContext::recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, + char* className, + const char** namespaceName) +{ + if (GetClassNameFromMetadata == nullptr) + GetClassNameFromMetadata = new LightWeightMap<DLD, DD>(); + DD value; + DLD key; + key.A = (DWORDLONG)cls; + key.B = (namespaceName != nullptr); + + if (className != nullptr) + value.A = + GetClassNameFromMetadata->AddBuffer((unsigned char*)className, (DWORD)strlen(className) + 1); + else + value.A = (DWORD)-1; + + if ((namespaceName != nullptr) && (*namespaceName != nullptr)) + value.B = + GetClassNameFromMetadata->AddBuffer((unsigned char*)*namespaceName, (DWORD)strlen(*namespaceName) + 1); + else + value.B = (DWORD)-1; + + GetClassNameFromMetadata->Add(key, value); + DEBUG_REC(dmpGetClassNameFromMetadata(key, value)); +} + +void MethodContext::dmpGetClassNameFromMetadata(DLD key, DD value) +{ + unsigned char* className = (unsigned char*)GetClassNameFromMetadata->GetBuffer(value.A); + unsigned char* namespaceName = (unsigned char*)GetClassNameFromMetadata->GetBuffer(value.B); + printf("GetClassNameFromMetadata key - classNonNull-%u namespaceNonNull-%u, value " + "class-'%s', namespace-'%s'", + key.A, key.B, className, namespaceName); + GetClassNameFromMetadata->Unlock(); +} + +const char* MethodContext::repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) +{ + const char* result = nullptr; + DD value; + DLD key; + key.A = (DWORDLONG)cls; + key.B = (namespaceName != nullptr); + + int itemIndex = -1; + if (GetClassNameFromMetadata != nullptr) + itemIndex = GetClassNameFromMetadata->GetIndex(key); + if (itemIndex < 0) + { + if (namespaceName != nullptr) + { + *namespaceName = nullptr; + } + } + else + { + value = GetClassNameFromMetadata->Get(key); + result = (const char*)GetClassNameFromMetadata->GetBuffer(value.A); + + if (namespaceName != nullptr) + { + *namespaceName = (const char*)GetClassNameFromMetadata->GetBuffer(value.B); + } + } + DEBUG_REP(dmpGetClassNameFromMetadata(key, value)); + return result; +} + +void MethodContext::recGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result, unsigned index) +{ + if (GetTypeInstantiationArgument == nullptr) + GetTypeInstantiationArgument = new LightWeightMap<DWORDLONG, DWORDLONG>(); + + DWORDLONG key = (DWORDLONG)cls; + + GetTypeInstantiationArgument->Add(key, (DWORDLONG)result); + DEBUG_REC(dmpGetTypeInstantiationArgument(key, (DWORDLONG)result)); +} + +void MethodContext::dmpGetTypeInstantiationArgument(DWORDLONG key, DWORDLONG value) +{ + printf("GetTypeInstantiationArgument key - classNonNull-%u, value NonNull-%u", key, value); + GetTypeInstantiationArgument->Unlock(); +} + + +CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) +{ + CORINFO_CLASS_HANDLE result = nullptr; + DWORDLONG value; + DWORDLONG key; + key = (DWORDLONG)cls; + + int itemIndex = -1; + if (GetTypeInstantiationArgument != nullptr) + itemIndex = GetTypeInstantiationArgument->GetIndex(key); + if (itemIndex >= 0) + { + value = GetTypeInstantiationArgument->Get(key); + result = (CORINFO_CLASS_HANDLE)value; + } + + DEBUG_REP(dmpGetTypeInstantiationArgument(key, value)); + return result; +} + void MethodContext::recAppendClassName( CORINFO_CLASS_HANDLE cls, BOOL fNamespace, BOOL fFullInst, BOOL fAssembly, const WCHAR* result) { diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index 582a26ff70..1174f070c7 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -1222,6 +1222,16 @@ public: void dmpGetClassName(DWORDLONG key, DWORD value); const char* repGetClassName(CORINFO_CLASS_HANDLE cls); + void recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, + char* className, + const char** namespaceName); + void dmpGetClassNameFromMetadata(DLD key, DD value); + const char* repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName); + + void recGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result, unsigned index); + void dmpGetTypeInstantiationArgument(DWORDLONG key, DWORDLONG value); + CORINFO_CLASS_HANDLE repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index); + void recAppendClassName( CORINFO_CLASS_HANDLE cls, BOOL fNamespace, BOOL fFullInst, BOOL fAssembly, const WCHAR* result); void dmpAppendClassName(const Agnostic_AppendClassName& key, DWORD value); @@ -1273,7 +1283,7 @@ private: }; // ********************* Please keep this up-to-date to ease adding more *************** -// Highest packet number: 165 +// Highest packet number: 167 // ************************************************************************************* enum mcPackets { @@ -1337,6 +1347,8 @@ enum mcPackets Packet_GetClassGClayout = 43, Packet_GetClassModuleIdForStatics = 44, Packet_GetClassName = 45, + Packet_GetClassNameFromMetadata = 166, // Added 12/4/17 + Packet_GetTypeInstantiationArgument = 167, // Added 12/4/17 Packet_GetClassNumInstanceFields = 46, Packet_GetClassSize = 47, Packet_GetIntConfigValue = 151, // Added 2/12/2015 diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index fe5f5572fb..b6bc4fa8fb 100644 --- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -550,6 +550,22 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls) return result; } +const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) +{ + mc->cr->AddCall("getClassNameFromMetadata"); + const char* temp = original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName); + mc->recGetClassNameFromMetadata(cls, (char*)temp, namespaceName); + return temp; +} + +CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) +{ + mc->cr->AddCall("getTypeInstantiationArgument"); + CORINFO_CLASS_HANDLE temp = original_ICorJitInfo->getTypeInstantiationArgument(cls, index); + mc->recGetTypeInstantiationArgument(cls, temp, index); + return temp; +} + // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen // If fNamespace=TRUE, include the namespace/enclosing classes // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index a9e5761c34..91d6b3388d 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -405,6 +405,18 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls) return original_ICorJitInfo->getClassName(cls); } +const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) +{ + mcs->AddCall("getClassNameFromMetadata"); + return original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName); +} + +CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) +{ + mcs->AddCall("getTypeInstantiationArgument"); + return original_ICorJitInfo->getTypeInstantiationArgument(cls, index); +} + // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen // If fNamespace=TRUE, include the namespace/enclosing classes // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index d7ca029fae..d23f727fd9 100644 --- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -364,6 +364,16 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls) return original_ICorJitInfo->getClassName(cls); } +const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) +{ + return original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName); +} + +CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) +{ + return original_ICorJitInfo->getTypeInstantiationArgument(cls, index); +} + // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen // If fNamespace=TRUE, include the namespace/enclosing classes // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index fc5677cea2..81ff74db71 100644 --- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -436,6 +436,20 @@ const char* MyICJI::getClassName(CORINFO_CLASS_HANDLE cls) return result; } +const char* MyICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName) +{ + jitInstance->mc->cr->AddCall("getClassNameFromMetadata"); + const char* result = jitInstance->mc->repGetClassNameFromMetadata(cls, namespaceName); + return result; +} + +CORINFO_CLASS_HANDLE MyICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index) +{ + jitInstance->mc->cr->AddCall("getTypeInstantiationArgument"); + CORINFO_CLASS_HANDLE result = jitInstance->mc->repGetTypeInstantiationArgument(cls, index); + return result; +} + // Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen // If fNamespace=TRUE, include the namespace/enclosing classes // If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters |