Skip to content

Commit d6cfa20

Browse files
authored
SPMI: Ensure proper zero extension for isObjectImmutable and friends (#112617)
Whether pointers are signed or unsigned is implementation defined, meaning that casts from a pointer to a 64-bit integer on 32-bit targets can be either zero or sign extended. SPMI provides `CastHandle` to handle this, but a couple of recording helpers were not using these.
1 parent 5bc9041 commit d6cfa20

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ void MethodContext::recGetRuntimeTypePointer(CORINFO_CLASS_HANDLE cls, CORINFO_O
21452145
GetRuntimeTypePointer = new LightWeightMap<DWORDLONG, DWORDLONG>();
21462146

21472147
DWORDLONG key = CastHandle(cls);
2148-
DWORDLONG value = (DWORDLONG)result;
2148+
DWORDLONG value = CastHandle(result);
21492149
GetRuntimeTypePointer->Add(key, value);
21502150
DEBUG_REC(dmpGetRuntimeTypePointer(key, value));
21512151
}
@@ -2166,7 +2166,7 @@ void MethodContext::recIsObjectImmutable(CORINFO_OBJECT_HANDLE objPtr, bool resu
21662166
if (IsObjectImmutable == nullptr)
21672167
IsObjectImmutable = new LightWeightMap<DWORDLONG, DWORD>();
21682168

2169-
DWORDLONG key = (DWORDLONG)objPtr;
2169+
DWORDLONG key = CastHandle(objPtr);
21702170
DWORD value = (DWORD)result;
21712171
IsObjectImmutable->Add(key, value);
21722172
DEBUG_REC(dmpIsObjectImmutable(key, value));
@@ -2177,7 +2177,7 @@ void MethodContext::dmpIsObjectImmutable(DWORDLONG key, DWORD value)
21772177
}
21782178
bool MethodContext::repIsObjectImmutable(CORINFO_OBJECT_HANDLE objPtr)
21792179
{
2180-
DWORDLONG key = (DWORDLONG)objPtr;
2180+
DWORDLONG key = CastHandle(objPtr);
21812181
DWORD value = LookupByKeyOrMiss(IsObjectImmutable, key, ": key %016" PRIX64 "", key);
21822182
DEBUG_REP(dmpIsObjectImmutable(key, value));
21832183
return (bool)value;
@@ -2224,8 +2224,8 @@ void MethodContext::recGetObjectType(CORINFO_OBJECT_HANDLE objPtr, CORINFO_CLASS
22242224
if (GetObjectType == nullptr)
22252225
GetObjectType = new LightWeightMap<DWORDLONG, DWORDLONG>();
22262226

2227-
DWORDLONG key = (DWORDLONG)objPtr;
2228-
DWORDLONG value = (DWORDLONG)result;
2227+
DWORDLONG key = CastHandle(objPtr);
2228+
DWORDLONG value = CastHandle(result);
22292229
GetObjectType->Add(key, value);
22302230
DEBUG_REC(dmpGetObjectType(key, value));
22312231
}
@@ -2235,7 +2235,7 @@ void MethodContext::dmpGetObjectType(DWORDLONG key, DWORDLONG value)
22352235
}
22362236
CORINFO_CLASS_HANDLE MethodContext::repGetObjectType(CORINFO_OBJECT_HANDLE objPtr)
22372237
{
2238-
DWORDLONG key = (DWORDLONG)objPtr;
2238+
DWORDLONG key = CastHandle(objPtr);
22392239
DWORDLONG value = LookupByKeyOrMiss(GetObjectType, key, ": key %016" PRIX64 "", key);
22402240
DEBUG_REP(dmpGetObjectType(key, value));
22412241
return (CORINFO_CLASS_HANDLE)value;

0 commit comments

Comments
 (0)