GCPROTECT_END();
}
-
VOID FmtClassUpdateNative(OBJECTREF *ppProtectedManagedData, BYTE *pNativeData, OBJECTREF *ppCleanupWorkListOnStack)
{
CONTRACTL
// all of the native fields even if one or more of the conversions fail.
//=======================================================================
VOID LayoutUpdateCLR(LPVOID *ppProtectedManagedData, SIZE_T offsetbias, MethodTable *pMT, BYTE *pNativeData)
-{
+{
CONTRACTL
{
THROWS;
// Don't try to destroy/free native the structure on exception, we may not own it. If we do own it and
// are supposed to destroy/free it, we do it upstack (e.g. in a helper called from the marshaling stub).
- FieldMarshaler* pFM = pMT->GetLayoutInfo()->GetFieldMarshalers();
- UINT numReferenceFields = pMT->GetLayoutInfo()->GetNumCTMFields();
+ FieldMarshaler* pFM = pMT->GetLayoutInfo()->GetFieldMarshalers();
+ UINT numReferenceFields = pMT->GetLayoutInfo()->GetNumCTMFields();
struct _gc
{
OBJECTREF pOldCLRValue;
} gc;
- gc.pCLRValue = NULL;
+ gc.pCLRValue = NULL;
gc.pOldCLRValue = NULL;
- LPVOID scalar = NULL;
-
+ LPVOID scalar = NULL;
+
GCPROTECT_BEGIN(gc)
GCPROTECT_BEGININTERIOR(scalar)
{
}
CONTRACTL_END;
+ MethodTable* pMT = GetMethodTable();
+
// would be better to detect this at class load time (that have a nested value
// class with no layout) but don't have a way to know
- if (! GetMethodTable()->GetLayoutInfo())
+ if (!pMT->GetLayoutInfo())
COMPlusThrow(kArgumentException, IDS_NOLAYOUT_IN_EMBEDDED_VALUECLASS);
- LayoutUpdateNative((LPVOID*)ppProtectedCLR, startoffset, GetMethodTable(), (BYTE*)pNative, ppCleanupWorkListOnStack);
+ if (pMT->IsBlittable())
+ {
+ memcpyNoGCRefs(pNative, (BYTE*)(*ppProtectedCLR) + startoffset, pMT->GetNativeSize());
+ }
+ else
+ {
+ LayoutUpdateNative((LPVOID*)ppProtectedCLR, startoffset, pMT, (BYTE*)pNative, ppCleanupWorkListOnStack);
+ }
}
}
CONTRACTL_END;
+ MethodTable* pMT = GetMethodTable();
+
// would be better to detect this at class load time (that have a nested value
// class with no layout) but don't have a way to know
- if (! GetMethodTable()->GetLayoutInfo())
+ if (!pMT->GetLayoutInfo())
COMPlusThrow(kArgumentException, IDS_NOLAYOUT_IN_EMBEDDED_VALUECLASS);
- LayoutUpdateCLR( (LPVOID*)ppProtectedCLR,
- startoffset,
- GetMethodTable(),
- (BYTE *)pNative);
-
-
+ if (pMT->IsBlittable())
+ {
+ memcpyNoGCRefs((BYTE*)(*ppProtectedCLR) + startoffset, pNative, pMT->GetNativeSize());
+ }
+ else
+ {
+ LayoutUpdateCLR((LPVOID*)ppProtectedCLR,
+ startoffset,
+ pMT,
+ (BYTE *)pNative);
+ }
}
}
CONTRACTL_END;
- LayoutDestroyNative(pNativeValue, GetMethodTable());
+ MethodTable* pMT = GetMethodTable();
+
+ if (!pMT->IsBlittable())
+ {
+ LayoutDestroyNative(pNativeValue, pMT);
+ }
}
#endif // CROSSGEN_COMPILE