diff options
author | Ruben Ayrapetyan <ruben-ayrapetyan@users.noreply.github.com> | 2017-05-22 17:38:20 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-05-22 07:38:20 -0700 |
commit | 3c76c1fff9473f8a0051907453c7e1902a6c3647 (patch) | |
tree | 0f51f15c42e3306f8576ef174e0995935bf92df8 | |
parent | c63b9fbdfefeae9a769a432c7e3410730ad2ee36 (diff) | |
download | coreclr-3c76c1fff9473f8a0051907453c7e1902a6c3647.tar.gz coreclr-3c76c1fff9473f8a0051907453c7e1902a6c3647.tar.bz2 coreclr-3c76c1fff9473f8a0051907453c7e1902a6c3647.zip |
Delete default copy/move constructors and assignment operators of RelativePointer and RelativeFixupPointer. (#11745)
-rw-r--r-- | src/inc/fixuppointer.h | 31 | ||||
-rw-r--r-- | src/vm/field.h | 29 | ||||
-rw-r--r-- | src/vm/generics.cpp | 3 | ||||
-rw-r--r-- | src/vm/ngenhash.h | 7 |
4 files changed, 66 insertions, 4 deletions
diff --git a/src/inc/fixuppointer.h b/src/inc/fixuppointer.h index 5a1b62c455..3467cfe5a2 100644 --- a/src/inc/fixuppointer.h +++ b/src/inc/fixuppointer.h @@ -30,6 +30,24 @@ template<typename PTR_TYPE> class RelativePointer { public: +#ifndef DACCESS_COMPILE + RelativePointer() + { + m_delta = (TADDR)NULL; + + _ASSERTE (IsNull()); + } +#else // DACCESS_COMPILE + RelativePointer() =delete; +#endif // DACCESS_COMPILE + + // Implicit copy/move is not allowed + // Bitwise copy is implemented by BitwiseCopyTo method + RelativePointer<PTR_TYPE>(const RelativePointer<PTR_TYPE> &) =delete; + RelativePointer<PTR_TYPE>(RelativePointer<PTR_TYPE> &&) =delete; + RelativePointer<PTR_TYPE>& operator = (const RelativePointer<PTR_TYPE> &) =delete; + RelativePointer<PTR_TYPE>& operator = (RelativePointer<PTR_TYPE> &&) =delete; + // Returns whether the encoded pointer is NULL. BOOL IsNull() const { @@ -143,6 +161,13 @@ public: dac_cast<DPTR(RelativePointer<PTR_TYPE>)>(base)->SetValueMaybeNull(base, addr); } +#ifndef DACCESS_COMPILE + void BitwiseCopyTo(RelativePointer<PTR_TYPE> &dest) const + { + dest.m_delta = m_delta; + } +#endif // DACCESS_COMPILE + private: #ifndef DACCESS_COMPILE Volatile<TADDR> m_delta; @@ -234,6 +259,12 @@ template<typename PTR_TYPE> class RelativeFixupPointer { public: + // Implicit copy/move is not allowed + RelativeFixupPointer<PTR_TYPE>(const RelativeFixupPointer<PTR_TYPE> &) =delete; + RelativeFixupPointer<PTR_TYPE>(RelativeFixupPointer<PTR_TYPE> &&) =delete; + RelativeFixupPointer<PTR_TYPE>& operator = (const RelativeFixupPointer<PTR_TYPE> &) =delete; + RelativeFixupPointer<PTR_TYPE>& operator = (RelativeFixupPointer<PTR_TYPE> &&) =delete; + // Returns whether the encoded pointer is NULL. BOOL IsNull() const { diff --git a/src/vm/field.h b/src/vm/field.h index 8e762eb4e4..f2cbda69e4 100644 --- a/src/vm/field.h +++ b/src/vm/field.h @@ -43,6 +43,8 @@ class FieldDesc protected: RelativePointer<PTR_MethodTable> m_pMTOfEnclosingClass; // This is used to hold the log2 of the field size temporarily during class loading. Yuck. + // See also: FieldDesc::InitializeFrom method + #if defined(DACCESS_COMPILE) union { //create a union so I can get the correct offset for ClrDump. unsigned m_dword1; @@ -85,10 +87,33 @@ class FieldDesc LPUTF8 m_debugName; #endif +public: // Allocated by special heap means, don't construct me - FieldDesc() {}; + FieldDesc() =delete; + +#ifndef DACCESS_COMPILE + void InitializeFrom(const FieldDesc& sourceField, MethodTable *pMT) + { + m_pMTOfEnclosingClass.SetValue(pMT); + + m_mb = sourceField.m_mb; + m_isStatic = sourceField.m_isStatic; + m_isThreadLocal = sourceField.m_isThreadLocal; + m_isRVA = sourceField.m_isRVA; + m_prot = sourceField.m_prot; + m_requiresFullMbValue = sourceField.m_requiresFullMbValue; + + m_dwOffset = sourceField.m_dwOffset; + m_type = sourceField.m_type; + +#ifdef _DEBUG + m_isDangerousAppDomainAgileField = sourceField.m_isDangerousAppDomainAgileField; + + m_debugName = sourceField.m_debugName; +#endif // _DEBUG + } +#endif // !DACCESS_COMPILE -public: #ifdef _DEBUG inline LPUTF8 GetDebugName() { diff --git a/src/vm/generics.cpp b/src/vm/generics.cpp index a04bde19fd..63d95a0e61 100644 --- a/src/vm/generics.cpp +++ b/src/vm/generics.cpp @@ -597,8 +597,7 @@ ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation( for (DWORD i = 0; i < pOldMT->GetNumStaticFields(); i++) { - pStaticFieldDescs[i] = pOldFD[i]; - pStaticFieldDescs[i].SetMethodTable(pMT); + pStaticFieldDescs[i].InitializeFrom(pOldFD[i], pMT); } } pMT->SetupGenericsStaticsInfo(pStaticFieldDescs); diff --git a/src/vm/ngenhash.h b/src/vm/ngenhash.h index 004d4b80c2..667a55e8f1 100644 --- a/src/vm/ngenhash.h +++ b/src/vm/ngenhash.h @@ -475,6 +475,13 @@ public: // Call this during the ngen Fixup phase to adjust the relative pointer to account for ngen image layout. void Fixup(DataImage *pImage, NgenHashTable<NGEN_HASH_ARGS> *pTable); #endif // FEATURE_PREJIT + + NgenHashEntryRef<NGEN_HASH_ARGS>& operator = (const NgenHashEntryRef<NGEN_HASH_ARGS> &src) + { + src.m_rpEntryRef.BitwiseCopyTo(m_rpEntryRef); + + return *this; + } #endif // !DACCESS_COMPILE private: |