summaryrefslogtreecommitdiff
path: root/packaging/0003-Delete-default-copy-move-constructors-and-assignment.patch
blob: c8653c09061abf6d2bac4f1758a6d815378a9297 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
From 662cc59c451bb6e1b5481a088126b5c0293a9238 Mon Sep 17 00:00:00 2001
From: Ruben Ayrapetyan <ruben-ayrapetyan@users.noreply.github.com>
Date: Mon, 22 May 2017 17:38:20 +0300
Subject: [PATCH 03/32] Delete default copy/move constructors and assignment
 operators of RelativePointer and RelativeFixupPointer. (#11745)

---
 src/inc/fixuppointer.h | 31 +++++++++++++++++++++++++++++++
 src/vm/field.h         | 29 +++++++++++++++++++++++++++--
 src/vm/generics.cpp    |  3 +--
 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 5a1b62c..3467cfe 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 030a0aa..8f6668b 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 a04bde1..63d95a0 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 004d4b8..667a55e 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:
-- 
2.7.4