Add SPMI for getTypeForPrimitiveNumericClass
authorFei Peng <fei.peng@intel.com>
Thu, 7 Dec 2017 22:08:55 +0000 (14:08 -0800)
committerFei Peng <fei.peng@intel.com>
Tue, 12 Dec 2017 17:58:21 +0000 (09:58 -0800)
12 files changed:
src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
src/ToolBox/superpmi/superpmi-shared/lwmlist.h
src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
src/ToolBox/superpmi/superpmi-shared/methodcontext.h
src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
src/jit/ICorJitInfo_API_names.h
src/jit/ICorJitInfo_API_wrapper.hpp
src/zap/zapinfo.cpp
src/zap/zapinfo.h

index e0a5886..61d1785 100644 (file)
@@ -430,6 +430,10 @@ CORINFO_CLASS_HANDLE getBuiltinClass(CorInfoClassId classId);
 // "System.Int32" ==> CORINFO_TYPE_INT..
 CorInfoType getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls);
 
+// "System.Int32" ==> CORINFO_TYPE_INT..
+// "System.UInt32" ==> CORINFO_TYPE_UINT..
+CorInfoType getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls);
+
 // TRUE if child is a subtype of parent
 // if parent is an interface, then does child implement / extend parent
 BOOL canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent)
index 467d28a..6a8b77e 100644 (file)
@@ -126,6 +126,7 @@ LWM(GetThreadTLSIndex, DWORD, DLD)
 LWM(GetTokenTypeAsHandle, GetTokenTypeAsHandleValue, DWORDLONG)
 LWM(GetTypeForBox, DWORDLONG, DWORDLONG)
 LWM(GetTypeForPrimitiveValueClass, DWORDLONG, DWORD)
+LWM(GetTypeForPrimitiveNumericClass, DWORDLONG, DWORD)
 LWM(GetUnboxedEntry, DWORDLONG, DLD);
 LWM(GetUnBoxHelper, DWORDLONG, DWORD)
 LWM(GetUnmanagedCallConv, DWORDLONG, DWORD)
index 601f738..4a16baf 100644 (file)
@@ -1916,6 +1916,29 @@ CorInfoType MethodContext::repGetTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE
     return result;
 }
 
+void MethodContext::recGetTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls, CorInfoType result)
+{
+    if (GetTypeForPrimitiveNumericClass == nullptr)
+        GetTypeForPrimitiveNumericClass = new LightWeightMap<DWORDLONG, DWORD>();
+
+    GetTypeForPrimitiveNumericClass->Add((DWORDLONG)cls, result);
+    DEBUG_REC(dmpGetTypeForPrimitiveNumericClass((DWORDLONG)cls, (DWORD)result));
+}
+void MethodContext::dmpGetTypeForPrimitiveNumericClass(DWORDLONG key, DWORD value)
+{
+    printf("GetTypeForPrimitiveNumericClass key cls-%016llX, value cit-%u(%s)", key, value, toString((CorInfoType)value));
+}
+CorInfoType MethodContext::repGetTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls)
+{
+    AssertCodeMsg(GetTypeForPrimitiveNumericClass != nullptr, EXCEPTIONCODE_MC,
+                  "Encountered an empty LWM while looking for %016llX", (DWORDLONG)cls);
+    AssertCodeMsg(GetTypeForPrimitiveNumericClass->GetIndex((DWORDLONG)cls) != -1, EXCEPTIONCODE_MC,
+                  "Didn't find %016llX", (DWORDLONG)cls);
+    CorInfoType result = (CorInfoType)GetTypeForPrimitiveNumericClass->Get((DWORDLONG)cls);
+    DEBUG_REP(dmpGetTypeForPrimitiveNumericClass((DWORDLONG)cls, (DWORD)result));
+    return result;
+}
+
 void MethodContext::recGetParentType(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result)
 {
     if (GetParentType == nullptr)
index 1174f07..abcfd49 100644 (file)
@@ -728,6 +728,10 @@ public:
     void dmpGetTypeForPrimitiveValueClass(DWORDLONG key, DWORD value);
     CorInfoType repGetTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls);
 
+    void recGetTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls, CorInfoType result);
+    void dmpGetTypeForPrimitiveNumericClass(DWORDLONG key, DWORD value);
+    CorInfoType repGetTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls);
+
     void recGetParentType(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result);
     void dmpGetParentType(DWORDLONG key, DWORDLONG value);
     CORINFO_CLASS_HANDLE repGetParentType(CORINFO_CLASS_HANDLE cls);
@@ -1283,7 +1287,7 @@ private:
 };
 
 // ********************* Please keep this up-to-date to ease adding more ***************
-// Highest packet number: 167
+// Highest packet number: 168
 // *************************************************************************************
 enum mcPackets
 {
@@ -1400,6 +1404,7 @@ enum mcPackets
     Packet_GetTokenTypeAsHandle                          = 89,
     Packet_GetTypeForBox                                 = 90,
     Packet_GetTypeForPrimitiveValueClass                 = 91,
+    Packet_GetTypeForPrimitiveNumericClass                 = 168, // Added 12/7/2017
     Packet_GetUnboxedEntry                               = 165, // Added 10/26/17
     Packet_GetUnBoxHelper                                = 92,
     Packet_GetReadyToRunHelper                           = 150, // Added 10/10/2014
index b6bc4fa..d63a8ac 100644 (file)
@@ -906,6 +906,16 @@ CorInfoType interceptor_ICJI::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE
     return temp;
 }
 
+// "System.Int32" ==> CORINFO_TYPE_INT..
+// "System.UInt32" ==> CORINFO_TYPE_UINT..
+CorInfoType interceptor_ICJI::getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls)
+{
+    mc->cr->AddCall("getTypeForPrimitiveNumericClass");
+    CorInfoType temp = original_ICorJitInfo->getTypeForPrimitiveNumericClass(cls);
+    mc->recGetTypeForPrimitiveNumericClass(cls, temp);
+    return temp;
+}
+
 // TRUE if child is a subtype of parent
 // if parent is an interface, then does child implement / extend parent
 BOOL interceptor_ICJI::canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent)
index 91d6b33..1b18072 100644 (file)
@@ -704,6 +704,14 @@ CorInfoType interceptor_ICJI::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE
     return original_ICorJitInfo->getTypeForPrimitiveValueClass(cls);
 }
 
+// "System.Int32" ==> CORINFO_TYPE_INT..
+// "System.UInt32" ==> CORINFO_TYPE_UINT..
+CorInfoType interceptor_ICJI::getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls)
+{
+    mcs->AddCall("getTypeForPrimitiveNumericClass");
+    return original_ICorJitInfo->getTypeForPrimitiveNumericClass(cls);
+}
+
 // TRUE if child is a subtype of parent
 // if parent is an interface, then does child implement / extend parent
 BOOL interceptor_ICJI::canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent)
index d23f727..ac7a6d9 100644 (file)
@@ -629,6 +629,13 @@ CorInfoType interceptor_ICJI::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE
     return original_ICorJitInfo->getTypeForPrimitiveValueClass(cls);
 }
 
+// "System.Int32" ==> CORINFO_TYPE_INT..
+// "System.UInt32" ==> CORINFO_TYPE_UINT..
+CorInfoType interceptor_ICJI::getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls)
+{
+    return original_ICorJitInfo->getTypeForPrimitiveNumericClass(cls);
+}
+
 // TRUE if child is a subtype of parent
 // if parent is an interface, then does child implement / extend parent
 BOOL interceptor_ICJI::canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent)
index 81ff74d..852b114 100644 (file)
@@ -763,6 +763,14 @@ CorInfoType MyICJI::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls)
     return jitInstance->mc->repGetTypeForPrimitiveValueClass(cls);
 }
 
+// "System.Int32" ==> CORINFO_TYPE_INT..
+// "System.UInt32" ==> CORINFO_TYPE_UINT..
+CorInfoType MyICJI::getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls)
+{
+    jitInstance->mc->cr->AddCall("getTypeForPrimitiveNumericClass");
+    return jitInstance->mc->repGetTypeForPrimitiveNumericClass(cls);
+}
+
 // TRUE if child is a subtype of parent
 // if parent is an interface, then does child implement / extend parent
 BOOL MyICJI::canCast(CORINFO_CLASS_HANDLE child, // subtype (extends parent)
index 0a8117d..c9edd54 100644 (file)
@@ -71,6 +71,7 @@ DEF_CLR_API(initClass)
 DEF_CLR_API(classMustBeLoadedBeforeCodeIsRun)
 DEF_CLR_API(getBuiltinClass)
 DEF_CLR_API(getTypeForPrimitiveValueClass)
+DEF_CLR_API(getTypeForPrimitiveNumericClass)
 DEF_CLR_API(canCast)
 DEF_CLR_API(areTypesEquivalent)
 DEF_CLR_API(mergeClasses)
index f298ea9..9eaeb5d 100644 (file)
@@ -675,6 +675,15 @@ CorInfoType WrapICorJitInfo::getTypeForPrimitiveValueClass(
     return temp;
 }
 
+CorInfoType WrapICorJitInfo::getTypeForPrimitiveNumericClass(
+            CORINFO_CLASS_HANDLE        cls)
+{
+    API_ENTER(getTypeForPrimitiveNumericClass);
+    CorInfoType temp = wrapHnd->getTypeForPrimitiveNumericClass(cls);
+    API_LEAVE(getTypeForPrimitiveNumericClass);
+    return temp;
+}
+
 BOOL WrapICorJitInfo::canCast(
             CORINFO_CLASS_HANDLE        child,
             CORINFO_CLASS_HANDLE        parent  )
index 215f4a7..02edde0 100644 (file)
@@ -3106,6 +3106,11 @@ CorInfoType ZapInfo::getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls)
     return m_pEEJitInfo->getTypeForPrimitiveValueClass(cls);
 }
 
+CorInfoType ZapInfo::getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls)
+{
+    return m_pEEJitInfo->getTypeForPrimitiveNumericClass(cls);
+}
+
 BOOL ZapInfo::canCast(CORINFO_CLASS_HANDLE child,
                                 CORINFO_CLASS_HANDLE parent)
 {
index 621ffbd..0e2bf9d 100644 (file)
@@ -573,6 +573,7 @@ public:
     CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl(CORINFO_METHOD_HANDLE methHnd);
     CORINFO_CLASS_HANDLE getBuiltinClass(CorInfoClassId classId);
     CorInfoType getTypeForPrimitiveValueClass(CORINFO_CLASS_HANDLE cls);
+    CorInfoType getTypeForPrimitiveNumericClass(CORINFO_CLASS_HANDLE cls);
     BOOL canCast(CORINFO_CLASS_HANDLE child, CORINFO_CLASS_HANDLE parent);
     BOOL areTypesEquivalent(CORINFO_CLASS_HANDLE cls1, CORINFO_CLASS_HANDLE cls2);
     TypeCompareState compareTypesForCast(CORINFO_CLASS_HANDLE fromClass, CORINFO_CLASS_HANDLE toClass);