DisplayWriteFieldInt( numElementsHot, ctorInfo->numElementsHot,
ModuleCtorInfo, SLIM_MODULE_TBLS );
DisplayWriteFieldAddress( ppMT, DPtrToPreferredAddr(ctorInfo->ppMT),
- ctorInfo->numElements * sizeof(MethodTable*),
+ ctorInfo->numElements * sizeof(RelativePointer<MethodTable*>),
ModuleCtorInfo, SLIM_MODULE_TBLS );
/* REVISIT_TODO Tue 03/21/2006
* is cctorInfoHot and cctorInfoCold actually have anything interesting
{
PTR_InterfaceInfo ifMap = mt->GetInterfaceMap();
m_display->StartArrayWithOffset( "InterfaceMap",
- offsetof(MethodTable, m_pMultipurposeSlot2),
+ offsetof(MethodTable, m_pInterfaceMap),
sizeof(void*),
NULL );
for( unsigned i = 0; i < mt->GetNumInterfaces(); ++i )
DPtrToPreferredAddr(genStatics),
sizeof(*genStatics) );
- PTR_FieldDesc fieldDescs = genStatics->m_pFieldDescs;
+ PTR_FieldDesc fieldDescs = ReadPointerMaybeNull((GenericsStaticsInfo *) genStatics, &GenericsStaticsInfo::m_pFieldDescs);
if( fieldDescs == NULL )
{
DisplayWriteFieldPointer( m_pFieldDescs, NULL, GenericsStaticsInfo,
LIMITED_METHOD_CONTRACT;
SetValueMaybeNull((TADDR)this, addr);
}
+
+ FORCEINLINE void SetValueVolatile(PTR_TYPE addr)
+ {
+ LIMITED_METHOD_CONTRACT;
+ SetValue(addr);
+ }
#endif
#ifndef DACCESS_COMPILE
RelativeFixupPointer<PTR_TYPE>& operator = (const RelativeFixupPointer<PTR_TYPE> &) =delete;
RelativeFixupPointer<PTR_TYPE>& operator = (RelativeFixupPointer<PTR_TYPE> &&) =delete;
+ // Default constructor
+ RelativeFixupPointer<PTR_TYPE>() {}
+
// Returns whether the encoded pointer is NULL.
BOOL IsNull() const
{
PTR_TYPE GetValue(TADDR base) const
{
LIMITED_METHOD_DAC_CONTRACT;
- PRECONDITION(!IsNull());
return dac_cast<PTR_TYPE>(m_ptr);
}
}
// Returns value of the encoded pointer. The pointer can be NULL.
+ PTR_TYPE GetValueMaybeNull() const
+ {
+ LIMITED_METHOD_DAC_CONTRACT;
+ return dac_cast<PTR_TYPE>(m_ptr);
+ }
+
+ // Returns value of the encoded pointer. The pointer can be NULL.
PTR_TYPE GetValueMaybeNull(TADDR base) const
{
LIMITED_METHOD_DAC_CONTRACT;
return dac_cast<DPTR(PlainPointer<PTR_TYPE>)>(base)->GetValueMaybeNull(base);
}
+#ifndef DACCESS_COMPILE
void SetValue(PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
void SetValue(TADDR base, PTR_TYPE addr)
{
LIMITED_METHOD_CONTRACT;
- PRECONDITION(addr != NULL);
m_ptr = dac_cast<TADDR>(addr);
}
m_ptr = dac_cast<TADDR>(addr);
}
-#ifndef DACCESS_COMPILE
// Set encoded value of the pointer. The value can be NULL.
// Does not need explicit base and thus can be used in non-DAC builds only.
FORCEINLINE void SetValueMaybeNull(PTR_TYPE addr)
LIMITED_METHOD_CONTRACT;
return SetValueMaybeNull((TADDR)this, addr);
}
-#endif
// Static version of SetValueMaybeNull. It is meant to simplify access to arrays of pointers.
FORCEINLINE static void SetValueMaybeNullAtPtr(TADDR base, PTR_TYPE addr)
dac_cast<DPTR(PlainPointer<PTR_TYPE>)>(base)->SetValueMaybeNull(base, addr);
}
+ FORCEINLINE void SetValueVolatile(PTR_TYPE addr)
+ {
+ LIMITED_METHOD_CONTRACT;
+ VolatileStore((PTR_TYPE *)(&m_ptr), addr);
+ }
+#endif
+
private:
TADDR m_ptr;
};
}
-ArrayDPTR(FixupPointer<PTR_MethodTable>) ModuleCtorInfo::GetGCStaticMTs(DWORD index)
+ArrayDPTR(RelativeFixupPointer<PTR_MethodTable>) ModuleCtorInfo::GetGCStaticMTs(DWORD index)
{
LIMITED_METHOD_CONTRACT;
#endif // _DEBUG
}
+#ifndef DACCESS_COMPILE
+
void ModuleCtorInfo::Save(DataImage *image, CorProfileData *profileData)
{
STANDARD_VM_CONTRACT;
// items numElementsHot...i-1 are cold
for (i = 0; i < numElements; i++)
{
- MethodTable *ppMTTemp = ppMT[i];
+ MethodTable *ppMTTemp = ppMT[i].GetValue();
// Count the number of boxed statics along the way
totalBoxedStatics += ppMTTemp->GetNumBoxedRegularStatics();
if (hot)
{
// swap ppMT[i] and ppMT[numElementsHot] to maintain the loop invariant
- ppMT[i] = ppMT[numElementsHot];
- ppMT[numElementsHot] = ppMTTemp;
+ ppMT[i].SetValue(ppMT[numElementsHot].GetValue());
+ ppMT[numElementsHot].SetValue(ppMTTemp);
numElementsHot++;
}
for (i = 0; i < numElementsHot; i++)
{
- hashArray[i] = GenerateHash(ppMT[i], HOT);
+ hashArray[i] = GenerateHash(ppMT[i].GetValue(), HOT);
}
for (i = numElementsHot; i < numElements; i++)
{
- hashArray[i] = GenerateHash(ppMT[i], COLD);
+ hashArray[i] = GenerateHash(ppMT[i].GetValue(), COLD);
}
// Sort the two arrays by hash values to create regions with the same hash values.
// make cctorInfoCold point to the first cold element
cctorInfoCold = cctorInfoHot + numElementsHot;
- ppHotGCStaticsMTs = (totalBoxedStatics != 0) ? new FixupPointer<PTR_MethodTable>[totalBoxedStatics] : NULL;
+ ppHotGCStaticsMTs = (totalBoxedStatics != 0) ? new RelativeFixupPointer<PTR_MethodTable>[totalBoxedStatics] : NULL;
numHotGCStaticsMTs = totalBoxedStatics;
DWORD iGCStaticMT = 0;
ppColdGCStaticsMTs = ppHotGCStaticsMTs + numHotGCStaticsMTs;
}
- MethodTable* pMT = ppMT[i];
+ MethodTable* pMT = ppMT[i].GetValue();
ClassCtorInfoEntry* pEntry = &cctorInfoHot[i];
WORD numBoxedStatics = pMT->GetNumBoxedRegularStatics();
== (iGCStaticMT - pEntry->firstBoxedStaticMTIndex) * sizeof(MethodTable*));
TypeHandle th = pField->GetFieldTypeHandleThrowing();
- ppHotGCStaticsMTs[iGCStaticMT++].SetValue(th.GetMethodTable());
+ ppHotGCStaticsMTs[iGCStaticMT++].SetValueMaybeNull(th.GetMethodTable());
numFoundBoxedStatics++;
}
if (numElements > 0)
image->StoreStructure(ppMT,
- sizeof(MethodTable *) * numElements,
+ sizeof(RelativePointer<MethodTable *>) * numElements,
DataImage::ITEM_MODULE_CCTOR_INFO_HOT);
if (numElements > numElementsHot)
if ( numHotGCStaticsMTs )
{
// Save the mt templates
- image->StoreStructure( ppHotGCStaticsMTs, numHotGCStaticsMTs * sizeof(MethodTable*),
+ image->StoreStructure( ppHotGCStaticsMTs, numHotGCStaticsMTs * sizeof(RelativeFixupPointer<MethodTable*>),
DataImage::ITEM_GC_STATIC_HANDLES_HOT);
}
else
if ( numColdGCStaticsMTs )
{
// Save the hot mt templates
- image->StoreStructure( ppColdGCStaticsMTs, numColdGCStaticsMTs * sizeof(MethodTable*),
+ image->StoreStructure( ppColdGCStaticsMTs, numColdGCStaticsMTs * sizeof(RelativeFixupPointer<MethodTable*>),
DataImage::ITEM_GC_STATIC_HANDLES_COLD);
}
else
}
}
+#endif // !DACCESS_COMPILE
bool Module::AreAllClassesFullyLoaded()
{
for (DWORD i=0; i<numElements; i++)
{
- image->FixupPointerField(ppMT, i * sizeof(ppMT[0]));
+ image->FixupRelativePointerField(ppMT, i * sizeof(ppMT[0]));
}
}
else
// This class is contained so do not enumerate 'this'.
DacEnumMemoryRegion(dac_cast<TADDR>(ppMT), numElements *
- sizeof(TADDR));
+ sizeof(RelativePointer<MethodTable *>));
DacEnumMemoryRegion(dac_cast<TADDR>(cctorInfoHot), numElementsHot *
sizeof(ClassCtorInfoEntry));
DacEnumMemoryRegion(dac_cast<TADDR>(cctorInfoCold),
DWORD numElements;
DWORD numLastAllocated;
DWORD numElementsHot;
- DPTR(PTR_MethodTable) ppMT; // size is numElements
+ DPTR(RelativePointer<PTR_MethodTable>) ppMT; // size is numElements
PTR_ClassCtorInfoEntry cctorInfoHot; // size is numElementsHot
PTR_ClassCtorInfoEntry cctorInfoCold; // size is numElements-numElementsHot
DWORD numHotHashes;
DWORD numColdHashes;
- ArrayDPTR(FixupPointer<PTR_MethodTable>) ppHotGCStaticsMTs; // hot table
- ArrayDPTR(FixupPointer<PTR_MethodTable>) ppColdGCStaticsMTs; // cold table
+ ArrayDPTR(RelativeFixupPointer<PTR_MethodTable>) ppHotGCStaticsMTs; // hot table
+ ArrayDPTR(RelativeFixupPointer<PTR_MethodTable>) ppColdGCStaticsMTs; // cold table
DWORD numHotGCStaticsMTs;
DWORD numColdGCStaticsMTs;
return hashVal;
};
- ArrayDPTR(FixupPointer<PTR_MethodTable>) GetGCStaticMTs(DWORD index);
+ ArrayDPTR(RelativeFixupPointer<PTR_MethodTable>) GetGCStaticMTs(DWORD index);
+
+ PTR_MethodTable GetMT(DWORD i)
+ {
+ LIMITED_METHOD_DAC_CONTRACT;
+ return ppMT[i].GetValue(dac_cast<TADDR>(ppMT) + i * sizeof(RelativePointer<PTR_MethodTable>));
+ }
#ifdef FEATURE_PREJIT
class ClassCtorInfoEntryArraySort : public CQuickSort<DWORD>
{
private:
- PTR_MethodTable *m_pBase1;
+ DPTR(RelativePointer<PTR_MethodTable>) m_pBase1;
public:
//Constructor
- ClassCtorInfoEntryArraySort(DWORD *base, PTR_MethodTable *base1, int count)
+ ClassCtorInfoEntryArraySort(DWORD *base, DPTR(RelativePointer<PTR_MethodTable>) base1, int count)
: CQuickSort<DWORD>(base, count)
{
WRAPPER_NO_CONTRACT;
return 1;
}
+#ifndef DACCESS_COMPILE
// Swap is overwriten so that we can sort both the MethodTable pointer
// array and the ClassCtorInfoEntry array in parrallel.
FORCEINLINE void Swap(SSIZE_T iFirst, SSIZE_T iSecond)
m_pBase[iFirst] = m_pBase[iSecond];
m_pBase[iSecond] = sTemp;
- sTemp1 = m_pBase1[iFirst];
- m_pBase1[iFirst] = m_pBase1[iSecond];
- m_pBase1[iSecond] = sTemp1;
+ sTemp1 = m_pBase1[iFirst].GetValueMaybeNull();
+ m_pBase1[iFirst].SetValueMaybeNull(m_pBase1[iSecond].GetValueMaybeNull());
+ m_pBase1[iSecond].SetValueMaybeNull(sTemp1);
}
+#endif // !DACCESS_COMPILE
};
#endif // FEATURE_PREJIT
};
void FixupPointerField(PVOID p, SSIZE_T offset);
void FixupRelativePointerField(PVOID p, SSIZE_T offset);
+ template<typename T, typename PT>
+ void FixupPlainOrRelativePointerField(const T *base, const RelativePointer<PT> T::* pPointerFieldMember)
+ {
+ STANDARD_VM_CONTRACT;
+ SSIZE_T offset = (SSIZE_T) &(base->*pPointerFieldMember) - (SSIZE_T) base;
+ FixupRelativePointerField((PVOID)base, offset);
+ }
+
+ template<typename T, typename C, typename PT>
+ void FixupPlainOrRelativePointerField(const T *base, const C T::* pFirstPointerFieldMember, const RelativePointer<PT> C::* pSecondPointerFieldMember)
+ {
+ STANDARD_VM_CONTRACT;
+ const RelativePointer<PT> *ptr = &(base->*pFirstPointerFieldMember.*pSecondPointerFieldMember);
+ SSIZE_T offset = (SSIZE_T) ptr - (SSIZE_T) base;
+ FixupRelativePointerField((PVOID)base, offset);
+ }
+
+ template<typename T, typename PT>
+ void FixupPlainOrRelativePointerField(const T *base, const PlainPointer<PT> T::* pPointerFieldMember)
+ {
+ STANDARD_VM_CONTRACT;
+ SSIZE_T offset = (SSIZE_T) &(base->*pPointerFieldMember) - (SSIZE_T) base;
+ FixupPointerField((PVOID)base, offset);
+ }
+
+ template<typename T, typename C, typename PT>
+ void FixupPlainOrRelativePointerField(const T *base, const C T::* pFirstPointerFieldMember, const PlainPointer<PT> C::* pSecondPointerFieldMember)
+ {
+ STANDARD_VM_CONTRACT;
+ const PlainPointer<PT> *ptr = &(base->*pFirstPointerFieldMember.*pSecondPointerFieldMember);
+ SSIZE_T offset = (SSIZE_T) ptr - (SSIZE_T) base;
+ FixupPointerField((PVOID)base, offset);
+ }
+
void FixupField(PVOID p, SSIZE_T offset, PVOID pTarget, SSIZE_T targetOffset = 0, ZapRelocationType type = IMAGE_REL_BASED_PTR);
+ template<typename T, typename PT>
+ void FixupPlainOrRelativeField(const T *base, const RelativePointer<PT> T::* pPointerFieldMember, PVOID pTarget, SSIZE_T targetOffset = 0)
+ {
+ STANDARD_VM_CONTRACT;
+ SSIZE_T offset = (SSIZE_T) &(base->*pPointerFieldMember) - (SSIZE_T) base;
+ FixupField((PVOID)base, offset, pTarget, targetOffset, IMAGE_REL_BASED_RELPTR);
+ }
+
+ template<typename T, typename PT>
+ void FixupPlainOrRelativeField(const T *base, const PlainPointer<PT> T::* pPointerFieldMember, PVOID pTarget, SSIZE_T targetOffset = 0)
+ {
+ STANDARD_VM_CONTRACT;
+ SSIZE_T offset = (SSIZE_T) &(base->*pPointerFieldMember) - (SSIZE_T) base;
+ FixupField((PVOID)base, offset, pTarget, targetOffset, IMAGE_REL_BASED_PTR);
+ }
+
void FixupFieldToNode(PVOID p, SSIZE_T offset, ZapNode * pTarget, SSIZE_T targetOffset = 0, ZapRelocationType type = IMAGE_REL_BASED_PTR);
void FixupFieldToNode(PVOID p, SSIZE_T offset, ZapStoredStructure * pTarget, SSIZE_T targetOffset = 0, ZapRelocationType type = IMAGE_REL_BASED_PTR)
return FixupFieldToNode(p, offset, (ZapNode *)pTarget, targetOffset, type);
}
+ template<typename T, typename PT>
+ void FixupPlainOrRelativeFieldToNode(const T *base, const RelativePointer<PT> T::* pPointerFieldMember, ZapNode * pTarget, SSIZE_T targetOffset = 0)
+ {
+ STANDARD_VM_CONTRACT;
+ SSIZE_T offset = (SSIZE_T) &(base->*pPointerFieldMember) - (SSIZE_T) base;
+ FixupFieldToNode((PVOID)base, offset, pTarget, targetOffset, IMAGE_REL_BASED_RELPTR);
+ }
+
+ template<typename T, typename PT>
+ void FixupPlainOrRelativeFieldToNode(const T *base, const RelativePointer<PT> T::* pPointerFieldMember, ZapStoredStructure * pTarget, SSIZE_T targetOffset = 0)
+ {
+ return FixupPlainOrRelativeFieldToNode(base, pPointerFieldMember, (ZapNode *)pTarget, targetOffset);
+ }
+
+ template<typename T, typename PT>
+ void FixupPlainOrRelativeFieldToNode(const T *base, const PlainPointer<PT> T::* pPointerFieldMember, ZapNode * pTarget, SSIZE_T targetOffset = 0)
+ {
+ STANDARD_VM_CONTRACT;
+ SSIZE_T offset = (SSIZE_T) &(base->*pPointerFieldMember) - (SSIZE_T) base;
+ FixupFieldToNode((PVOID)base, offset, pTarget, targetOffset, IMAGE_REL_BASED_PTR);
+ }
+
+ template<typename T, typename PT>
+ void FixupPlainOrRelativeFieldToNode(const T *base, const PlainPointer<PT> T::* pPointerFieldMember, ZapStoredStructure * pTarget, SSIZE_T targetOffset = 0)
+ {
+ return FixupPlainOrRelativeFieldToNode(base, pPointerFieldMember, (ZapNode *)pTarget, targetOffset);
+ }
+
BOOL IsStored(const void *data)
{ WRAPPER_NO_CONTRACT; return m_structures.LookupPtr(data) != NULL; }
m_wNumInterfaces = wNumInterfaces;
CONSISTENCY_CHECK(IS_ALIGNED(iMap, sizeof(void*)));
- m_pInterfaceMap = iMap;
+ m_pInterfaceMap.SetValue(iMap);
}
//==========================================================================================
*(((DWORD_PTR *)pNewItfMap) - 1) = NumDynAddedInterfaces + 1;
// Switch the old interface map with the new one.
- VolatileStore(EnsureWritablePages(&m_pInterfaceMap), pNewItfMap);
+ EnsureWritablePages(&m_pInterfaceMap);
+ m_pInterfaceMap.SetValueVolatile(pNewItfMap);
// Log the fact that we leaked the interface vtable map.
#ifdef _DEBUG
pInfo->m_DynamicTypeID = (SIZE_T)-1;
}
- pInfo->m_pFieldDescs = pStaticFieldDescs;
+ pInfo->m_pFieldDescs.SetValueMaybeNull(pStaticFieldDescs);
}
#endif // !DACCESS_COMPILE
OBJECTREF* pStaticSlots = (OBJECTREF*)(pStaticBase + pClassCtorInfoEntry->firstBoxedStaticOffset);
GCPROTECT_BEGININTERIOR(pStaticSlots);
- ArrayDPTR(FixupPointer<PTR_MethodTable>) ppMTs = GetLoaderModule()->GetZapModuleCtorInfo()->
+ ArrayDPTR(RelativeFixupPointer<PTR_MethodTable>) ppMTs = GetLoaderModule()->GetZapModuleCtorInfo()->
GetGCStaticMTs(pClassCtorInfoEntry->firstBoxedStaticMTIndex);
DWORD numBoxedStatics = pClassCtorInfoEntry->numBoxedStatics;
{
_ASSERTE(numElements == numLastAllocated);
- MethodTable ** ppOldMTEntries = ppMT;
+ RelativePointer<MethodTable *> *ppOldMTEntries = ppMT;
#ifdef _PREFAST_
#pragma warning(push)
#pragma warning(pop)
#endif // _PREFAST_
- ppMT = new MethodTable* [numNewAllocated];
+ ppMT = new RelativePointer<MethodTable *> [numNewAllocated];
_ASSERTE(ppMT);
- memcpy(ppMT, ppOldMTEntries, sizeof(MethodTable *) * numLastAllocated);
- memset(ppMT + numLastAllocated, 0, sizeof(MethodTable *) * (numNewAllocated - numLastAllocated));
+ for (unsigned index = 0; index < numLastAllocated; ++index)
+ {
+ ppMT[index].SetValueMaybeNull(ppOldMTEntries[index].GetValueMaybeNull());
+ }
+
+ for (unsigned index = numLastAllocated; index < numNewAllocated; ++index)
+ {
+ ppMT[index].SetValueMaybeNull(NULL);
+ }
delete[] ppOldMTEntries;
// Note the use of two "parallel" arrays. We do this to keep the workingset smaller since we
// often search (in GetClassCtorInfoIfExists) for a methodtable pointer but never actually find it.
- ppMT[numElements] = pMethodTable;
+ ppMT[numElements].SetValue(pMethodTable);
numElements++;
}
if (IsCanonicalMethodTable())
{
// Pointer to EEClass
- image->FixupPointerField(this, offsetof(MethodTable, m_pEEClass));
+ image->FixupPlainOrRelativePointerField(this, &MethodTable::m_pEEClass);
}
else
{
if (image->CanHardBindToZapModule(pCanonMT->GetLoaderModule()))
{
// Pointer to canonical methodtable
- image->FixupField(this, offsetof(MethodTable, m_pCanonMT), pCanonMT, UNION_METHODTABLE);
+ image->FixupPlainOrRelativeField(this, &MethodTable::m_pCanonMT, pCanonMT, UNION_METHODTABLE);
}
else
{
if (pImport != NULL)
{
- image->FixupFieldToNode(this, offsetof(MethodTable, m_pCanonMT), pImport, UNION_INDIRECTION);
+ image->FixupPlainOrRelativeFieldToNode(this, &MethodTable::m_pCanonMT, pImport, UNION_INDIRECTION);
}
}
- image->FixupField(this, offsetof(MethodTable, m_pLoaderModule), pZapModule);
+ image->FixupField(this, offsetof(MethodTable, m_pLoaderModule), pZapModule, 0, IMAGE_REL_BASED_RELPTR);
#ifdef _DEBUG
image->FixupPointerField(this, offsetof(MethodTable, debug_m_szClassName));
if (HasInterfaceMap())
{
- image->FixupPointerField(this, offsetof(MethodTable, m_pMultipurposeSlot2));
+ image->FixupPlainOrRelativePointerField(this, &MethodTable::m_pInterfaceMap);
FixupExtraInterfaceInfo(image);
}
{
GenericsStaticsInfo *pInfo = GetGenericsStaticsInfo();
- image->FixupPointerField(this, (BYTE *)&pInfo->m_pFieldDescs - (BYTE *)this);
+ image->FixupRelativePointerField(this, (BYTE *)&pInfo->m_pFieldDescs - (BYTE *)this);
if (!isCanonical)
{
for (DWORD i = 0; i < GetClass()->GetNumStaticFields(); i++)
// If we have an indirection cell then restore the m_pCanonMT and its module pointer
//
- if (union_getLowBits(m_pCanonMT) == UNION_INDIRECTION)
+ if (union_getLowBits(m_pCanonMT.GetValue()) == UNION_INDIRECTION)
{
- Module::RestoreMethodTablePointerRaw((MethodTable **)(union_getPointer(m_pCanonMT)),
+ Module::RestoreMethodTablePointerRaw((MethodTable **)(union_getPointer(m_pCanonMT.GetValue())),
GetLoaderModule(), CLASS_LOAD_UNRESTORED);
}
// strings have component size2, all other non-arrays should have 0
_ASSERTE((GetComponentSize() <= 2) || IsArray());
- if (m_pEEClass == NULL)
+ if (m_pEEClass.IsNull())
{
if (IsAsyncPinType())
{
if (HasBoxedRegularStatics())
{
ModuleCtorInfo *pModuleCtorInfo = GetZapModule()->GetZapModuleCtorInfo();
- DPTR(PTR_MethodTable) ppMT = pModuleCtorInfo->ppMT;
+ DPTR(RelativePointer<PTR_MethodTable>) ppMT = pModuleCtorInfo->ppMT;
PTR_DWORD hotHashOffsets = pModuleCtorInfo->hotHashOffsets;
PTR_DWORD coldHashOffsets = pModuleCtorInfo->coldHashOffsets;
for (DWORD i = hotHashOffsets[hash]; i != hotHashOffsets[hash + 1]; i++)
{
- _ASSERTE(ppMT[i]);
- if (dac_cast<TADDR>(ppMT[i]) == dac_cast<TADDR>(this))
+ _ASSERTE(!ppMT[i].IsNull());
+ if (dac_cast<TADDR>(pModuleCtorInfo->GetMT(i)) == dac_cast<TADDR>(this))
{
return pModuleCtorInfo->cctorInfoHot + i;
}
for (DWORD i = coldHashOffsets[hash]; i != coldHashOffsets[hash + 1]; i++)
{
- _ASSERTE(ppMT[i]);
- if (dac_cast<TADDR>(ppMT[i]) == dac_cast<TADDR>(this))
+ _ASSERTE(!ppMT[i].IsNull());
+ if (dac_cast<TADDR>(pModuleCtorInfo->GetMT(i)) == dac_cast<TADDR>(this))
{
return pModuleCtorInfo->cctorInfoCold + (i - pModuleCtorInfo->numElementsHot);
}
struct GenericsStaticsInfo
{
// Pointer to field descs for statics
- PTR_FieldDesc m_pFieldDescs;
+ RelativePointer<PTR_FieldDesc> m_pFieldDescs;
// Method table ID for statics
SIZE_T m_DynamicTypeID;
inline void SetClass(EEClass *pClass)
{
LIMITED_METHOD_CONTRACT;
- m_pEEClass = pClass;
+ m_pEEClass.SetValue(pClass);
}
inline void SetCanonicalMethodTable(MethodTable * pMT)
{
- m_pCanonMT = (TADDR)pMT | MethodTable::UNION_METHODTABLE;
+ m_pCanonMT.SetValue((TADDR)pMT | MethodTable::UNION_METHODTABLE);
}
#endif
{
WRAPPER_NO_CONTRACT;
_ASSERTE(HasGenericsStaticsInfo());
- return GetGenericsStaticsInfo()->m_pFieldDescs;
+ return ReadPointerMaybeNull((GenericsStaticsInfo *)GetGenericsStaticsInfo(), &GenericsStaticsInfo::m_pFieldDescs);
}
BOOL HasCrossModuleGenericStaticsInfo()
// for enum_flag_HasIndirectParentMethodTable.
TADDR m_pParentMethodTable;
- PTR_Module m_pLoaderModule; // LoaderModule. It is equal to the ZapModule in ngened images
+ RelativePointer<PTR_Module> m_pLoaderModule; // LoaderModule. It is equal to the ZapModule in ngened images
PTR_MethodTableWriteableData m_pWriteableData;
static const TADDR UNION_MASK = 3;
union {
- EEClass * m_pEEClass;
- TADDR m_pCanonMT;
+#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_)
+ RelativePointer<DPTR(EEClass)> m_pEEClass;
+ RelativePointer<TADDR> m_pCanonMT;
+#else
+ PlainPointer<DPTR(EEClass)> m_pEEClass;
+ PlainPointer<TADDR> m_pCanonMT;
+#endif
};
__forceinline static LowBits union_getLowBits(TADDR pCanonMT)
public:
union
{
- InterfaceInfo_t * m_pInterfaceMap;
+#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_)
+ RelativePointer<PTR_InterfaceInfo> m_pInterfaceMap;
+#else
+ PlainPointer<PTR_InterfaceInfo> m_pInterfaceMap;
+#endif
TADDR m_pMultipurposeSlot2;
};
{
LIMITED_METHOD_DAC_CONTRACT;
+ TADDR addr = ReadPointer(this, &MethodTable::m_pCanonMT);
+
#ifdef _DEBUG
- LowBits lowBits = union_getLowBits(m_pCanonMT);
+ LowBits lowBits = union_getLowBits(addr);
if (lowBits == UNION_EECLASS)
{
- return PTR_EEClass(m_pCanonMT);
+ return PTR_EEClass(addr);
}
else if (lowBits == UNION_METHODTABLE)
{
// pointer to canonical MethodTable.
- TADDR canonicalMethodTable = union_getPointer(m_pCanonMT);
- return PTR_EEClass(PTR_MethodTable(canonicalMethodTable)->m_pCanonMT);
+ TADDR canonicalMethodTable = union_getPointer(addr);
+ return PTR_EEClass(ReadPointer((MethodTable *) PTR_MethodTable(canonicalMethodTable), &MethodTable::m_pCanonMT));
}
#ifdef FEATURE_PREJIT
else if (lowBits == UNION_INDIRECTION)
{
// pointer to indirection cell that points to canonical MethodTable
- TADDR canonicalMethodTable = *PTR_TADDR(union_getPointer(m_pCanonMT));
- return PTR_EEClass(PTR_MethodTable(canonicalMethodTable)->m_pCanonMT);
+ TADDR canonicalMethodTable = *PTR_TADDR(union_getPointer(addr));
+ return PTR_EEClass(ReadPointer((MethodTable *) PTR_MethodTable(canonicalMethodTable), &MethodTable::m_pCanonMT));
}
#endif
#ifdef DACCESS_COMPILE
#else
- TADDR addr = m_pCanonMT;
-
if ((addr & 2) == 0)
{
// pointer to EEClass
{
// pointer to indirection cell that points to canonical MethodTable
TADDR canonicalMethodTable = *PTR_TADDR(addr - 3);
- return PTR_EEClass(PTR_MethodTable(canonicalMethodTable)->m_pCanonMT);
+ return PTR_EEClass(ReadPointer((MethodTable *) PTR_MethodTable(canonicalMethodTable), &MethodTable::m_pCanonMT));
}
#endif
// pointer to canonical MethodTable.
- return PTR_EEClass(PTR_MethodTable(addr - 2)->m_pCanonMT);
+ return PTR_EEClass(ReadPointer((MethodTable *) PTR_MethodTable(addr - 2), &MethodTable::m_pCanonMT));
#endif
}
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
- LowBits lowBits = union_getLowBits(m_pCanonMT);
+ TADDR addr = ReadPointer(this, &MethodTable::m_pCanonMT);
+
+ LowBits lowBits = union_getLowBits(addr);
if (lowBits == UNION_EECLASS)
{
- return (m_pEEClass != NULL);
+ return !m_pEEClass.IsNull();
}
else if (lowBits == UNION_METHODTABLE)
{
// pointer to canonical MethodTable.
- TADDR canonicalMethodTable = union_getPointer(m_pCanonMT);
- return (PTR_MethodTable(canonicalMethodTable)->m_pEEClass != NULL);
+ TADDR canonicalMethodTable = union_getPointer(addr);
+ return !PTR_MethodTable(canonicalMethodTable)->m_pEEClass.IsNull();
}
#ifdef FEATURE_PREJIT
else if (lowBits == UNION_INDIRECTION)
{
// pointer to indirection cell that points to canonical MethodTable
- TADDR canonicalMethodTable = *PTR_TADDR(union_getPointer(m_pCanonMT));
+ TADDR canonicalMethodTable = *PTR_TADDR(union_getPointer(addr));
if (CORCOMPILE_IS_POINTER_TAGGED(canonicalMethodTable))
return FALSE;
- return (PTR_MethodTable(canonicalMethodTable)->m_pEEClass != NULL);
+ return !PTR_MethodTable(canonicalMethodTable)->m_pEEClass.IsNull();
}
#endif
_ASSERTE(!"Malformed m_pEEClass in MethodTable");
PTR_Module zapModule = NULL;
if (IsZapped())
{
- zapModule = m_pLoaderModule;
+ zapModule = ReadPointer(this, &MethodTable::m_pLoaderModule);
}
return zapModule;
inline PTR_Module MethodTable::GetLoaderModule()
{
LIMITED_METHOD_DAC_CONTRACT;
- return m_pLoaderModule;
+ return ReadPointer(this, &MethodTable::m_pLoaderModule);
}
inline PTR_LoaderAllocator MethodTable::GetLoaderAllocator()
inline void MethodTable::SetLoaderModule(Module* pModule)
{
WRAPPER_NO_CONTRACT;
- m_pLoaderModule = pModule;
+ m_pLoaderModule.SetValue(pModule);
}
inline void MethodTable::SetLoaderAllocator(LoaderAllocator* pAllocator)
{
LIMITED_METHOD_DAC_CONTRACT;
+ TADDR addr = ReadPointer(this, &MethodTable::m_pCanonMT);
+
#ifdef _DEBUG
- LowBits lowBits = union_getLowBits(m_pCanonMT);
+ LowBits lowBits = union_getLowBits(addr);
if (lowBits == UNION_EECLASS)
{
return dac_cast<PTR_MethodTable>(this);
else if (lowBits == UNION_METHODTABLE)
{
// pointer to canonical MethodTable.
- return PTR_MethodTable(union_getPointer(m_pCanonMT));
+ return PTR_MethodTable(union_getPointer(addr));
}
#ifdef FEATURE_PREJIT
else if (lowBits == UNION_INDIRECTION)
{
- return PTR_MethodTable(*PTR_TADDR(union_getPointer(m_pCanonMT)));
+ return PTR_MethodTable(*PTR_TADDR(union_getPointer(addr)));
}
#endif
_ASSERTE(!"Malformed m_pCanonMT in MethodTable");
return NULL;
#else
- TADDR addr = m_pCanonMT;
if ((addr & 2) == 0)
return dac_cast<PTR_MethodTable>(this);
LIMITED_METHOD_DAC_CONTRACT;
#ifdef FEATURE_PREJIT
- LowBits lowBits = union_getLowBits(m_pCanonMT);
+ TADDR addr = ReadPointer(this, &MethodTable::m_pCanonMT);
+ LowBits lowBits = union_getLowBits(addr);
if (lowBits == UNION_INDIRECTION)
{
// pointer to canonical MethodTable.
- return *PTR_TADDR(union_getPointer(m_pCanonMT));
+ return *PTR_TADDR(union_getPointer(addr));
}
else
#endif
{
LIMITED_METHOD_DAC_CONTRACT;
- return (union_getLowBits(m_pCanonMT) == UNION_EECLASS);
+ return (union_getLowBits(ReadPointer(this, &MethodTable::m_pCanonMT)) == UNION_EECLASS);
}
//==========================================================================================
{
LIMITED_METHOD_DAC_CONTRACT;
- return dac_cast<PTR_InterfaceInfo>(m_pMultipurposeSlot2); // m_pInterfaceMap
+ return ReadPointer(this, &MethodTable::m_pInterfaceMap);
}
//==========================================================================================