Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Merge changes from TFS #13842

Merged
merged 1 commit into from
Sep 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,14 @@ const char* getMethodName(CORINFO_METHOD_HANDLE ftn, /* IN */
const char** moduleName /* OUT */
);

// Return method name as in metadata, or nullptr if there is none,
// and optionally return the class name as in metadata.
// Suitable for non-debugging use.
const char* getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, /* IN */
const char** className, /* OUT */
const char** namespaceName /* OUT */
);

// this function is for debugging only. It returns a value that
// is will always be the same for a given method. It is used
// to implement the 'jitRange' functionality
Expand Down
1 change: 1 addition & 0 deletions src/ToolBox/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ LWM(GetMethodDefFromMethod, DWORDLONG, DWORD)
LWM(GetMethodHash, DWORDLONG, DWORD)
LWM(GetMethodInfo, DWORDLONG, Agnostic_GetMethodInfo)
LWM(GetMethodName, DLD, DD)
LWM(GetMethodNameFromMetadata, DLDD, DDD)
LWM(GetMethodSig, DLDL, Agnostic_CORINFO_SIG_INFO)
LWM(GetMethodSync, DWORDLONG, DLDL)
LWM(GetMethodVTableOffset, DWORDLONG, DDD)
Expand Down
79 changes: 79 additions & 0 deletions src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,85 @@ const char* MethodContext::repGetMethodName(CORINFO_METHOD_HANDLE ftn, const cha
return result;
}


void MethodContext::recGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn,
char* methodName, const char** className, const char **namespaceName)
{
if (GetMethodNameFromMetadata == nullptr)
GetMethodNameFromMetadata = new LightWeightMap<DLDD, DDD>();
DDD value;
DLDD key;
key.A = (DWORDLONG)ftn;
key.B = (className != nullptr);
key.C = (namespaceName != nullptr);

if (methodName != nullptr)
value.A = GetMethodNameFromMetadata->AddBuffer((unsigned char*)methodName, (DWORD)strlen(methodName) + 1);
else
value.A = (DWORD)-1;

if (className != nullptr)
value.B = GetMethodNameFromMetadata->AddBuffer((unsigned char*)*className, (DWORD)strlen(*className) + 1);
else
value.B = (DWORD)-1;

if (namespaceName != nullptr)
value.C = GetMethodNameFromMetadata->AddBuffer((unsigned char*)*namespaceName, (DWORD)strlen(*namespaceName) + 1);
else
value.C = (DWORD)-1;

GetMethodNameFromMetadata->Add(key, value);
DEBUG_REC(dmpGetMethodNameFromMetadata(key, value));
}

void MethodContext::dmpGetMethodNameFromMetadata(DLDD key, DDD 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);
GetMethodNameFromMetadata->Unlock();
}

const char* MethodContext::repGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, const char** moduleName, const char** namespaceName)
{
const char* result = nullptr;
DDD value;
DLDD key;
key.A = (DWORDLONG)ftn;
key.B = (moduleName != nullptr);
key.C = (namespaceName != nullptr);

int itemIndex = -1;
if (GetMethodNameFromMetadata != nullptr)
itemIndex = GetMethodNameFromMetadata->GetIndex(key);
if (itemIndex < 0)
{
if (moduleName != nullptr)
{
*moduleName = nullptr;
}
}
else
{
value = GetMethodNameFromMetadata->Get(key);
result = (const char*)GetMethodNameFromMetadata->GetBuffer(value.A);

if (moduleName != nullptr)
{
*moduleName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.B);
}

if (namespaceName != nullptr)
{
*namespaceName = (const char*)GetMethodNameFromMetadata->GetBuffer(value.C);
}
}
DEBUG_REP(dmpGetMethodNameFromMetadata(key, value));
return result;
}

void MethodContext::recGetJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes, DWORD result)
{
if (GetJitFlags == nullptr)
Expand Down
15 changes: 13 additions & 2 deletions src/ToolBox/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class MethodContext
DWORDLONG A;
DWORD B;
};
struct DLDD
{
DWORDLONG A;
DWORD B;
DWORD C;
};
struct Agnostic_CORINFO_RESOLVED_TOKENin
{
DWORDLONG tokenContext;
Expand Down Expand Up @@ -241,7 +247,7 @@ class MethodContext
{
DWORD A;
DWORD B;
bool C;
DWORD C;
};
struct Agnostic_CanTailCall
{
Expand Down Expand Up @@ -616,6 +622,10 @@ class MethodContext
void dmpGetMethodName(DLD key, DD value);
const char* repGetMethodName(CORINFO_METHOD_HANDLE ftn, const char** moduleName);

void recGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, char* methodname, const char** moduleName, const char** namespaceName);
void dmpGetMethodNameFromMetadata(DLDD key, DDD value);
const char* repGetMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftn, const char** className, const char** namespaceName);

void recGetJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes, DWORD result);
void dmpGetJitFlags(DWORD key, DD value);
DWORD repGetJitFlags(CORJIT_FLAGS* jitFlags, DWORD sizeInBytes);
Expand Down Expand Up @@ -1247,7 +1257,7 @@ class MethodContext
};

// ********************* Please keep this up-to-date to ease adding more ***************
// Highest packet number: 160
// Highest packet number: 161
// *************************************************************************************
enum mcPackets
{
Expand Down Expand Up @@ -1342,6 +1352,7 @@ enum mcPackets
Packet_GetMethodHash = 73,
Packet_GetMethodInfo = 74,
Packet_GetMethodName = 75,
Packet_GetMethodNameFromMetadata = 161, // Added 9/6/17
Packet_GetMethodSig = 76,
Packet_GetMethodSync = 77,
Packet_GetMethodVTableOffset = 78,
Expand Down
11 changes: 11 additions & 0 deletions src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,17 @@ 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 */
)
{
mc->cr->AddCall("getMethodNameFromMetadata");
const char* temp = original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName);
mc->recGetMethodNameFromMetadata(ftn, (char*)temp, className, namespaceName);
return temp;
}

// this function is for debugging only. It returns a value that
// is will always be the same for a given method. It is used
// to implement the 'jitRange' functionality
Expand Down
9 changes: 9 additions & 0 deletions src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,15 @@ 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 */
)
{
mcs->AddCall("getMethodNameFromMetadata");
return original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName);
}

// this function is for debugging only. It returns a value that
// is will always be the same for a given method. It is used
// to implement the 'jitRange' functionality
Expand Down
8 changes: 8 additions & 0 deletions src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,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 */
)
{
return original_ICorJitInfo->getMethodNameFromMetadata(ftn, className, namespaceName);
}

// this function is for debugging only. It returns a value that
// is will always be the same for a given method. It is used
// to implement the 'jitRange' functionality
Expand Down
9 changes: 9 additions & 0 deletions src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,15 @@ 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 */
)
{
jitInstance->mc->cr->AddCall("getMethodNameFromMetadata");
return jitInstance->mc->repGetMethodNameFromMetadata(ftn, className, namespaceName);
}

// this function is for debugging only. It returns a value that
// is will always be the same for a given method. It is used
// to implement the 'jitRange' functionality
Expand Down