Skip to content
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
3 changes: 3 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ LWM(GetLazyStringLiteralHelper, DWORDLONG, DWORD)
LWM(GetLikelyClass, Agnostic_GetLikelyClass, Agnostic_GetLikelyClassResult)
LWM(GetLocationOfThisType, DWORDLONG, Agnostic_CORINFO_LOOKUP_KIND)
LWM(GetMethodAttribs, DWORDLONG, DWORD)
LWM(GetClassModule, DWORDLONG, DWORDLONG)
LWM(GetModuleAssembly, DWORDLONG, DWORDLONG)
LWM(GetAssemblyName, DWORDLONG, DWORD)
LWM(GetMethodClass, DWORDLONG, DWORDLONG)
LWM(GetMethodModule, DWORDLONG, DWORDLONG)
LWM(GetMethodDefFromMethod, DWORDLONG, DWORD)
Expand Down
88 changes: 88 additions & 0 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,94 @@ DWORD MethodContext::repGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle)
return value;
}

void MethodContext::recGetClassModule(CORINFO_CLASS_HANDLE cls, CORINFO_MODULE_HANDLE mod)
{
if (GetClassModule == nullptr)
GetClassModule = new LightWeightMap<DWORDLONG, DWORDLONG>();

GetClassModule->Add(CastHandle(cls), CastHandle(mod));
DEBUG_REC(dmpGetClassModule(CastHandle(cls), CastHandle(mod)));
}
void MethodContext::dmpGetClassModule(DWORDLONG key, DWORDLONG value)
{
printf("GetClassModule cls-%016llX, mod-%016llX", key, value);
}
CORINFO_MODULE_HANDLE MethodContext::repGetClassModule(CORINFO_CLASS_HANDLE cls)
{
AssertCodeMsg(GetClassModule != nullptr, EXCEPTIONCODE_MC,
"Found a null GetClassModule for %016llX.", CastHandle(cls));
AssertCodeMsg(GetClassModule->GetIndex(CastHandle(cls)) != -1, EXCEPTIONCODE_MC,
"Didn't find %016llX", CastHandle(cls));
CORINFO_MODULE_HANDLE value = (CORINFO_MODULE_HANDLE)GetClassModule->Get(CastHandle(cls));
DEBUG_REP(dmpGetClassModule(CastHandle(cls), CastHandle(value)));
return value;
}

void MethodContext::recGetModuleAssembly(CORINFO_MODULE_HANDLE mod, CORINFO_ASSEMBLY_HANDLE assem)
{
if (GetModuleAssembly == nullptr)
GetModuleAssembly = new LightWeightMap<DWORDLONG, DWORDLONG>();

GetModuleAssembly->Add(CastHandle(mod), CastHandle(assem));
DEBUG_REC(dmpGetModuleAssembly(CastHandle(mod), CastHandle(assem)));
}
void MethodContext::dmpGetModuleAssembly(DWORDLONG key, DWORDLONG value)
{
printf("GetModuleAssembly mod-%016llX, assem-%016llX", key, value);
}
CORINFO_ASSEMBLY_HANDLE MethodContext::repGetModuleAssembly(CORINFO_MODULE_HANDLE mod)
{
AssertCodeMsg(GetModuleAssembly != nullptr, EXCEPTIONCODE_MC,
"Found a null GetModuleAssembly for %016llX.", CastHandle(mod));
AssertCodeMsg(GetModuleAssembly->GetIndex(CastHandle(mod)) != -1, EXCEPTIONCODE_MC,
"Didn't find %016llX", CastHandle(mod));
CORINFO_ASSEMBLY_HANDLE value = (CORINFO_ASSEMBLY_HANDLE)GetModuleAssembly->Get(CastHandle(mod));
DEBUG_REP(dmpGetModuleAssembly(CastHandle(mod), CastHandle(assem)));
return value;
}

void MethodContext::recGetAssemblyName(CORINFO_ASSEMBLY_HANDLE assem, const char* assemblyName)
{
if (GetAssemblyName == nullptr)
GetAssemblyName = new LightWeightMap<DWORDLONG, DWORD>();

DWORD value;
if (assemblyName != nullptr)
{
value = GetAssemblyName->AddBuffer((const unsigned char*)assemblyName, (DWORD)strlen(assemblyName) + 1);
}
else
{
value = (DWORD)-1;
}

GetAssemblyName->Add(CastHandle(assem), value);
DEBUG_REC(dmpGetAssemblyName(CastHandle(mod), value));
}
void MethodContext::dmpGetAssemblyName(DWORDLONG key, DWORD value)
{
const char* assemblyName = (const char*)GetAssemblyName->GetBuffer(value);
printf("GetAssemblyName assem-%016llX, value-%u '%s'", key, value, assemblyName);
GetAssemblyName->Unlock();
}
const char* MethodContext::repGetAssemblyName(CORINFO_ASSEMBLY_HANDLE assem)
{
const char* result = "hackishAssemblyName";
DWORD value = (DWORD)-1;
int itemIndex = -1;
if (GetAssemblyName != nullptr)
{
itemIndex = GetAssemblyName->GetIndex(CastHandle(assem));
}
if (itemIndex >= 0)
{
value = GetAssemblyName->Get(CastHandle(assem));
result = (const char*)GetAssemblyName->GetBuffer(value);
}
DEBUG_REP(dmpGetAssemblyName(CastHandle(assem), value));
return result;
}

// Note - the jit will call freearray on the array we give back....
void MethodContext::recGetVars(CORINFO_METHOD_HANDLE ftn,
ULONG32* cVars,
Expand Down
17 changes: 16 additions & 1 deletion src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ class MethodContext
void dmpGetMethodAttribs(DWORDLONG key, DWORD value);
DWORD repGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle);

void recGetClassModule(CORINFO_CLASS_HANDLE cls, CORINFO_MODULE_HANDLE mod);
void dmpGetClassModule(DWORDLONG key, DWORDLONG value);
CORINFO_MODULE_HANDLE repGetClassModule(CORINFO_CLASS_HANDLE cls);

void recGetModuleAssembly(CORINFO_MODULE_HANDLE mod, CORINFO_ASSEMBLY_HANDLE assem);
void dmpGetModuleAssembly(DWORDLONG key, DWORDLONG value);
CORINFO_ASSEMBLY_HANDLE repGetModuleAssembly(CORINFO_MODULE_HANDLE mod);

void recGetAssemblyName(CORINFO_ASSEMBLY_HANDLE assem, const char* assemblyName);
void dmpGetAssemblyName(DWORDLONG key, DWORD value);
const char* repGetAssemblyName(CORINFO_ASSEMBLY_HANDLE assem);

void recGetVars(CORINFO_METHOD_HANDLE ftn, ULONG32* cVars, ICorDebugInfo::ILVarInfo** vars, bool* extendOthers);
void dmpGetVars(DWORDLONG key, const Agnostic_GetVars& value);
void repGetVars(CORINFO_METHOD_HANDLE ftn, ULONG32* cVars, ICorDebugInfo::ILVarInfo** vars, bool* extendOthers);
Expand Down Expand Up @@ -869,7 +881,7 @@ class MethodContext
};

// ********************* Please keep this up-to-date to ease adding more ***************
// Highest packet number: 188
// Highest packet number: 191
// *************************************************************************************
enum mcPackets
{
Expand Down Expand Up @@ -1034,6 +1046,9 @@ enum mcPackets
Packet_SigInstHandleMap = 184,
Packet_AllocPgoInstrumentationBySchema = 186, // Added 1/4/2021
Packet_GetPgoInstrumentationResults = 187, // Added 1/4/2021
Packet_GetClassModule = 189, // Added 2/19/2021
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use some of the retired numbers or do you want them to be together?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never reused retired numbers.

Originally, there was some idea that collections wouldn't be so tightly tied to the particular build of spmi, thus not reusing was a good thing. At this point, we don't try to support that, so we could renumber everything, sort the list, and squash out all the unused numbers, if we wanted.

Packet_GetModuleAssembly = 190, // Added 2/19/2021
Packet_GetAssemblyName = 191, // Added 2/19/2021

PacketCR_AddressMap = 113,
PacketCR_AllocGCInfo = 114,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,21 +608,27 @@ bool interceptor_ICJI::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cl
CORINFO_MODULE_HANDLE interceptor_ICJI::getClassModule(CORINFO_CLASS_HANDLE cls)
{
mc->cr->AddCall("getClassModule");
return original_ICorJitInfo->getClassModule(cls);
CORINFO_MODULE_HANDLE temp = original_ICorJitInfo->getClassModule(cls);
mc->recGetClassModule(cls, temp);
return temp;
}

// Returns the assembly that contains the module "mod".
CORINFO_ASSEMBLY_HANDLE interceptor_ICJI::getModuleAssembly(CORINFO_MODULE_HANDLE mod)
{
mc->cr->AddCall("getModuleAssembly");
return original_ICorJitInfo->getModuleAssembly(mod);
CORINFO_ASSEMBLY_HANDLE temp = original_ICorJitInfo->getModuleAssembly(mod);
mc->recGetModuleAssembly(mod, temp);
return temp;
}

// Returns the name of the assembly "assem".
const char* interceptor_ICJI::getAssemblyName(CORINFO_ASSEMBLY_HANDLE assem)
{
mc->cr->AddCall("getAssemblyName");
return original_ICorJitInfo->getAssemblyName(assem);
const char* temp = original_ICorJitInfo->getAssemblyName(assem);
mc->recGetAssemblyName(assem, temp);
return temp;
}

// Allocate and delete process-lifetime objects. Should only be
Expand Down
16 changes: 3 additions & 13 deletions src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,31 +489,21 @@ bool MyICJI::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls)
CORINFO_MODULE_HANDLE MyICJI::getClassModule(CORINFO_CLASS_HANDLE cls)
{
jitInstance->mc->cr->AddCall("getClassModule");
LogError("Hit unimplemented getClassModule");
DebugBreakorAV(28);
return (CORINFO_MODULE_HANDLE)0;
// jitInstance->mc->getClassModule(cls);
return jitInstance->mc->repGetClassModule(cls);
}

// Returns the assembly that contains the module "mod".
CORINFO_ASSEMBLY_HANDLE MyICJI::getModuleAssembly(CORINFO_MODULE_HANDLE mod)
{
jitInstance->mc->cr->AddCall("getModuleAssembly");
LogError("Hit unimplemented getModuleAssembly");
DebugBreakorAV(28);
return (CORINFO_ASSEMBLY_HANDLE)0;

// return jitInstance->mc->getModuleAssembly(mod);
return jitInstance->mc->repGetModuleAssembly(mod);
}

// Returns the name of the assembly "assem".
const char* MyICJI::getAssemblyName(CORINFO_ASSEMBLY_HANDLE assem)
{
jitInstance->mc->cr->AddCall("getAssemblyName");
LogError("Hit unimplemented getAssemblyName");
DebugBreakorAV(28);
return nullptr;
// return jitInstance->mc->getAssemblyName(assem);
return jitInstance->mc->repGetAssemblyName(assem);
}

// Allocate and delete process-lifetime objects. Should only be
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* ba99f659-11ae-4c05-bdad-650cb5104f26 */
0xba99f659,
0x11ae,
0x4c05,
{0xbd, 0xad, 0x65, 0x0c, 0xb5, 0x10, 0x4f, 0x26}
constexpr GUID JITEEVersionIdentifier = { /* 73d20c3a-75a9-4eea-a952-60419d67b6a6 */
0x73d20c3a,
0x75a9,
0x4eea,
{0xa9, 0x52, 0x60, 0x41, 0x9d, 0x67, 0xb6, 0xa6}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5583,6 +5583,15 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
info.compClassAttr = info.compCompHnd->getClassAttribs(info.compClassHnd);
}

#ifdef DEBUG
if (JitConfig.EnableExtraSuperPmiQueries())
{
// Get the assembly name, to aid finding any particular SuperPMI method context function
(void)info.compCompHnd->getAssemblyName(
info.compCompHnd->getModuleAssembly(info.compCompHnd->getClassModule(info.compClassHnd)));
}
#endif // DEBUG

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work out ok for the unusual cases like stubs, LGC, etc...?

info.compProfilerCallback = false; // Assume false until we are told to hook this method.

#if defined(DEBUG) || defined(LATE_DISASM)
Expand Down