Skip to content

Commit

Permalink
Remove ArrayClass::m_ElementType - get type from the type handle on M…
Browse files Browse the repository at this point in the history
…ethodTable
  • Loading branch information
elinor-fung committed Aug 22, 2024
1 parent 631778a commit 84be45b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
6 changes: 2 additions & 4 deletions src/coreclr/vm/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy
pClass->SetInternalCorElementType(arrayKind);
pClass->SetAttrClass (tdPublic | tdSerializable | tdSealed); // This class is public, serializable, sealed
pClass->SetRank (Rank);
pClass->SetArrayElementType (elemType);
pClass->SetMethodTable (pMT);

// Fill In the method table
Expand Down Expand Up @@ -658,9 +657,8 @@ class ArrayOpLinker : public ILStubLinker
hiddenArgIdx = 0;
}
#endif

ArrayClass *pcls = (ArrayClass*)(pMT->GetClass());
if(pcls->GetArrayElementType() == ELEMENT_TYPE_CLASS)
CorElementType sigElementType = pMT->GetArrayElementType();
if(sigElementType == ELEMENT_TYPE_CLASS || sigElementType == ELEMENT_TYPE_ARRAY)
{
// Type Check
if(m_pMD->GetArrayFuncIndex() == ArrayMethodDesc::ARRAY_FUNC_SET)
Expand Down
11 changes: 0 additions & 11 deletions src/coreclr/vm/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,6 @@ class ArrayClass : public EEClass

DAC_ALIGNAS(EEClass) // Align the first member to the alignment of the base class
unsigned char m_rank;
CorElementType m_ElementType;// Cache of element type in m_ElementTypeHnd

public:
DWORD GetRank() {
Expand All @@ -1969,16 +1968,6 @@ class ArrayClass : public EEClass
m_rank = (unsigned char)Rank;
}

CorElementType GetArrayElementType() {
LIMITED_METHOD_CONTRACT;
return m_ElementType;
}
void SetArrayElementType(CorElementType ElementType) {
LIMITED_METHOD_CONTRACT;
m_ElementType = ElementType;
}


// Allocate a new MethodDesc for the methods we add to this class
void InitArrayMethodDesc(
ArrayMethodDesc* pNewMD,
Expand Down
6 changes: 5 additions & 1 deletion src/coreclr/vm/methodtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,11 @@ class MethodTable
}

// The following methods are only valid for the method tables for array types.
CorElementType GetArrayElementType();
CorElementType GetArrayElementType()
{
return GetArrayElementTypeHandle().GetSignatureCorElementType();
}

DWORD GetRank();

TypeHandle GetArrayElementTypeHandle()
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/vm/methodtable.inl
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,6 @@ inline BOOL MethodTable::IsValueType()
return GetFlag(enum_flag_Category_ValueType_Mask) == enum_flag_Category_ValueType;
}

//==========================================================================================
inline CorElementType MethodTable::GetArrayElementType()
{
WRAPPER_NO_CONTRACT;

_ASSERTE (IsArray());
return dac_cast<PTR_ArrayClass>(GetClass())->GetArrayElementType();
}

//==========================================================================================
inline DWORD MethodTable::GetRank()
{
Expand Down

0 comments on commit 84be45b

Please sign in to comment.