Skip to content

Commit

Permalink
Use TypeHandle for ConstValueType
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Aug 22, 2023
1 parent 4bd7a65 commit 9a7013f
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2780,7 +2780,7 @@ class ICorStaticInfo
) = 0;

// Return the type of the const value if this is a const value type
virtual CorInfoType getConstValueType(
virtual CORINFO_CLASS_HANDLE getConstValueType(
CORINFO_CLASS_HANDLE cls
) = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool isConstValue(
uint64_t getConstValue(
CORINFO_CLASS_HANDLE cls) override;

CorInfoType getConstValueType(
CORINFO_CLASS_HANDLE getConstValueType(
CORINFO_CLASS_HANDLE cls) override;

CorInfoIsAccessAllowedResult canAccessClass(
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* 5fb396c1-a29d-4feb-8268-8eb79d1ff5ef */
0x5fb396c1,
0xa29d,
0x4feb,
{0x82, 0x68, 0x8e, 0xb7, 0x9d, 0x1f, 0xf5, 0xef}
constexpr GUID JITEEVersionIdentifier = { /* abb7adbf-5df8-4ada-bac9-3ac6db8a09c5 */
0xabb7adbf,
0x5df8,
0x4ada,
{0xba, 0xc9, 0x3a, 0xc6, 0xdb, 0x8a, 0x09, 0xc5}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,11 +877,11 @@ uint64_t WrapICorJitInfo::getConstValue(
return temp;
}

CorInfoType WrapICorJitInfo::getConstValueType(
CORINFO_CLASS_HANDLE WrapICorJitInfo::getConstValueType(
CORINFO_CLASS_HANDLE cls)
{
API_ENTER(getConstValueType);
CorInfoType temp = wrapHnd->getConstValueType(cls);
CORINFO_CLASS_HANDLE temp = wrapHnd->getConstValueType(cls);
API_LEAVE(getConstValueType);
return temp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7915,7 +7915,7 @@ class Compiler
// functions exposed on top that have SPMI handling and additional buffer
// handling. Note that the strings returned are never truncated here.
void eePrintJitType(class StringPrinter* printer, var_types jitType);
void eePrintConstValue(class StringPrinter* printer, CorInfoType valueType, uint64_t value);
void eePrintConstValue(class StringPrinter* printer, CORINFO_CLASS_HANDLE valueType, uint64_t value);
void eePrintType(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation);
void eePrintTypeOrJitAlias(class StringPrinter* printer, CORINFO_CLASS_HANDLE clsHnd, bool includeInstantiation);
void eePrintMethod(class StringPrinter* printer,
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/eeinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ void Compiler::eePrintJitType(StringPrinter* printer, var_types jitType)
// valueType - the value type
// value - the value
//
void Compiler::eePrintConstValue(StringPrinter* printer, CorInfoType valueType, uint64_t value)
void Compiler::eePrintConstValue(StringPrinter* printer, CORINFO_CLASS_HANDLE valueType, uint64_t value)
{
printer->Append(varTypeName(JitType2PreciseVarType(valueType)));
eePrintType(printer, valueType, true);
printer->Append("(");
char buffer[64];
switch (valueType)
switch (info.compCompHnd->asCorInfoType(valueType))
{
case CORINFO_TYPE_BOOL:
printer->Append(*(uint8_t*)&value == 0 ? "true" : "false");
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3019,12 +3019,12 @@ private ulong getConstValue(CORINFO_CLASS_STRUCT_* cls)
}

#pragma warning disable CA1822 // Mark members as static
private CorInfoType getConstValueType(CORINFO_CLASS_STRUCT_* cls)
private CORINFO_CLASS_STRUCT_* getConstValueType(CORINFO_CLASS_STRUCT_* cls)
#pragma warning restore CA1822 // Mark members as static
{
// Implemented for JIT only for now.

return (CorInfoType)0;
return (CORINFO_CLASS_STRUCT_*)0;
}

private nuint printFieldName(CORINFO_FIELD_STRUCT_* fld, byte* buffer, nuint bufferSize, nuint* requiredBufferSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ private static ulong _getConstValue(IntPtr thisHandle, IntPtr* ppException, CORI
}

[UnmanagedCallersOnly]
private static CorInfoType _getConstValueType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls)
private static CORINFO_CLASS_STRUCT_* _getConstValueType(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls)
{
var _this = GetThis(thisHandle);
try
Expand Down Expand Up @@ -2658,7 +2658,7 @@ private static IntPtr GetUnmanagedCallbacks()
callbacks[86] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_FIELD_STRUCT_*, uint, void*>)&_getArrayInitializationData;
callbacks[87] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_CLASS_STRUCT_*, byte>)&_isConstValue;
callbacks[88] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_CLASS_STRUCT_*, ulong>)&_getConstValue;
callbacks[89] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_CLASS_STRUCT_*, CorInfoType>)&_getConstValueType;
callbacks[89] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_CLASS_STRUCT_*, CORINFO_CLASS_STRUCT_*>)&_getConstValueType;
callbacks[90] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_RESOLVED_TOKEN*, CORINFO_METHOD_STRUCT_*, CORINFO_HELPER_DESC*, CorInfoIsAccessAllowedResult>)&_canAccessClass;
callbacks[91] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_FIELD_STRUCT_*, byte*, UIntPtr, UIntPtr*, UIntPtr>)&_printFieldName;
callbacks[92] = (delegate* unmanaged<IntPtr, IntPtr*, CORINFO_FIELD_STRUCT_*, CORINFO_CLASS_STRUCT_*>)&_getFieldClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ FUNCTIONS
void* getArrayInitializationData(CORINFO_FIELD_HANDLE field, uint32_t size)
bool isConstValue(CORINFO_CLASS_HANDLE cls)
uint64_t getConstValue(CORINFO_CLASS_HANDLE cls)
CorInfoType getConstValueType(CORINFO_CLASS_HANDLE cls)
CORINFO_CLASS_HANDLE getConstValueType(CORINFO_CLASS_HANDLE cls)
CorInfoIsAccessAllowedResult canAccessClass(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE callerHandle, CORINFO_HELPER_DESC* pAccessHelper)
size_t printFieldName(CORINFO_FIELD_HANDLE field, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize)
CORINFO_CLASS_HANDLE getFieldClass(CORINFO_FIELD_HANDLE field)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/aot/jitinterface/jitinterface_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct JitInterfaceCallbacks
void* (* getArrayInitializationData)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, uint32_t size);
bool (* isConstValue)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls);
uint64_t (* getConstValue)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls);
CorInfoType (* getConstValueType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls);
CORINFO_CLASS_HANDLE (* getConstValueType)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls);
CorInfoIsAccessAllowedResult (* canAccessClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_METHOD_HANDLE callerHandle, CORINFO_HELPER_DESC* pAccessHelper);
size_t (* printFieldName)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, char* buffer, size_t bufferSize, size_t* pRequiredBufferSize);
CORINFO_CLASS_HANDLE (* getFieldClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field);
Expand Down Expand Up @@ -1064,11 +1064,11 @@ class JitInterfaceWrapper : public ICorJitInfo
return temp;
}

virtual CorInfoType getConstValueType(
virtual CORINFO_CLASS_HANDLE getConstValueType(
CORINFO_CLASS_HANDLE cls)
{
CorInfoExceptionClass* pException = nullptr;
CorInfoType temp = _callbacks->getConstValueType(_thisHandle, &pException, cls);
CORINFO_CLASS_HANDLE temp = _callbacks->getConstValueType(_thisHandle, &pException, cls);
if (pException != nullptr) throw pException;
return temp;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ LWM(GetArrayInitializationData, DLD, DWORDLONG)
LWM(GetArrayRank, DWORDLONG, DWORD)
LWM(GetArrayIntrinsicID, DWORDLONG, DWORD)
LWM(IsConstValue, DWORDLONG, DWORD)
LWM(GetConstValueType, DWORDLONG, DWORD)
LWM(GetConstValueType, DWORDLONG, DWORDLONG)
LWM(GetConstValue, DWORDLONG, DWORDLONG)
LWM(GetBoundaries, DWORDLONG, Agnostic_GetBoundaries)
LWM(GetBoxHelper, DWORDLONG, DWORD)
Expand Down
17 changes: 8 additions & 9 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5204,29 +5204,28 @@ DWORDLONG MethodContext::repGetConstValue(CORINFO_CLASS_HANDLE cls)
return value;
}

void MethodContext::recGetConstValueType(CORINFO_CLASS_HANDLE cls, CorInfoType result)
void MethodContext::recGetConstValueType(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result)
{
if (GetConstValueType == nullptr)
GetConstValueType = new LightWeightMap<DWORDLONG, DWORD>();
GetConstValueType = new LightWeightMap<DWORDLONG, DWORDLONG>();

DWORDLONG key = CastHandle(cls);
GetConstValueType->Add(key, result);
GetConstValueType->Add(key, CastHandle(result));
DEBUG_REC(dmpGetConstValueType(key, result));
}

void MethodContext::dmpGetConstValueType(DWORDLONG key, DWORD value)
void MethodContext::dmpGetConstValueType(DWORDLONG key, DWORDLONG value)
{
printf("GetConstValueType key cls-%016" PRIX64 ", value res-%u(%s)", key, value, toString((CorInfoType)value));
printf("GetConstValueType key cls-%016" PRIX64 ", value res-%016" PRIX64 "", key, value);
}

CorInfoType MethodContext::repGetConstValueType(CORINFO_CLASS_HANDLE cls)
CORINFO_CLASS_HANDLE MethodContext::repGetConstValueType(CORINFO_CLASS_HANDLE cls)
{
DWORDLONG key = CastHandle(cls);
DWORD value = LookupByKeyOrMissNoMessage(GetConstValueType, key);
DWORDLONG value = LookupByKeyOrMissNoMessage(GetConstValueType, key);

DEBUG_REP(dmpGetConstValueType(key, value));
CorInfoType result = (CorInfoType)value;
return result;
return (CORINFO_CLASS_HANDLE)value;
}

void MethodContext::recGetAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, CORINFO_CONST_LOOKUP* pLookup)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,9 @@ class MethodContext
void dmpGetConstValue(DWORDLONG key, DWORDLONG value);
DWORDLONG repGetConstValue(CORINFO_CLASS_HANDLE cls);

void recGetConstValueType(CORINFO_CLASS_HANDLE cls, CorInfoType result);
void dmpGetConstValueType(DWORDLONG key, DWORD value);
CorInfoType repGetConstValueType(CORINFO_CLASS_HANDLE cls);
void recGetConstValueType(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result);
void dmpGetConstValueType(DWORDLONG key, DWORDLONG value);
CORINFO_CLASS_HANDLE repGetConstValueType(CORINFO_CLASS_HANDLE cls);

void recGetAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, CORINFO_CONST_LOOKUP* pLookup);
void dmpGetAddressOfPInvokeTarget(DWORDLONG key, DLD value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,10 @@ uint64_t interceptor_ICJI::getConstValue(CORINFO_CLASS_HANDLE cls)
return temp;
}

CorInfoType interceptor_ICJI::getConstValueType(CORINFO_CLASS_HANDLE cls)
CORINFO_CLASS_HANDLE interceptor_ICJI::getConstValueType(CORINFO_CLASS_HANDLE cls)
{
mc->cr->AddCall("getConstValueType");
CorInfoType temp = original_ICorJitInfo->getConstValueType(cls);
CORINFO_CLASS_HANDLE temp = original_ICorJitInfo->getConstValueType(cls);
mc->recGetConstValueType(cls, temp);
return temp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ uint64_t interceptor_ICJI::getConstValue(
return original_ICorJitInfo->getConstValue(cls);
}

CorInfoType interceptor_ICJI::getConstValueType(
CORINFO_CLASS_HANDLE interceptor_ICJI::getConstValueType(
CORINFO_CLASS_HANDLE cls)
{
mcs->AddCall("getConstValueType");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ uint64_t interceptor_ICJI::getConstValue(
return original_ICorJitInfo->getConstValue(cls);
}

CorInfoType interceptor_ICJI::getConstValueType(
CORINFO_CLASS_HANDLE interceptor_ICJI::getConstValueType(
CORINFO_CLASS_HANDLE cls)
{
return original_ICorJitInfo->getConstValueType(cls);
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 @@ -842,7 +842,7 @@ uint64_t MyICJI::getConstValue(CORINFO_CLASS_HANDLE cls)
return jitInstance->mc->repGetConstValue(cls);
}

CorInfoType MyICJI::getConstValueType(CORINFO_CLASS_HANDLE cls)
CORINFO_CLASS_HANDLE MyICJI::getConstValueType(CORINFO_CLASS_HANDLE cls)
{
jitInstance->mc->cr->AddCall("getConstValueType");
return jitInstance->mc->repGetConstValueType(cls);
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5004,19 +5004,19 @@ uint64_t CEEInfo::getConstValue(CORINFO_CLASS_HANDLE cls)
}

// Return the type of the const value if this is a const value type
CorInfoType CEEInfo::getConstValueType(CORINFO_CLASS_HANDLE cls)
CORINFO_CLASS_HANDLE CEEInfo::getConstValueType(CORINFO_CLASS_HANDLE cls)
{
CONTRACTL {
THROWS;
GC_TRIGGERS;
MODE_PREEMPTIVE;
} CONTRACTL_END;

CorInfoType result = CorInfoType::CORINFO_TYPE_COUNT;
CORINFO_CLASS_HANDLE result = nullptr;

JIT_TO_EE_TRANSITION();

result = CEEInfo::asCorInfoType(((TypeHandle)cls).GetConstValueType());
result = (CORINFO_CLASS_HANDLE)((TypeHandle)cls).GetConstValueType().AsTAddr();

EE_TO_JIT_TRANSITION();

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/typehandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,12 +1046,12 @@ uint64_t TypeHandle::GetConstValue() const
return AsConstValue()->GetConstValue();
}

CorElementType TypeHandle::GetConstValueType() const
TypeHandle TypeHandle::GetConstValueType() const
{
LIMITED_METHOD_DAC_CONTRACT;

_ASSERTE(IsTypeDesc());
return AsConstValue()->GetConstValueType().GetInternalCorElementType();
return AsConstValue()->GetConstValueType();
}

BOOL TypeHandle::IsRestored() const
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/typehandle.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class TypeHandle
// CTARG
BOOL IsConstValue() const;
uint64_t GetConstValue() const;
CorElementType GetConstValueType() const;
TypeHandle GetConstValueType() const;

// BYREF
BOOL IsByRef() const;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/typehash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ EETypeHashEntry_t *EETypeHashTable::FindItem(TypeKey* pKey)
if (!pSearch->GetTypeHandle().IsConstValue())
continue;

CorElementType valueType = pKey->GetConstValueType().GetInternalCorElementType();
TypeHandle valueType = pKey->GetConstValueType();
if ((pSearch->GetTypeHandle().GetConstValueType() != valueType))
continue;

Expand Down

0 comments on commit 9a7013f

Please sign in to comment.