Skip to content

Commit

Permalink
Implement getMethodModule (#45046)
Browse files Browse the repository at this point in the history
R2R testing was failing by hitting an assert about unimplemented
getMethodModule, called as part of R2R-only devirtualization handling
in the JIT.

I didn't determine why this regressed now.

Fixes #45016
  • Loading branch information
BruceForstall authored Nov 21, 2020
1 parent 2f8959a commit 8a3dc16
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/coreclr/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ LWM(GetLazyStringLiteralHelper, DWORDLONG, DWORD)
LWM(GetLocationOfThisType, DWORDLONG, Agnostic_CORINFO_LOOKUP_KIND)
LWM(GetMethodAttribs, DWORDLONG, DWORD)
LWM(GetMethodClass, DWORDLONG, DWORDLONG)
LWM(GetMethodModule, DWORDLONG, DWORDLONG)
LWM(GetMethodDefFromMethod, DWORDLONG, DWORD)
LWM(GetMethodHash, DWORDLONG, DWORD)
LWM(GetMethodInfo, DWORDLONG, Agnostic_GetMethodInfo)
Expand Down
24 changes: 24 additions & 0 deletions src/coreclr/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,30 @@ CORINFO_CLASS_HANDLE MethodContext::repGetMethodClass(CORINFO_METHOD_HANDLE meth
return value;
}

void MethodContext::recGetMethodModule(CORINFO_METHOD_HANDLE methodHandle, CORINFO_MODULE_HANDLE moduleHandle)
{
if (GetMethodModule == nullptr)
GetMethodModule = new LightWeightMap<DWORDLONG, DWORDLONG>();

GetMethodModule->Add((DWORDLONG)methodHandle, (DWORDLONG)moduleHandle);
DEBUG_REC(dmpGetMethodModule((DWORDLONG)methodHandle, (DWORDLONG)moduleHandle));
}
void MethodContext::dmpGetMethodModule(DWORDLONG key, DWORDLONG value)
{
printf("GetMethodModule key %016llX, value %016llX", key, value);
}
CORINFO_MODULE_HANDLE MethodContext::repGetMethodModule(CORINFO_METHOD_HANDLE methodHandle)
{
AssertCodeMsg(GetMethodModule != nullptr, EXCEPTIONCODE_MC,
"Found a null GetMethodModule. Probably missing a fatTrigger for %016llX.", (DWORDLONG)methodHandle);
int index = GetMethodModule->GetIndex((DWORDLONG)methodHandle);
AssertCodeMsg(index != -1, EXCEPTIONCODE_MC, "Didn't find %016llX. Probably missing a fatTrigger",
(DWORDLONG)methodHandle);
CORINFO_MODULE_HANDLE value = (CORINFO_MODULE_HANDLE)GetMethodModule->Get((DWORDLONG)methodHandle);
DEBUG_REP(dmpGetMethodModule((DWORDLONG)methodHandle, (DWORDLONG)value));
return value;
}

void MethodContext::recGetClassAttribs(CORINFO_CLASS_HANDLE classHandle, DWORD attribs)
{
if (GetClassAttribs == nullptr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ class MethodContext
void dmpGetMethodClass(DWORDLONG key, DWORDLONG value);
CORINFO_CLASS_HANDLE repGetMethodClass(CORINFO_METHOD_HANDLE methodHandle);

void recGetMethodModule(CORINFO_METHOD_HANDLE methodHandle, CORINFO_MODULE_HANDLE moduleHandle);
void dmpGetMethodModule(DWORDLONG key, DWORDLONG value);
CORINFO_MODULE_HANDLE repGetMethodModule(CORINFO_METHOD_HANDLE methodHandle);

void recGetClassAttribs(CORINFO_CLASS_HANDLE classHandle, DWORD attribs);
void dmpGetClassAttribs(DWORDLONG key, DWORD value);
DWORD repGetClassAttribs(CORINFO_CLASS_HANDLE classHandle);
Expand Down Expand Up @@ -1355,7 +1359,7 @@ class MethodContext
};

// ********************* Please keep this up-to-date to ease adding more ***************
// Highest packet number: 178
// Highest packet number: 181
// *************************************************************************************
enum mcPackets
{
Expand Down Expand Up @@ -1457,6 +1461,7 @@ enum mcPackets
Packet_GetLocationOfThisType = 69,
Packet_GetMethodAttribs = 70,
Packet_GetMethodClass = 71,
Packet_GetMethodModule = 181, // Added 11/20/2020
Packet_GetMethodDefFromMethod = 72,
Packet_GetMethodHash = 73,
Packet_GetMethodInfo = 74,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getMethodClass(CORINFO_METHOD_HANDLE meth
CORINFO_MODULE_HANDLE interceptor_ICJI::getMethodModule(CORINFO_METHOD_HANDLE method)
{
mc->cr->AddCall("getMethodModule");
return original_ICorJitInfo->getMethodModule(method);
CORINFO_MODULE_HANDLE temp = original_ICorJitInfo->getMethodModule(method);
mc->recGetMethodModule(method, temp);
return temp;
}

// This function returns the offset of the specified method in the
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ CORINFO_CLASS_HANDLE MyICJI::getMethodClass(CORINFO_METHOD_HANDLE method)
CORINFO_MODULE_HANDLE MyICJI::getMethodModule(CORINFO_METHOD_HANDLE method)
{
jitInstance->mc->cr->AddCall("getMethodModule");
LogError("Hit unimplemented getMethodModule");
DebugBreakorAV(7);
return 0;
return jitInstance->mc->repGetMethodModule(method);
}

// This function returns the offset of the specified method in the
Expand Down

0 comments on commit 8a3dc16

Please sign in to comment.