Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
SPMI: Record and replay notifyInstructionSetUsage properly
  • Loading branch information
jakobbotsch committed Feb 20, 2025
commit f93acf264bcfcbe36d183f3fed10c5836539f6a0
12 changes: 6 additions & 6 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* a116647a-3f80-4fd6-9c80-95156c7e9923 */
0xa116647a,
0x3f80,
0x4fd6,
{0x9c, 0x80, 0x95, 0x15, 0x6c, 0x7e, 0x99, 0x23}
};
constexpr GUID JITEEVersionIdentifier = { /* 00e17355-0390-432c-a2da-1068a055dc77 */
0x00e17355,
0x0390,
0x432c,
{0xa2, 0xda, 0x10, 0x68, 0xa0, 0x55, 0xdc, 0x77}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,25 +497,25 @@ public void ExpandInstructionSetByImplication(TargetArchitecture architecture)

public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionSets(TargetArchitecture architecture, InstructionSet input)
{
switch (architecture)
switch(architecture)
{
case TargetArchitecture.ARM64:
switch (input)
switch(input)
{
case InstructionSet.ARM64_Vector64: return InstructionSet.ARM64_AdvSimd;
case InstructionSet.ARM64_Vector128: return InstructionSet.ARM64_AdvSimd;
}
break;
case TargetArchitecture.X64:
switch (input)
switch(input)
{
case InstructionSet.X64_Vector128: return InstructionSet.X64_SSE;
case InstructionSet.X64_Vector256: return InstructionSet.X64_AVX;
case InstructionSet.X64_Vector512: return InstructionSet.X64_AVX512F;
}
break;
case TargetArchitecture.X86:
switch (input)
switch(input)
{
case InstructionSet.X86_Vector128: return InstructionSet.X86_SSE;
case InstructionSet.X86_Vector256: return InstructionSet.X86_AVX;
Expand Down Expand Up @@ -984,7 +984,7 @@ private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelpe
do
{
oldflags = resultflags;
switch (architecture)
switch(architecture)
{

case TargetArchitecture.ARM64:
Expand Down
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 @@ -102,6 +102,7 @@ LWM(GetLazyStringLiteralHelper, DWORDLONG, DWORD)
LWM(GetLocationOfThisType, DWORDLONG, Agnostic_CORINFO_LOOKUP_KIND)
LWM(IsIntrinsic, DWORDLONG, DWORD)
LWM(NotifyMethodInfoUsage, DWORDLONG, DWORD)
LWM(NotifyInstructionSetUsage, DD, DWORD)
LWM(GetMethodAttribs, DWORDLONG, DWORD)
LWM(GetClassAssemblyName, DWORDLONG, DWORD)
LWM(GetMethodClass, DWORDLONG, DWORDLONG)
Expand Down
25 changes: 25 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,31 @@ bool MethodContext::repNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn)
return value != 0;
}

void MethodContext::recNotifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported, bool result)
{
if (NotifyInstructionSetUsage == nullptr)
NotifyInstructionSetUsage = new LightWeightMap<DD, DWORD>();

DD key{};
key.A = (DWORD)isa;
key.B = supported ? 1 : 0;
NotifyInstructionSetUsage->Add(key, result ? 1 : 0);
DEBUG_REC(dmpNotifyInstructionSetUsage(key, result ? 1 : 0));
}
void MethodContext::dmpNotifyInstructionSetUsage(DD key, DWORD value)
{
printf("NotifyInstructionSetUsage key isa-%u, supported-%u, res-%u", key.A, key.B, value);
}
bool MethodContext::repNotifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported)
{
DD key{};
key.A = (DWORD)isa;
key.B = supported ? 1 : 0;
DWORD value = LookupByKeyOrMiss(NotifyInstructionSetUsage, key, ": key %u-%u", key.A, key.B);
DEBUG_REP(dmpNotifyInstructionSetUsage(key, value));
return value != 0;
}

void MethodContext::recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs)
{
if (GetMethodAttribs == nullptr)
Expand Down
6 changes: 5 additions & 1 deletion src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,13 @@ class MethodContext
bool repIsIntrinsic(CORINFO_METHOD_HANDLE ftn);

void recNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn, bool result);
void dmpNotifyMethodInfoUsage(DWORDLONG key, DWORD value);
void dmpNotifyMethodInfoUsage(DD key, DWORD value);
bool repNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn);

void recNotifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported, bool result);
void dmpNotifyInstructionSetUsage(DD key, DWORD supported);
bool repNotifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported);

void recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs);
void dmpGetMethodAttribs(DWORDLONG key, DWORD value);
DWORD repGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ bool interceptor_ICJI::notifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn)
return temp;
}

bool interceptor_ICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
{
mc->cr->AddCall("notifyInstructionSetUsage");
bool result = original_ICorJitInfo->notifyInstructionSetUsage(instructionSet, supported);
mc->recNotifyInstructionSetUsage(instructionSet, supported, result);
return result;
}

// return flags (defined above, CORINFO_FLG_PUBLIC ...)
uint32_t interceptor_ICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */)
{
Expand Down Expand Up @@ -2024,11 +2032,6 @@ uint32_t interceptor_ICJI::getExpectedTargetArchitecture()
return result;
}

bool interceptor_ICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
{
return original_ICorJitInfo->notifyInstructionSetUsage(instructionSet, supported);
}

CORINFO_METHOD_HANDLE interceptor_ICJI::getSpecialCopyHelper(CORINFO_CLASS_HANDLE type)
{
mc->cr->AddCall("getSpecialCopyHelper");
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ bool MyICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, b
bool MyICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
{
jitInstance->mc->cr->AddCall("notifyInstructionSetUsage");
return supported;
return jitInstance->mc->repNotifyInstructionSetUsage(instructionSet, supported);
}

void MyICJI::updateEntryPointForTailCall(CORINFO_CONST_LOOKUP* entryPoint)
Expand Down
Loading