Skip to content

Commit

Permalink
GetCorElementTypeOfElementType
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Jun 2, 2024
1 parent 44445a3 commit b59fa9d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,8 @@ public unsafe int GetLowerBound(int dimension)
return Unsafe.Add(ref RuntimeHelpers.GetMultiDimensionalArrayBounds(this), rank + dimension);
}

internal unsafe CorElementType GetCorElementTypeOfElementType()
{
MethodTable* pMT = RuntimeHelpers.GetMethodTable(this);
CorElementType et = pMT->GetArrayElementTypeHandle().GetVerifierCorElementType();
GC.KeepAlive(this);
return et;
}
[MethodImpl(MethodImplOptions.InternalCall)]
internal extern CorElementType GetCorElementTypeOfElementType();

private unsafe bool IsValueOfElementType(object value)
{
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/classlibnative/bcltype/arraynative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

#include "arraynative.inl"

// Returns a bool to indicate if the array is of primitive types or not.
FCIMPL1(INT32, ArrayNative::GetCorElementTypeOfElementType, ArrayBase* arrayUNSAFE)
{
FCALL_CONTRACT;

_ASSERTE(arrayUNSAFE != NULL);

return arrayUNSAFE->GetArrayElementTypeHandle().GetVerifierCorElementType();
}
FCIMPLEND

extern "C" PCODE QCALLTYPE Array_GetElementConstructorEntrypoint(QCall::TypeHandle pArrayTypeHnd)
{
QCALL_CONTRACT;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/classlibnative/bcltype/arraynative.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct FCALLRuntimeFieldHandle
class ArrayNative
{
public:
static FCDECL1(INT32, GetCorElementTypeOfElementType, ArrayBase* arrayUNSAFE);

static FCDECL2(FC_BOOL_RET, IsSimpleCopy, ArrayBase* pSrc, ArrayBase* pDst);
};
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/ecalllist.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ FCFuncStart(gCastHelpers)
FCFuncEnd()

FCFuncStart(gArrayFuncs)
FCFuncElement("GetCorElementTypeOfElementType", ArrayNative::GetCorElementTypeOfElementType)
FCFuncElement("IsSimpleCopy", ArrayNative::IsSimpleCopy)
FCFuncEnd()

Expand Down Expand Up @@ -535,6 +536,7 @@ FCFuncEnd()
// Note these have to remain sorted by name:namespace pair (Assert will wack you if you don't)
// The sorting is case-sensitive

FCClassElement("Array", "System", gArrayFuncs)
FCClassElement("AssemblyLoadContext", "System.Runtime.Loader", gAssemblyLoadContextFuncs)
FCClassElement("Buffer", "System", gBufferFuncs)
FCClassElement("CastHelpers", "System.Runtime.CompilerServices", gCastHelpers)
Expand Down

0 comments on commit b59fa9d

Please sign in to comment.