DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pArrayClass, ::g_pArrayClass)
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pSZArrayHelperClass, ::g_pSZArrayHelperClass)
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pNullableClass, ::g_pNullableClass)
+#ifdef FEATURE_SPAN_OF_T
+DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pSpanClass, ::g_pSpanClass)
+DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pReadOnlySpanClass, ::g_pReadOnlySpanClass)
+#endif
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pExceptionClass, ::g_pExceptionClass)
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pThreadAbortExceptionClass, ::g_pThreadAbortExceptionClass)
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pOutOfMemoryExceptionClass, ::g_pOutOfMemoryExceptionClass)
// the SZArrayHelper class here.
g_pSZArrayHelperClass = MscorlibBinder::GetClass(CLASS__SZARRAYHELPER);
+#ifdef FEATURE_SPAN_OF_T
+ // Load Span class
+ g_pSpanClass = MscorlibBinder::GetClass(CLASS__SPAN);
+ g_pReadOnlySpanClass = MscorlibBinder::GetClass(CLASS__READONLY_SPAN);
+#endif
+
// Load Nullable class
g_pNullableClass = MscorlibBinder::GetClass(CLASS__NULLABLE);
#define g_ArrayClassName "System.Array"
#define g_NullableName "Nullable`1"
+#ifdef FEATURE_SPAN_OF_T
+#define g_SpanName "Span`1"
+#define g_ReadOnlySpanName "ReadOnlySpan`1"
+#endif
#define g_CollectionsEnumerableItfName "System.Collections.IEnumerable"
#define g_CollectionsEnumeratorClassName "System.Collections.IEnumerator"
MethodTable* pMT = VMClsHnd.GetMethodTable();
- if (pMT == g_TypedReferenceMT)
+ if (pMT->IsByRefLike())
{
- gcPtrs[0] = TYPE_GC_BYREF;
- gcPtrs[1] = TYPE_GC_NONE;
- result = 1;
+ if (pMT == g_TypedReferenceMT
+#ifdef FEATURE_SPAN_OF_T
+ || pMT->HasSameTypeDefAs(g_pSpanClass) || pMT->HasSameTypeDefAs(g_pReadOnlySpanClass)
+#endif
+ )
+ {
+ gcPtrs[0] = TYPE_GC_BYREF;
+ gcPtrs[1] = TYPE_GC_NONE;
+ result = 1;
+ }
+ else
+ {
+ result = 0;
+ }
}
else if (VMClsHnd.IsNativeValueType())
{
MethodTable * pMT = GetHalfBakedMethodTable();
EEClass * pClass = GetHalfBakedClass();
- // We can exit early for generic types - there is just one case to check for.
- if (g_pNullableClass != NULL && bmtGenerics->HasInstantiation())
+ // We can exit early for generic types - there are just a few cases to check for.
+ if (bmtGenerics->HasInstantiation() && g_pNullableClass != NULL)
{
+#ifdef FEATURE_SPAN_OF_T
+ _ASSERTE(g_pSpanClass != NULL);
+ _ASSERTE(g_pReadOnlySpanClass != NULL);
+
+ _ASSERTE(g_pSpanClass->IsByRefLike());
+ _ASSERTE(g_pReadOnlySpanClass->IsByRefLike());
+
+ if (GetCl() == g_pSpanClass->GetCl())
+ {
+ pMT->SetIsByRefLike();
+ return;
+ }
+
+ if (GetCl() == g_pReadOnlySpanClass->GetCl())
+ {
+ pMT->SetIsByRefLike();
+ return;
+ }
+#endif
+
_ASSERTE(g_pNullableClass->IsNullable());
// Pre-compute whether the class is a Nullable<T> so that code:Nullable::IsNullableType is efficient
// This is useful to the performance of boxing/unboxing a Nullable
if (GetCl() == g_pNullableClass->GetCl())
pMT->SetIsNullable();
+
return;
}
{
pMT->SetIsNullable();
}
+#ifdef FEATURE_SPAN_OF_T
+ else if (strcmp(name, g_SpanName) == 0)
+ {
+ pMT->SetIsByRefLike();
+ }
+ else if (strcmp(name, g_ReadOnlySpanName) == 0)
+ {
+ pMT->SetIsByRefLike();
+ }
+#endif
else if (strcmp(name, g_ArgIteratorName) == 0)
{
// Mark the special types that have embeded stack poitners in them
DEFINE_CLASS(NULLABLE, System, Nullable`1)
+#ifdef FEATURE_SPAN_OF_T
+DEFINE_CLASS(SPAN, System, Span`1)
+DEFINE_CLASS(READONLY_SPAN, System, ReadOnlySpan`1)
+#endif
+
// Keep this in sync with System.Globalization.NumberFormatInfo
DEFINE_CLASS_U(Globalization, NumberFormatInfo, NumberFormatInfo)
DEFINE_FIELD_U(numberGroupSizes, NumberFormatInfo, cNumberGroup)
GPTR_IMPL(MethodTable, g_pArrayClass);
GPTR_IMPL(MethodTable, g_pSZArrayHelperClass);
GPTR_IMPL(MethodTable, g_pNullableClass);
+#ifdef FEATURE_SPAN_OF_T
+GPTR_IMPL(MethodTable, g_pSpanClass);
+GPTR_IMPL(MethodTable, g_pReadOnlySpanClass);
+#endif
GPTR_IMPL(MethodTable, g_pExceptionClass);
GPTR_IMPL(MethodTable, g_pThreadAbortExceptionClass);
GPTR_IMPL(MethodTable, g_pOutOfMemoryExceptionClass);
GPTR_DECL(MethodTable, g_pArrayClass);
GPTR_DECL(MethodTable, g_pSZArrayHelperClass);
GPTR_DECL(MethodTable, g_pNullableClass);
+#ifdef FEATURE_SPAN_OF_T
+GPTR_DECL(MethodTable, g_pSpanClass);
+GPTR_DECL(MethodTable, g_pReadOnlySpanClass);
+#endif
GPTR_DECL(MethodTable, g_pExceptionClass);
GPTR_DECL(MethodTable, g_pThreadAbortExceptionClass);
GPTR_DECL(MethodTable, g_pOutOfMemoryExceptionClass);