Skip to content

Commit fb67dba

Browse files
authored
SPMI: Record and replay notifyInstructionSetUsage properly (#112764)
1 parent 7060c62 commit fb67dba

File tree

7 files changed

+49
-15
lines changed

7 files changed

+49
-15
lines changed

src/coreclr/inc/jiteeversionguid.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ typedef const GUID *LPCGUID;
4343
#define GUID_DEFINED
4444
#endif // !GUID_DEFINED
4545

46-
constexpr GUID JITEEVersionIdentifier = { /* a116647a-3f80-4fd6-9c80-95156c7e9923 */
47-
0xa116647a,
48-
0x3f80,
49-
0x4fd6,
50-
{0x9c, 0x80, 0x95, 0x15, 0x6c, 0x7e, 0x99, 0x23}
51-
};
46+
constexpr GUID JITEEVersionIdentifier = { /* 4463d6ac-dfcb-4ab0-a941-c53b56089b7c */
47+
0x4463d6ac,
48+
0xdfcb,
49+
0x4ab0,
50+
{0xa9, 0x41, 0xc5, 0x3b, 0x56, 0x08, 0x9b, 0x7c}
51+
};
5252

5353
//////////////////////////////////////////////////////////////////////////////////////////////////////////
5454
//

src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ public void ExpandInstructionSetByImplication(TargetArchitecture architecture)
545545
546546
public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionSets(TargetArchitecture architecture, InstructionSet input)
547547
{
548-
switch(architecture)
548+
switch (architecture)
549549
{
550550
");
551551
foreach (string architecture in _architectures)
@@ -554,7 +554,7 @@ public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionS
554554
continue;
555555

556556
tr.Write($@" case TargetArchitecture.{architecture}:
557-
switch(input)
557+
switch (input)
558558
{{
559559
");
560560
foreach (var vectorInstructionSet in _architectureVectorInstructionSetJitNames[architecture])
@@ -635,7 +635,7 @@ private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelpe
635635
do
636636
{
637637
oldflags = resultflags;
638-
switch(architecture)
638+
switch (architecture)
639639
{
640640
");
641641
foreach (string architecture in _architectures)

src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ LWM(GetLazyStringLiteralHelper, DWORDLONG, DWORD)
102102
LWM(GetLocationOfThisType, DWORDLONG, Agnostic_CORINFO_LOOKUP_KIND)
103103
LWM(IsIntrinsic, DWORDLONG, DWORD)
104104
LWM(NotifyMethodInfoUsage, DWORDLONG, DWORD)
105+
LWM(NotifyInstructionSetUsage, DD, DWORD)
105106
LWM(GetMethodAttribs, DWORDLONG, DWORD)
106107
LWM(GetClassAssemblyName, DWORDLONG, DWORD)
107108
LWM(GetMethodClass, DWORDLONG, DWORDLONG)

src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,31 @@ bool MethodContext::repNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn)
791791
return value != 0;
792792
}
793793

794+
void MethodContext::recNotifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported, bool result)
795+
{
796+
if (NotifyInstructionSetUsage == nullptr)
797+
NotifyInstructionSetUsage = new LightWeightMap<DD, DWORD>();
798+
799+
DD key{};
800+
key.A = (DWORD)isa;
801+
key.B = supported ? 1 : 0;
802+
NotifyInstructionSetUsage->Add(key, result ? 1 : 0);
803+
DEBUG_REC(dmpNotifyInstructionSetUsage(key, result ? 1 : 0));
804+
}
805+
void MethodContext::dmpNotifyInstructionSetUsage(DD key, DWORD value)
806+
{
807+
printf("NotifyInstructionSetUsage key isa-%u, supported-%u, res-%u", key.A, key.B, value);
808+
}
809+
bool MethodContext::repNotifyInstructionSetUsage(CORINFO_InstructionSet isa, bool supported)
810+
{
811+
DD key{};
812+
key.A = (DWORD)isa;
813+
key.B = supported ? 1 : 0;
814+
DWORD value = LookupByKeyOrMiss(NotifyInstructionSetUsage, key, ": key %u-%u", key.A, key.B);
815+
DEBUG_REP(dmpNotifyInstructionSetUsage(key, value));
816+
return value != 0;
817+
}
818+
794819
void MethodContext::recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs)
795820
{
796821
if (GetMethodAttribs == nullptr)

src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ class MethodContext
126126
void dmpNotifyMethodInfoUsage(DWORDLONG key, DWORD value);
127127
bool repNotifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn);
128128

129+
void recNotifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported, bool result);
130+
void dmpNotifyInstructionSetUsage(DD key, DWORD supported);
131+
bool repNotifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported);
132+
129133
void recGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle, DWORD attribs);
130134
void dmpGetMethodAttribs(DWORDLONG key, DWORD value);
131135
DWORD repGetMethodAttribs(CORINFO_METHOD_HANDLE methodHandle);
@@ -1203,6 +1207,7 @@ enum mcPackets
12031207
Packet_GetSZArrayHelperEnumeratorClass = 226,
12041208
Packet_GetMethodInstantiationArgument = 227,
12051209
Packet_GetInstantiatedEntry = 228,
1210+
Packet_NotifyInstructionSetUsage = 229,
12061211
};
12071212

12081213
void SetDebugDumpVariables();

src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ bool interceptor_ICJI::notifyMethodInfoUsage(CORINFO_METHOD_HANDLE ftn)
3636
return temp;
3737
}
3838

39+
bool interceptor_ICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
40+
{
41+
mc->cr->AddCall("notifyInstructionSetUsage");
42+
bool result = original_ICorJitInfo->notifyInstructionSetUsage(instructionSet, supported);
43+
mc->recNotifyInstructionSetUsage(instructionSet, supported, result);
44+
return result;
45+
}
46+
3947
// return flags (defined above, CORINFO_FLG_PUBLIC ...)
4048
uint32_t interceptor_ICJI::getMethodAttribs(CORINFO_METHOD_HANDLE ftn /* IN */)
4149
{
@@ -2024,11 +2032,6 @@ uint32_t interceptor_ICJI::getExpectedTargetArchitecture()
20242032
return result;
20252033
}
20262034

2027-
bool interceptor_ICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
2028-
{
2029-
return original_ICorJitInfo->notifyInstructionSetUsage(instructionSet, supported);
2030-
}
2031-
20322035
CORINFO_METHOD_HANDLE interceptor_ICJI::getSpecialCopyHelper(CORINFO_CLASS_HANDLE type)
20332036
{
20342037
mc->cr->AddCall("getSpecialCopyHelper");

src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ bool MyICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, b
15291529
bool MyICJI::notifyInstructionSetUsage(CORINFO_InstructionSet instructionSet, bool supported)
15301530
{
15311531
jitInstance->mc->cr->AddCall("notifyInstructionSetUsage");
1532-
return supported;
1532+
return jitInstance->mc->repNotifyInstructionSetUsage(instructionSet, supported);
15331533
}
15341534

15351535
void MyICJI::updateEntryPointForTailCall(CORINFO_CONST_LOOKUP* entryPoint)

0 commit comments

Comments
 (0)