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 e0a5886e766208eca58619f48a7a3685349c41e0..61d1785b51c961adc6d5e0d34aafd1de4a703ff4 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 467d28ac55516721fbc385bada6c43719811b6a3..6a8b77e246a45ad5d1ffdd4f30d46860376f8e3b 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 601f73833e02523bbdce4f5d8b20263b4563a1c1..4a16baf5b778c0f505d4215d212767b7d749b0f1 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 1174f070c7d2d3a9f4200ae99ee44550f0cacf73..abcfd4926e70af3000da3242a1b2f9cabfb5d1fb 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 b6bc4fa8fb5fab54655ad70105c3db88d20f9034..d63a8acb90f3362ceff191b55fd4160caeacafd6 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 91d6b3388d52b441490edc007282778452ec223e..1b18072f4128e15ba2434d8a5cbdffb4f913c99f 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 d23f727fd95943a944c69b839886bef107b6c60e..ac7a6d9f30a839bb725fd74f5f03edc93ed97402 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 81ff74db7195d994331599b505d62ae94ad203f1..852b1147e6d2a5c3d24a8566e109b5102ee34c01 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 0a8117da5919555fa602cd0d5420bdb7294b96d3..c9edd544be67f8951b3cbab1fb5b3abd87a374a8 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 f298ea917337afcfe66e10646f0ce82e881e67c6..9eaeb5d179e989f5166809da927b39515c667bfa 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 215f4a736056afe671ba85d2db7a317cd4a23363..02edde0f1784265c953c98081a9cfdb669f96f48 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 621ffbdc30379bd4de19b81e3224ec4eb4c0d667..0e2bf9dcaf11bc6b75b6d0271f4818f52b954f87 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);