Add SuperPMI code for the new getMethodNameFromMetadata
authorFei Peng <fei.peng@intel.com>
Thu, 29 Nov 2018 23:02:24 +0000 (15:02 -0800)
committerFei Peng <fei.peng@intel.com>
Thu, 29 Nov 2018 23:02:56 +0000 (15:02 -0800)
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

index 73a8d28..b6a66a3 100644 (file)
@@ -716,7 +716,8 @@ const char* getMethodName(CORINFO_METHOD_HANDLE ftn,       /* IN */
 // Suitable for non-debugging use.
 const char* getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,       /* IN */
                                       const char**          className, /* OUT */
-                                      const char**          namespaceName /* OUT */
+                                      const char**          namespaceName, /* OUT */
+                                      const char**          enclosingClassName /* OUT */
                                       );
 
 // this function is for debugging only.  It returns a value that
index a50e9b6..137fbe1 100644 (file)
@@ -109,7 +109,7 @@ LWM(GetMethodDefFromMethod, DWORDLONG, DWORD)
 LWM(GetMethodHash, DWORDLONG, DWORD)
 LWM(GetMethodInfo, DWORDLONG, Agnostic_GetMethodInfo)
 LWM(GetMethodName, DLD, DD)
-LWM(GetMethodNameFromMetadata, DLDD, DDD)
+LWM(GetMethodNameFromMetadata, Agnostic_CORINFO_METHODNAME_TOKENin, Agnostic_CORINFO_METHODNAME_TOKENout)
 LWM(GetMethodSig, DLDL, Agnostic_CORINFO_SIG_INFO)
 LWM(GetMethodSync, DWORDLONG, DLDL)
 LWM(GetMethodVTableOffset, DWORDLONG, DDD)
index 11c7336..4883dd4 100644 (file)
@@ -1001,57 +1001,68 @@ const char* MethodContext::repGetMethodName(CORINFO_METHOD_HANDLE ftn, const cha
 void MethodContext::recGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,
                                                  char*                 methodName,
                                                  const char**          className,
-                                                 const char**          namespaceName)
+                                                 const char**          namespaceName,
+                                                 const char**          enclosingClassName)
 {
     if (GetMethodNameFromMetadata == nullptr)
-        GetMethodNameFromMetadata = new LightWeightMap<DLDD, DDD>();
-    DDD  value;
-    DLDD key;
-    key.A = (DWORDLONG)ftn;
-    key.B = (className != nullptr);
-    key.C = (namespaceName != nullptr);
+        GetMethodNameFromMetadata = new LightWeightMap<Agnostic_CORINFO_METHODNAME_TOKENin, Agnostic_CORINFO_METHODNAME_TOKENout>();
+    Agnostic_CORINFO_METHODNAME_TOKENout  value;
+    Agnostic_CORINFO_METHODNAME_TOKENin key;
+    key.ftn = (DWORDLONG)ftn;
+    key.className = (className != nullptr);
+    key.namespaceName = (namespaceName != nullptr);
+    key.enclosingClassName = (enclosingClassName != nullptr);
 
     if (methodName != nullptr)
-        value.A = GetMethodNameFromMetadata->AddBuffer((unsigned char*)methodName, (DWORD)strlen(methodName) + 1);
+        value.methodName = GetMethodNameFromMetadata->AddBuffer((unsigned char*)methodName, (DWORD)strlen(methodName) + 1);
     else
-        value.A = (DWORD)-1;
+        value.methodName = (DWORD)-1;
 
     if ((className != nullptr) && (*className != nullptr))
-        value.B = GetMethodNameFromMetadata->AddBuffer((unsigned char*)*className, (DWORD)strlen(*className) + 1);
+        value.className = GetMethodNameFromMetadata->AddBuffer((unsigned char*)*className, (DWORD)strlen(*className) + 1);
     else
-        value.B = (DWORD)-1;
+        value.className = (DWORD)-1;
 
     if ((namespaceName != nullptr) && (*namespaceName != nullptr))
-        value.C =
+        value.namespaceName =
             GetMethodNameFromMetadata->AddBuffer((unsigned char*)*namespaceName, (DWORD)strlen(*namespaceName) + 1);
     else
-        value.C = (DWORD)-1;
+        value.namespaceName = (DWORD)-1;
+
+    if ((enclosingClassName != nullptr) && (*enclosingClassName != nullptr))
+        value.enclosingClassName =
+            GetMethodNameFromMetadata->AddBuffer((unsigned char*)*enclosingClassName, (DWORD)strlen(*enclosingClassName) + 1);
+    else
+        value.enclosingClassName = (DWORD)-1;
 
     GetMethodNameFromMetadata->Add(key, value);
     DEBUG_REC(dmpGetMethodNameFromMetadata(key, value));
 }
 
-void MethodContext::dmpGetMethodNameFromMetadata(DLDD key, DDD value)
+void MethodContext::dmpGetMethodNameFromMetadata(Agnostic_CORINFO_METHODNAME_TOKENin key, Agnostic_CORINFO_METHODNAME_TOKENout value)
 {
-    unsigned char* methodName    = (unsigned char*)GetMethodName->GetBuffer(value.A);
-    unsigned char* className     = (unsigned char*)GetMethodName->GetBuffer(value.B);
-    unsigned char* namespaceName = (unsigned char*)GetMethodName->GetBuffer(value.C);
-    printf("GetMethodNameFromMetadata key - ftn-%016llX classNonNull-%u namespaceNonNull-%u, value meth-'%s', "
-           "class-'%s', namespace-'%s'",
-           key.A, key.B, key.C, methodName, className, namespaceName);
+    unsigned char* methodName    = (unsigned char*)GetMethodName->GetBuffer(value.methodName);
+    unsigned char* className     = (unsigned char*)GetMethodName->GetBuffer(value.className);
+    unsigned char* namespaceName = (unsigned char*)GetMethodName->GetBuffer(value.namespaceName);
+    unsigned char* enclosingClassName = (unsigned char*)GetMethodName->GetBuffer(value.enclosingClassName);
+    printf("GetMethodNameFromMetadata key - ftn-%016llX classNonNull-%u namespaceNonNull-%u nclosingClassNonNull-%u, value meth-'%s', "
+           "class-'%s', namespace-'%s' enclosingClass-'%s'",
+           key.ftn, key.className, key.namespaceName, key.enclosingClassName, methodName, className, namespaceName, enclosingClassName);
     GetMethodNameFromMetadata->Unlock();
 }
 
 const char* MethodContext::repGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,
                                                         const char**          moduleName,
-                                                        const char**          namespaceName)
+                                                        const char**          namespaceName,
+                                                        const char**          enclosingClassName)
 {
     const char* result = nullptr;
-    DDD         value;
-    DLDD        key;
-    key.A = (DWORDLONG)ftn;
-    key.B = (moduleName != nullptr);
-    key.C = (namespaceName != nullptr);
+    Agnostic_CORINFO_METHODNAME_TOKENout value;
+    Agnostic_CORINFO_METHODNAME_TOKENin key;
+    key.ftn = (DWORDLONG)ftn;
+    key.className = (moduleName != nullptr);
+    key.namespaceName = (namespaceName != nullptr);
+    key.enclosingClassName = (enclosingClassName != nullptr);
 
     int itemIndex = -1;
     if (GetMethodNameFromMetadata != nullptr)
@@ -1066,16 +1077,21 @@ const char* MethodContext::repGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ft
     else
     {
         value  = GetMethodNameFromMetadata->Get(key);
-        result = (const char*)GetMethodNameFromMetadata->GetBuffer(value.A);
+        result = (const char*)GetMethodNameFromMetadata->GetBuffer(value.methodName);
 
         if (moduleName != nullptr)
         {
-            *moduleName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.B);
+            *moduleName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.className);
         }
 
         if (namespaceName != nullptr)
         {
-            *namespaceName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.C);
+            *namespaceName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.namespaceName);
+        }
+
+        if (enclosingClassName != nullptr)
+        {
+            *enclosingClassName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.enclosingClassName);
         }
     }
     DEBUG_REP(dmpGetMethodNameFromMetadata(key, value));
index cde16ad..115cd41 100644 (file)
@@ -95,6 +95,20 @@ public:
         DWORD     B;
         DWORD     C;
     };
+    struct Agnostic_CORINFO_METHODNAME_TOKENin
+    {
+        DWORDLONG ftn;
+        DWORD     className;
+        DWORD     namespaceName;
+        DWORD     enclosingClassName;
+    };
+    struct Agnostic_CORINFO_METHODNAME_TOKENout
+    {
+        DWORD methodName;
+        DWORD className;
+        DWORD namespaceName;
+        DWORD enclosingClassName;
+    };
     struct Agnostic_CORINFO_RESOLVED_TOKENin
     {
         DWORDLONG tokenContext;
@@ -625,11 +639,13 @@ public:
     void recGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,
                                       char*                 methodname,
                                       const char**          moduleName,
-                                      const char**          namespaceName);
-    void dmpGetMethodNameFromMetadata(DLDD key, DDD value);
+                                      const char**          namespaceName,
+                                      const char**          enclosingClassName);
+    void dmpGetMethodNameFromMetadata(Agnostic_CORINFO_METHODNAME_TOKENin key, Agnostic_CORINFO_METHODNAME_TOKENout value);
     const char* repGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,
                                              const char**          className,
-                                             const char**          namespaceName);
+                                             const char**          namespaceName,
+                                             const char**          enclosingClassName);
 
     void recGetJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes, DWORD result);
     void dmpGetJitFlags(DWORD key, DD value);
index 1b1ba5d..898f824 100644 (file)
@@ -1481,14 +1481,15 @@ const char* interceptor_ICJI::getMethodName(CORINFO_METHOD_HANDLE ftn,       /*
     return temp;
 }
 
-const char* interceptor_ICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,          /* IN */
-                                                        const char**          className,    /* OUT */
-                                                        const char**          namespaceName /* OUT */
+const char* interceptor_ICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,                  /* IN */
+                                                        const char**          className,            /* OUT */
+                                                        const char**          namespaceName,        /* OUT */
+                                                        const char**          enclosingClassName   /* OUT */
                                                         )
 {
     mc->cr->AddCall("getMethodNameFromMetadata");
-    const char* temp = original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName);
-    mc->recGetMethodNameFromMetadata(ftn, (char*)temp, className, namespaceName);
+    const char* temp = original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName, enclosingClassName);
+    mc->recGetMethodNameFromMetadata(ftn, (char*)temp, className, namespaceName, enclosingClassName);
     return temp;
 }
 
index c8002f5..3348479 100644 (file)
@@ -1153,13 +1153,14 @@ const char* interceptor_ICJI::getMethodName(CORINFO_METHOD_HANDLE ftn,       /*
     return original_ICorJitInfo->getMethodName(ftn, moduleName);
 }
 
-const char* interceptor_ICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,          /* IN */
-                                                        const char**          className,    /* OUT */
-                                                        const char**          namespaceName /* OUT */
+const char* interceptor_ICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,                /* IN */
+                                                        const char**          className,          /* OUT */
+                                                        const char**          namespaceName,      /* OUT */
+                                                        const char**          enclosingClassName /* OUT */
                                                         )
 {
     mcs->AddCall("getMethodNameFromMetadata");
-    return original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName);
+    return original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName, enclosingClassName);
 }
 
 // this function is for debugging only.  It returns a value that
index 1bdd3b7..b5a18f8 100644 (file)
@@ -1037,12 +1037,13 @@ const char* interceptor_ICJI::getMethodName(CORINFO_METHOD_HANDLE ftn,       /*
     return original_ICorJitInfo->getMethodName(ftn, moduleName);
 }
 
-const char* interceptor_ICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,          /* IN */
-                                                        const char**          className,    /* OUT */
-                                                        const char**          namespaceName /* OUT */
+const char* interceptor_ICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,                /* IN */
+                                                        const char**          className,          /* OUT */
+                                                        const char**          namespaceName,      /* OUT */
+                                                        const char**          enclosingClassName /* OUT */
                                                         )
 {
-    return original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName);
+    return original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName, enclosingClassName);
 }
 
 // this function is for debugging only.  It returns a value that
index d6d4d6e..bf60a9a 100644 (file)
@@ -1259,13 +1259,14 @@ const char* MyICJI::getMethodName(CORINFO_METHOD_HANDLE ftn,       /* IN */
     return jitInstance->mc->repGetMethodName(ftn, moduleName);
 }
 
-const char* MyICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,          /* IN */
-                                              const char**          className,    /* OUT */
-                                              const char**          namespaceName /* OUT */
+const char* MyICJI::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,                /* IN */
+                                              const char**          className,          /* OUT */
+                                              const char**          namespaceName,      /* OUT */
+                                              const char**          enclosingClassName /* OUT */
                                               )
 {
     jitInstance->mc->cr->AddCall("getMethodNameFromMetadata");
-    return jitInstance->mc->repGetMethodNameFromMetadata(ftn, className, namespaceName);
+    return jitInstance->mc->repGetMethodNameFromMetadata(ftn, className, namespaceName, enclosingClassName);
 }
 
 // this function is for debugging only.  It returns a value that