Skip to content

Commit

Permalink
Implement missing superPMI methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Mar 12, 2024
1 parent 14b7e27 commit 7584128
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ LWM(GetMethodDefFromMethod, DWORDLONG, DWORD)
LWM(GetMethodHash, DWORDLONG, DWORD)
LWM(GetMethodInfo, DLDL, Agnostic_GetMethodInfo)
LWM(HaveSameMethodDefinition, DLDL, DWORD)
LWM(GetTypeDefinition, DWORDLONG, DWORDLONG)
LWM(GetMethodNameFromMetadata, Agnostic_CORINFO_METHODNAME_TOKENin, Agnostic_CORINFO_METHODNAME_TOKENout)
LWM(GetMethodSig, DLDL, Agnostic_CORINFO_SIG_INFO)
LWM(GetMethodSync, DWORDLONG, DLDL)
Expand Down
23 changes: 23 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,29 @@ bool MethodContext::repHaveSameMethodDefinition(CORINFO_METHOD_HANDLE methHnd1,
return value != 0;
}

void MethodContext::recGetTypeDefinition(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result)
{
if (GetTypeDefinition == nullptr)
GetTypeDefinition = new LightWeightMap<DWORDLONG, DWORDLONG>();

DWORDLONG key = CastHandle(cls);
DWORDLONG value = CastHandle(result);
GetTypeDefinition->Add(key, value);
DEBUG_REC(dmpGetTypeDefinition(key, value));
}
void MethodContext::dmpGetTypeDefinition(DWORDLONG key, DWORDLONG value)
{
printf("GetTypeDefinition key cls-%016" PRIX64 ", value cls-%016" PRIX64 "", key, value);
}
CORINFO_CLASS_HANDLE MethodContext::repGetTypeDefinition(CORINFO_CLASS_HANDLE cls)
{
DWORDLONG key = CastHandle(cls);
DWORDLONG value = LookupByKeyOrMiss(GetTypeDefinition, key, ": key %016" PRIX64 "", key);
DEBUG_REP(dmpGetTypeDefinition(key, value));
CORINFO_CLASS_HANDLE result = (CORINFO_CLASS_HANDLE)value;
return result;
}

void MethodContext::recGetNewHelper(CORINFO_CLASS_HANDLE classHandle,
bool hasSideEffects,
CorInfoHelpFunc result,
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ class MethodContext
void dmpHaveSameMethodDefinition(const DLDL& key, DWORD value);
bool repHaveSameMethodDefinition(CORINFO_METHOD_HANDLE methHnd1, CORINFO_METHOD_HANDLE methHnd2);

void recGetTypeDefinition(CORINFO_CLASS_HANDLE type, CORINFO_CLASS_HANDLE result);
void dmpGetTypeDefinition(DWORDLONG key, DWORDLONG value);
CORINFO_CLASS_HANDLE repGetTypeDefinition(CORINFO_CLASS_HANDLE type);

void recGetNewHelper(CORINFO_CLASS_HANDLE classHandle,
bool hasSideEffects,
CorInfoHelpFunc result,
Expand Down Expand Up @@ -1154,6 +1158,7 @@ enum mcPackets
Packet_HaveSameMethodDefinition = 213,
Packet_NotifyMethodInfoUsage = 214,
Packet_IsExactType = 215,
Packet_GetTypeDefinition = 216,
};

void SetDebugDumpVariables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ bool interceptor_ICJI::haveSameMethodDefinition(
return result;
}

CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeDefinition(
CORINFO_CLASS_HANDLE type)
{
CORINFO_CLASS_HANDLE result = original_ICorJitInfo->getTypeDefinition(type);
mc->recGetTypeDefinition(type, result);

return result;
}

// Decides if you have any limitations for inlining. If everything's OK, it will return
// INLINE_PASS.
//
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ bool MyICJI::haveSameMethodDefinition(
return value;
}

CORINFO_CLASS_HANDLE MyICJI::getTypeDefinition(
CORINFO_CLASS_HANDLE type)
{
jitInstance->mc->cr->AddCall("getTypeDefinition");
CORINFO_CLASS_HANDLE value = jitInstance->mc->repGetTypeDefinition(type);
return value;
}

// Decides if you have any limitations for inlining. If everything's OK, it will return
// INLINE_PASS.
//
Expand Down

0 comments on commit 7584128

Please sign in to comment.