#define NOT_ARM64_ARG(x) , x
#endif
+#ifdef _TARGET_64BIT_
+#define LOG2_PTRSIZE 3
+#else
+#define LOG2_PTRSIZE 2
+#endif
+
#ifdef _WIN64
- #define LOG2_PTRSIZE 3
#define INVALID_POINTER_CC 0xcccccccccccccccc
#define INVALID_POINTER_CD 0xcdcdcdcdcdcdcdcd
#define FMT_ADDR " %08x`%08x "
#define LFMT_ADDR W(" %08x`%08x ")
#define DBG_ADDR(ptr) (((UINT_PTR) (ptr)) >> 32), (((UINT_PTR) (ptr)) & 0xffffffff)
#else // _WIN64
- #define LOG2_PTRSIZE 2
#define INVALID_POINTER_CC 0xcccccccc
#define INVALID_POINTER_CD 0xcdcdcdcd
#define FMT_ADDR " %08x "
_ASSERTE(pMT->IsClassPreInited());
// Set BaseSize to be size of non-data portion of the array
- DWORD baseSize = ObjSizeOf(ArrayBase);
+ DWORD baseSize = ARRAYBASE_BASESIZE;
if (arrayKind == ELEMENT_TYPE_ARRAY)
baseSize += Rank*sizeof(DWORD)*2;
// This equals the offset of the first pointer if this were an array of entirely pointers, plus the offset of the
// first pointer in the value class
pSeries->SetSeriesOffset(ArrayBase::GetDataPtrOffset(pMT)
- + (sortedSeries[0]->GetSeriesOffset()) - sizeof (Object) );
+ + (sortedSeries[0]->GetSeriesOffset()) - OBJECT_SIZE);
for (index = 0; index < nSeries; index ++)
{
size_t numPtrsInBytes = sortedSeries[index]->GetSeriesSize()
else
{
skip = sortedSeries[0]->GetSeriesOffset() + pElemMT->GetBaseSize()
- - ObjSizeOf(Object) - currentOffset;
+ - OBJECT_BASESIZE - currentOffset;
}
_ASSERTE(!"Module::CreateArrayMethodTable() - unaligned GC info" || IS_ALIGNED(skip, TARGET_POINTER_SIZE));
(S_SIZE_T(2 * sizeof(DWORD))*(S_SIZE_T(dwNumTypes)+S_SIZE_T(1)))));
for (DWORD i = 0; i < dwIndex; i++) {
- pRegularStaticOffsets[i * 2 ] = dwGCHandles[0]*sizeof(OBJECTREF);
+ pRegularStaticOffsets[i * 2 ] = dwGCHandles[0]*TARGET_POINTER_SIZE;
pRegularStaticOffsets[i * 2 + 1] = dwNonGCBytes[0];
}
}
(S_SIZE_T(2 * sizeof(DWORD))*(S_SIZE_T(dwNumTypes)+S_SIZE_T(1)))));
for (DWORD i = 0; i < dwIndex; i++) {
- pThreadStaticOffsets[i * 2 ] = dwGCHandles[1]*sizeof(OBJECTREF);
+ pThreadStaticOffsets[i * 2 ] = dwGCHandles[1]*TARGET_POINTER_SIZE;
pThreadStaticOffsets[i * 2 + 1] = dwNonGCBytes[1];
}
}
dwNonGCBytes[0] = (DWORD) ALIGN_UP(dwNonGCBytes[0], dwAlignment[0]);
// Save current offsets
- pRegularStaticOffsets[dwIndex*2] = dwGCHandles[0]*sizeof(OBJECTREF);
+ pRegularStaticOffsets[dwIndex*2] = dwGCHandles[0]*TARGET_POINTER_SIZE;
pRegularStaticOffsets[dwIndex*2 + 1] = dwNonGCBytes[0];
// Increment for next class
dwNonGCBytes[1] = (DWORD) ALIGN_UP(dwNonGCBytes[1], dwAlignment[1]);
// Save current offsets
- pThreadStaticOffsets[dwIndex*2] = dwGCHandles[1]*sizeof(OBJECTREF);
+ pThreadStaticOffsets[dwIndex*2] = dwGCHandles[1]*TARGET_POINTER_SIZE;
pThreadStaticOffsets[dwIndex*2 + 1] = dwNonGCBytes[1];
// Increment for next class
if (pRegularStaticOffsets != NULL)
{
- pRegularStaticOffsets[dwNumTypes*2] = dwGCHandles[0]*sizeof(OBJECTREF);
+ pRegularStaticOffsets[dwNumTypes*2] = dwGCHandles[0]*TARGET_POINTER_SIZE;
pRegularStaticOffsets[dwNumTypes*2 + 1] = dwNonGCBytes[0];
}
if (pThreadStaticOffsets != NULL)
{
- pThreadStaticOffsets[dwNumTypes*2] = dwGCHandles[1]*sizeof(OBJECTREF);
+ pThreadStaticOffsets[dwNumTypes*2] = dwGCHandles[1]*TARGET_POINTER_SIZE;
pThreadStaticOffsets[dwNumTypes*2 + 1] = dwNonGCBytes[1];
}
// in the object, there is no gc descriptor, and thus no need to adjust
// the pointer to skip the gc descriptor.
- g_pFreeObjectMethodTable->SetBaseSize(ObjSizeOf (ArrayBase));
+ g_pFreeObjectMethodTable->SetBaseSize(ARRAYBASE_BASESIZE);
g_pFreeObjectMethodTable->SetComponentSize(1);
hr = GCHeapUtilities::LoadAndInitialize();
{
ssBuff.Printf(W(" offset %5d (%d w/o Object), size %5d (%5d w/o BaseSize subtr)\n"),
pSeries->GetSeriesOffset(),
- pSeries->GetSeriesOffset() - sizeof(Object),
+ pSeries->GetSeriesOffset() - OBJECT_SIZE,
pSeries->GetSeriesSize(),
pSeries->GetSeriesSize() + GetBaseSize() );
WszOutputDebugString(ssBuff.GetUnicode());
//LF_ALWAYS allowed here because this is controlled by special env var ShouldDumpOnClassLoad
LOG((LF_ALWAYS, LL_ALWAYS, " offset %5d (%d w/o Object), size %5d (%5d w/o BaseSize subtr)\n",
pSeries->GetSeriesOffset(),
- pSeries->GetSeriesOffset() - sizeof(Object),
+ pSeries->GetSeriesOffset() - OBJECT_SIZE,
pSeries->GetSeriesSize(),
pSeries->GetSeriesSize() + GetBaseSize()
));
CORCOMPILE_GCREFMAP_TOKENS newToken = (dwFlags & GC_CALL_INTERIOR) ? GCREFMAP_INTERIOR : GCREFMAP_REF;
- _ASSERTE((*ppObj == NULL) || (*(CORCOMPILE_GCREFMAP_TOKENS *)ppObj == newToken));
+ _ASSERTE((*(CORCOMPILE_GCREFMAP_TOKENS *)ppObj == NULL) || (*(CORCOMPILE_GCREFMAP_TOKENS *)ppObj == newToken));
*(CORCOMPILE_GCREFMAP_TOKENS *)ppObj = newToken;
}
// FieldDesc::GetOffset() does not include the size of Object
if (!pFieldMT->IsValueType())
{
- pResult->offset += sizeof(Object);
+ pResult->offset += OBJECT_SIZE;
}
}
{
// Get offset into the value class of the first pointer field (includes a +Object)
size_t cbSeriesSize = pByValueSeries->GetSeriesSize() + pMT->GetBaseSize();
- size_t cbOffset = pByValueSeries->GetSeriesOffset() - sizeof(Object);
+ size_t cbOffset = pByValueSeries->GetSeriesOffset() - OBJECT_SIZE;
_ASSERTE (cbOffset % TARGET_POINTER_SIZE == 0);
_ASSERTE (cbSeriesSize % TARGET_POINTER_SIZE == 0);
}
else if (!field->GetApproxEnclosingMethodTable()->IsValueType())
{
- result += sizeof(Object);
+ result += OBJECT_SIZE;
}
EE_TO_JIT_TRANSITION();
pMT->SetLoaderModule(pContainingModule);
pMT->SetLoaderAllocator(pContainingModule->GetLoaderAllocator());
pMT->SetInternalCorElementType(ELEMENT_TYPE_CLASS);
- pMT->SetBaseSize(ObjSizeOf(Object));
+ pMT->SetBaseSize(OBJECT_BASESIZE);
#ifdef _DEBUG
pClass->SetDebugClassName("dynamicClass");
if (CorTypeInfo::IsObjRef(pFD->GetFieldType()))
{
// Check that the ref offset is pointer aligned
- if ((pFD->GetOffset_NoLogging() & ((ULONG)sizeof(OBJECTREF) - 1)) != 0)
+ if ((pFD->GetOffset_NoLogging() & ((ULONG)TARGET_POINTER_SIZE - 1)) != 0)
{
badOffset = pFD->GetOffset_NoLogging();
fieldTrust.SetTrust(ExplicitFieldTrust::kNone);
{
CONSISTENCY_CHECK(pSeries <= map->GetHighestSeries());
- memset((void*)&vcLayout[pSeries->GetSeriesOffset()-sizeof(Object)], oref, pSeries->GetSeriesSize() + pMT->GetBaseSize());
+ memset((void*)&vcLayout[pSeries->GetSeriesOffset() - OBJECT_SIZE], oref, pSeries->GetSeriesSize() + pMT->GetBaseSize());
pSeries++;
}
// ref-non-ref-non, and since only ref series are recorded and non-ref series
// are skipped, the max number of series is total instance size / 2 / sizeof(ref).
// But watch out for the case where we have e.g. an instanceSlizeSize of 4.
- DWORD sz = (instanceSliceSize + (2 * sizeof(OBJECTREF)) - 1);
- bmtGCSeries->pSeries = new bmtGCSeriesInfo::Series[sz/2/sizeof(OBJECTREF)];
+ DWORD sz = (instanceSliceSize + (2 * TARGET_POINTER_SIZE) - 1);
+ bmtGCSeries->pSeries = new bmtGCSeriesInfo::Series[sz/2/ TARGET_POINTER_SIZE];
BYTE *loc = pFieldLayout;
BYTE *layoutEnd = pFieldLayout + instanceSliceSize;
CGCDesc::Init( (PVOID) pMT, 1);
pSeries = ((CGCDesc*)pMT)->GetLowestSeries();
pSeries->SetSeriesSize( (size_t) (0) - (size_t) pMT->GetBaseSize());
- pSeries->SetSeriesOffset(sizeof(Object));
+ pSeries->SetSeriesOffset(OBJECT_SIZE);
}
else
#endif // FEATURE_COLLECTIBLE_TYPES
BAD_FORMAT_NOTHROW_ASSERT(pSeries <= CGCDesc::GetCGCDescFromMT(pMT)->GetHighestSeries());
pSeries->SetSeriesSize( (size_t) bmtGCSeries->pSeries[i].len - (size_t) pMT->GetBaseSize() );
- pSeries->SetSeriesOffset(bmtGCSeries->pSeries[i].offset + sizeof(Object) + dwInstanceSliceOffset);
+ pSeries->SetSeriesOffset(bmtGCSeries->pSeries[i].offset + OBJECT_SIZE + dwInstanceSliceOffset);
pSeries++;
}
}
// when the instance is in its "boxed" state.
if (!IsInterface())
{
- DWORD baseSize = Max<DWORD>(bmtFP->NumInstanceFieldBytes + ObjSizeOf(Object), MIN_OBJECT_SIZE);
+ DWORD baseSize = Max<DWORD>(bmtFP->NumInstanceFieldBytes + OBJECT_BASESIZE, MIN_OBJECT_SIZE);
baseSize = (baseSize + ALLOC_ALIGN_CONSTANT) & ~ALLOC_ALIGN_CONSTANT; // m_BaseSize must be aligned
pMT->SetBaseSize(baseSize);
CGCDesc::Init( (PVOID) pMT, 1);
pSeries = ((CGCDesc*)pMT)->GetLowestSeries();
pSeries->SetSeriesSize( (size_t) (0) - (size_t) pMT->GetBaseSize());
- pSeries->SetSeriesOffset(sizeof(Object));
+ pSeries->SetSeriesOffset(OBJECT_SIZE);
}
else
#endif // FEATURE_COLLECTIBLE_TYPES
if (bmtFP->NumInstanceGCPointerFields)
{
// See gcdesc.h for an explanation of why we adjust by subtracting BaseSize
- pSeries->SetSeriesSize( (size_t) (bmtFP->NumInstanceGCPointerFields * sizeof(OBJECTREF)) - (size_t) pMT->GetBaseSize());
- pSeries->SetSeriesOffset(bmtFP->GCPointerFieldStart+sizeof(Object));
+ pSeries->SetSeriesSize( (size_t) (bmtFP->NumInstanceGCPointerFields * TARGET_POINTER_SIZE) - (size_t) pMT->GetBaseSize());
+ pSeries->SetSeriesOffset(bmtFP->GCPointerFieldStart + OBJECT_SIZE);
pSeries++;
}
}
else
{
- pNewMT->SetBaseSize(ObjSizeOf (ArrayBase));
+ pNewMT->SetBaseSize(ARRAYBASE_BASESIZE);
pNewMT->SetComponentSize(static_cast<WORD>(-size));
}
s_pPinHandleTable->InsertValue(size, (HashDatum)pNewMT);
struct RCW;
+#ifdef _TARGET_64BIT_
+#define OBJHEADER_SIZE (sizeof(DWORD) /* m_alignpad */ + sizeof(DWORD) /* m_SyncBlockValue */)
+#else
+#define OBJHEADER_SIZE sizeof(DWORD) /* m_SyncBlockValue */
+#endif
+
+#define OBJECT_SIZE TARGET_POINTER_SIZE /* m_pMethTab */
+#define OBJECT_BASESIZE (OBJHEADER_SIZE + OBJECT_SIZE)
+
+#ifdef _TARGET_64BIT_
+#define ARRAYBASE_SIZE (OBJECT_SIZE /* m_pMethTab */ + sizeof(DWORD) /* m_NumComponents */ + sizeof(DWORD) /* pad */)
+#else
+#define ARRAYBASE_SIZE (OBJECT_SIZE /* m_pMethTab */ + sizeof(DWORD) /* m_NumComponents */)
+#endif
+
+#define ARRAYBASE_BASESIZE (OBJHEADER_SIZE + ARRAYBASE_SIZE)
+
//
// The generational GC requires that every object be at least 12 bytes
// in size.
-#define MIN_OBJECT_SIZE (2*sizeof(BYTE*) + sizeof(ObjHeader))
+#define MIN_OBJECT_SIZE (2*TARGET_POINTER_SIZE + OBJHEADER_SIZE)
#define PTRALIGNCONST (DATA_ALIGNMENT-1)
{
LIMITED_METHOD_DAC_CONTRACT;
- return ObjSizeOf(Object) + sizeof(DWORD) /* length */ + sizeof(WCHAR) /* null terminator */;
+ return OBJECT_BASESIZE + sizeof(DWORD) /* length */ + sizeof(WCHAR) /* null terminator */;
}
__forceinline /*static*/ SIZE_T StringObject::GetSize(DWORD strLen)
_ASSERTE(pMT->IsArray());
#endif // DACCESS_COMPILE
// The -sizeof(ObjHeader) is because of the sync block, which is before "this"
- return pMT->GetBaseSize() - sizeof(ObjHeader);
+ return pMT->GetBaseSize() - OBJHEADER_SIZE;
}
inline /* static */ unsigned ArrayBase::GetBoundsOffset(MethodTable* pMT)
WRAPPER_NO_CONTRACT;
_ASSERTE(pMT->IsArray());
if (!pMT->IsMultiDimArray())
- return(offsetof(ArrayBase, m_NumComponents));
+ return OBJECT_SIZE /* offset(ArrayBase, m_NumComponents */;
_ASSERTE(pMT->GetInternalCorElementType() == ELEMENT_TYPE_ARRAY);
- return sizeof(ArrayBase);
+ return ARRAYBASE_SIZE;
}
inline /* static */ unsigned ArrayBase::GetLowerBoundsOffset(MethodTable* pMT)
{
dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, dwAlignment);
- return (DWORD)sizeof(Object) + dwCumulativeInstanceFieldPos - dwOffsetBias;
+ return OBJECT_SIZE + dwCumulativeInstanceFieldPos - dwOffsetBias;
}
BOOL ReadyToRunInfo::IsImageVersionAtLeast(int majorVersion, int minorVersion)
while (srcPtr < srcPtrStop)
{
(*fn)(dac_cast<PTR_PTR_Object>(srcPtr), sc, 0);
- srcPtr++;
+ srcPtr = (PTR_OBJECTREF)(PTR_BYTE(srcPtr) + TARGET_POINTER_SIZE);
}
cur--;
} while (cur >= last);
#include "synch.h"
-
// At a negative offset from each Object is an ObjHeader. The 'size' of the
// object includes these bytes. However, we rely on the previous object allocation
// to zero out the ObjHeader for the current allocation. And the limits of the
#endif
};
-
-// The true size of an object is whatever C++ thinks, plus the ObjHeader we
-// allocate before it.
-
-#define ObjSizeOf(c) (sizeof(c) + sizeof(ObjHeader))
-
-
inline void AwareLock::SetPrecious()
{
LIMITED_METHOD_CONTRACT;