Skip to content

Commit

Permalink
superpmi
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Apr 14, 2024
1 parent bb52b25 commit 1210d9a
Show file tree
Hide file tree
Showing 5 changed files with 44 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 @@ -158,6 +158,7 @@ LWM(PrintMethodName, DWORDLONG, Agnostic_PrintResult)
LWM(IsValueClass, DWORDLONG, DWORD)
LWM(IsMoreSpecificType, DLDL, DWORD)
LWM(IsExactType, DWORDLONG, DWORD)
LWM(IsNullableType, DWORDLONG, DWORD)
LWM(IsEnum, DWORDLONG, DLD)
LWM(PInvokeMarshalingRequired, MethodOrSigInfoValue, DWORD)
LWM(ResolveToken, Agnostic_CORINFO_RESOLVED_TOKENin, ResolveTokenValue)
Expand Down
22 changes: 22 additions & 0 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5920,6 +5920,28 @@ bool MethodContext::repIsExactType(CORINFO_CLASS_HANDLE cls)
return value != 0;
}

void MethodContext::recIsNullableType(CORINFO_CLASS_HANDLE cls, TypeCompareState result)
{
if (IsNullableType == nullptr)
IsNullableType = new LightWeightMap<DWORDLONG, DWORD>();

DWORDLONG key = CastHandle(cls);
DWORD value = (DWORD)result;
IsNullableType->Add(key, value);
DEBUG_REC(dmpIsNullableType(key, value));
}
void MethodContext::dmpIsNullableType(DWORDLONG key, DWORD value)
{
printf("IsNullableType key cls-%016" PRIX64 ", value res-%d", key, value);
}
TypeCompareState MethodContext::repIsNullableType(CORINFO_CLASS_HANDLE cls)
{
DWORDLONG key = CastHandle(cls);
DWORD value = LookupByKeyOrMiss(IsNullableType, key, ": key %016" PRIX64 "", key);
DEBUG_REP(dmpIsNullableType(key, value));
return (TypeCompareState)value;
}

void MethodContext::recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE underlyingType, TypeCompareState result)
{
if (IsEnum == nullptr)
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 @@ -723,6 +723,10 @@ class MethodContext
void dmpIsExactType(DWORDLONG key, DWORD value);
bool repIsExactType(CORINFO_CLASS_HANDLE cls);

void recIsNullableType(CORINFO_CLASS_HANDLE cls, TypeCompareState result);
void dmpIsNullableType(DWORDLONG key, DWORD value);
TypeCompareState repIsNullableType(CORINFO_CLASS_HANDLE cls);

void recIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE underlyingType, TypeCompareState result);
void dmpIsEnum(DWORDLONG key, DLD value);
TypeCompareState repIsEnum(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE* underlyingType);
Expand Down Expand Up @@ -1165,6 +1169,7 @@ enum mcPackets
Packet_NotifyMethodInfoUsage = 214,
Packet_IsExactType = 215,
Packet_GetSwiftLowering = 216,
Packet_IsNullableType = 217,
};

void SetDebugDumpVariables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,15 @@ bool interceptor_ICJI::isExactType(CORINFO_CLASS_HANDLE cls)
return temp;
}

// Returns whether a class handle represents a Nullable type, if that can be statically determined.
TypeCompareState interceptor_ICJI::isNullableType(CORINFO_CLASS_HANDLE cls)
{
mc->cr->AddCall("isNullableType");
TypeCompareState temp = original_ICorJitInfo->isNullableType(cls);
mc->recIsNullableType(cls, temp);
return temp;
}

// Returns TypeCompareState::Must if cls is known to be an enum.
// For enums with known exact type returns the underlying
// type in underlyingType when the provided pointer is
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,13 @@ bool MyICJI::isExactType(CORINFO_CLASS_HANDLE cls)
return jitInstance->mc->repIsExactType(cls);
}

// Returns true if a class handle represents a Nullable type.
TypeCompareState MyICJI::isNullableType(CORINFO_CLASS_HANDLE cls)
{
jitInstance->mc->cr->AddCall("isNullableType");
return jitInstance->mc->repIsNullableType(cls);
}

// Returns TypeCompareState::Must if cls is known to be an enum.
// For enums with known exact type returns the underlying
// type in underlyingType when the provided pointer is
Expand Down

0 comments on commit 1210d9a

Please sign in to comment.