Skip to content

Commit 922c75c

Browse files
authored
SPMI: Fix recGetStaticFieldCurrentClass (#83843)
getStaticFieldCurrentClass has very different behavior depending on whether pIsSpeculative is passed or not, and we need to record the resulting class handle in both cases. This fixes a case of replays not working after recording that I hit while tracking down a separate issue.
1 parent f1f9fde commit 922c75c

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

src/coreclr/inc/jiteeversionguid.h

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

46-
constexpr GUID JITEEVersionIdentifier = { /* 3a8a07e7-928e-4281-ab68-cd4017c1141b */
47-
0x3a8a07e7,
48-
0x928e,
49-
0x4281,
50-
{0xab, 0x68, 0xcd, 0x40, 0x17, 0xc1, 0x14, 0x1b}
46+
constexpr GUID JITEEVersionIdentifier = { /* 95c688c7-28cf-4b1f-922a-11bf3947e56f */
47+
0x95c688c7,
48+
0x28cf,
49+
0x4b1f,
50+
{0x92, 0x2a, 0x11, 0xbf, 0x39, 0x47, 0xe5, 0x6f}
5151
};
5252

5353
//////////////////////////////////////////////////////////////////////////////////////////////////////////

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ LWM(GetDelegateCtor, Agnostic_GetDelegateCtorIn, Agnostic_GetDelegateCtorOut)
7878
LWM(GetEEInfo, DWORD, Agnostic_CORINFO_EE_INFO)
7979
LWM(GetEHinfo, DLD, Agnostic_CORINFO_EH_CLAUSE)
8080
LWM(GetReadonlyStaticFieldValue, DLDDD, DD)
81-
LWM(GetStaticFieldCurrentClass, DWORDLONG, Agnostic_GetStaticFieldCurrentClass)
81+
LWM(GetStaticFieldCurrentClass, DLD, Agnostic_GetStaticFieldCurrentClass)
8282
LWM(GetFieldClass, DWORDLONG, DWORDLONG)
8383
LWM(GetFieldInClass, DLD, DWORDLONG)
8484
LWM(GetFieldInfo, Agnostic_GetFieldInfo, Agnostic_CORINFO_FIELD_INFO)

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,29 +3710,36 @@ bool MethodContext::repGetReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, u
37103710
}
37113711

37123712
void MethodContext::recGetStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field,
3713-
bool isSpeculative,
3713+
bool* pIsSpeculative,
37143714
CORINFO_CLASS_HANDLE result)
37153715
{
37163716
if (GetStaticFieldCurrentClass == nullptr)
3717-
GetStaticFieldCurrentClass = new LightWeightMap<DWORDLONG, Agnostic_GetStaticFieldCurrentClass>();
3717+
GetStaticFieldCurrentClass = new LightWeightMap<DLD, Agnostic_GetStaticFieldCurrentClass>();
37183718

3719-
Agnostic_GetStaticFieldCurrentClass value;
3719+
DLD key;
3720+
ZeroMemory(&key, sizeof(key));
3721+
key.A = CastHandle(field);
3722+
key.B = pIsSpeculative != nullptr ? 1 : 0;
37203723

3724+
Agnostic_GetStaticFieldCurrentClass value;
37213725
value.classHandle = CastHandle(result);
3722-
value.isSpeculative = isSpeculative;
3726+
value.isSpeculative = pIsSpeculative != nullptr ? *pIsSpeculative : false;
37233727

3724-
DWORDLONG key = CastHandle(field);
37253728
GetStaticFieldCurrentClass->Add(key, value);
37263729
DEBUG_REC(dmpGetStaticFieldCurrentClass(key, value));
37273730
}
3728-
void MethodContext::dmpGetStaticFieldCurrentClass(DWORDLONG key, const Agnostic_GetStaticFieldCurrentClass& value)
3731+
void MethodContext::dmpGetStaticFieldCurrentClass(DLD key, const Agnostic_GetStaticFieldCurrentClass& value)
37293732
{
3730-
printf("GetStaticFieldCurrentClass key fld-%016" PRIX64 ", value clsHnd-%016" PRIX64 " isSpeculative-%u", key, value.classHandle,
3733+
printf("GetStaticFieldCurrentClass key fld-%016" PRIX64 ", value clsHnd-%016" PRIX64 " isSpeculative-%u", key.A, value.classHandle,
37313734
value.isSpeculative);
37323735
}
37333736
CORINFO_CLASS_HANDLE MethodContext::repGetStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool* pIsSpeculative)
37343737
{
3735-
DWORDLONG key = CastHandle(field);
3738+
DLD key;
3739+
ZeroMemory(&key, sizeof(key));
3740+
key.A = CastHandle(field);
3741+
key.B = pIsSpeculative != nullptr ? 1 : 0;
3742+
37363743
Agnostic_GetStaticFieldCurrentClass value = LookupByKeyOrMiss(GetStaticFieldCurrentClass, key, ": key %016" PRIX64 "", key);
37373744

37383745
DEBUG_REP(dmpGetStaticFieldCurrentClass(key, value));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ class MethodContext
493493
void dmpGetReadonlyStaticFieldValue(DLDDD key, DD value);
494494
bool repGetReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects);
495495

496-
void recGetStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool isSpeculative, CORINFO_CLASS_HANDLE result);
497-
void dmpGetStaticFieldCurrentClass(DWORDLONG key, const Agnostic_GetStaticFieldCurrentClass& value);
496+
void recGetStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool* pIsSpeculative, CORINFO_CLASS_HANDLE result);
497+
void dmpGetStaticFieldCurrentClass(DLD key, const Agnostic_GetStaticFieldCurrentClass& value);
498498
CORINFO_CLASS_HANDLE repGetStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool* pIsSpeculative);
499499

500500
void recGetClassGClayout(CORINFO_CLASS_HANDLE cls, BYTE* gcPtrs, unsigned len, unsigned result);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ CORINFO_CLASS_HANDLE interceptor_ICJI::getStaticFieldCurrentClass(CORINFO_FIELD_
17131713
{
17141714
mc->cr->AddCall("getStaticFieldCurrentClass");
17151715
CORINFO_CLASS_HANDLE result = original_ICorJitInfo->getStaticFieldCurrentClass(field, pIsSpeculative);
1716-
mc->recGetStaticFieldCurrentClass(field, (pIsSpeculative == nullptr) ? false : *pIsSpeculative, result);
1716+
mc->recGetStaticFieldCurrentClass(field, pIsSpeculative, result);
17171717
return result;
17181718
}
17191719

0 commit comments

Comments
 (0)