diff --git a/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs index 2ec3fa8ee934b..ed9b78357f6e0 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs @@ -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) { diff --git a/src/coreclr/classlibnative/bcltype/arraynative.cpp b/src/coreclr/classlibnative/bcltype/arraynative.cpp index 2e8a41a827910..7a42245f76888 100644 --- a/src/coreclr/classlibnative/bcltype/arraynative.cpp +++ b/src/coreclr/classlibnative/bcltype/arraynative.cpp @@ -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; diff --git a/src/coreclr/classlibnative/bcltype/arraynative.h b/src/coreclr/classlibnative/bcltype/arraynative.h index 19bc1a4fa85ac..56a1dd5b37954 100644 --- a/src/coreclr/classlibnative/bcltype/arraynative.h +++ b/src/coreclr/classlibnative/bcltype/arraynative.h @@ -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); }; diff --git a/src/coreclr/vm/ecalllist.h b/src/coreclr/vm/ecalllist.h index ee1393130bbbb..244982efc6f01 100644 --- a/src/coreclr/vm/ecalllist.h +++ b/src/coreclr/vm/ecalllist.h @@ -360,6 +360,7 @@ FCFuncStart(gCastHelpers) FCFuncEnd() FCFuncStart(gArrayFuncs) + FCFuncElement("GetCorElementTypeOfElementType", ArrayNative::GetCorElementTypeOfElementType) FCFuncElement("IsSimpleCopy", ArrayNative::IsSimpleCopy) FCFuncEnd() @@ -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)