summaryrefslogtreecommitdiff
path: root/packaging/0023-Remove-relocations-for-MethodTable-m_pWriteableData-.patch
blob: f8b8321f3f7ff387225cc4ed49e560c4db9964fc (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
From 74f3dd15eada76e26fd74c2ec8db5076a7d4b86f Mon Sep 17 00:00:00 2001
From: Gleb Balykov <g.balykov@samsung.com>
Date: Thu, 22 Jun 2017 20:39:03 +0300
Subject: [PATCH 23/32] Remove relocations for MethodTable::m_pWriteableData
 for Linux ARM

---
 src/debug/daccess/nidump.cpp  |  2 +-
 src/vm/methodtable.cpp        | 26 ++++++++++++++------------
 src/vm/methodtable.h          | 23 +++++++++++++++--------
 src/vm/methodtable.inl        |  2 +-
 src/vm/methodtablebuilder.cpp |  2 +-
 5 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp
index 673aa39..04d610e 100644
--- a/src/debug/daccess/nidump.cpp
+++ b/src/debug/daccess/nidump.cpp
@@ -7045,7 +7045,7 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name,
                               DPtrToPreferredAddr(mt->GetLoaderModule()),
                               MethodTable, METHODTABLES );
 
-    PTR_MethodTableWriteableData wd = mt->m_pWriteableData;
+    PTR_MethodTableWriteableData wd = ReadPointer((MethodTable *)mt, &MethodTable::m_pWriteableData);
     _ASSERTE(wd != NULL);
     DisplayStartStructureWithOffset( m_pWriteableData, DPtrToPreferredAddr(wd),
                                      sizeof(*wd), MethodTable, METHODTABLES );
diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp
index b849746..e93f63d 100644
--- a/src/vm/methodtable.cpp
+++ b/src/vm/methodtable.cpp
@@ -4832,8 +4832,8 @@ void MethodTable::Fixup(DataImage *image)
     }
 
     _ASSERTE(GetWriteableData());
-    image->FixupPointerField(this, offsetof(MethodTable, m_pWriteableData));
-    m_pWriteableData->Fixup(image, this, needsRestore);
+    image->FixupPlainOrRelativePointerField(this, &MethodTable::m_pWriteableData);
+    m_pWriteableData.GetValue()->Fixup(image, this, needsRestore);
 
 #ifdef FEATURE_COMINTEROP
     if (HasGuidInfo())
@@ -5074,12 +5074,12 @@ void MethodTable::Fixup(DataImage *image)
 
         if (NeedsCrossModuleGenericsStaticsInfo())
         {
-            MethodTableWriteableData * pNewWriteableData = (MethodTableWriteableData *)image->GetImagePointer(m_pWriteableData);
+            MethodTableWriteableData * pNewWriteableData = (MethodTableWriteableData *)image->GetImagePointer(m_pWriteableData.GetValue());
             CrossModuleGenericsStaticsInfo * pNewCrossModuleGenericsStaticsInfo = pNewWriteableData->GetCrossModuleGenericsStaticsInfo();
 
             pNewCrossModuleGenericsStaticsInfo->m_DynamicTypeID = pInfo->m_DynamicTypeID;
 
-            image->ZeroPointerField(m_pWriteableData, sizeof(MethodTableWriteableData) + offsetof(CrossModuleGenericsStaticsInfo, m_pModuleForStatics));
+            image->ZeroPointerField(m_pWriteableData.GetValue(), sizeof(MethodTableWriteableData) + offsetof(CrossModuleGenericsStaticsInfo, m_pModuleForStatics));
 
             pNewMT->SetFlag(enum_flag_StaticsMask_IfGenericsThenCrossModule);
         }
@@ -9194,9 +9194,10 @@ MethodTable::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
         DacEnumMemoryRegion(dac_cast<TADDR>(it.GetIndirectionSlot()), it.GetSize());
     }
 
-    if (m_pWriteableData.IsValid())
+    PTR_MethodTableWriteableData pWriteableData = ReadPointer(this, &MethodTable::m_pWriteableData);
+    if (pWriteableData.IsValid())
     {
-        m_pWriteableData.EnumMem();
+        pWriteableData.EnumMem();
     }
 
     if (flags != CLRDATA_ENUM_MEM_MINI && flags != CLRDATA_ENUM_MEM_TRIAGE)
@@ -9659,8 +9660,6 @@ bool MethodTable::ClassRequiresUnmanagedCodeCheck()
     return false;
 }
 
-#endif // !DACCESS_COMPILE
-
 
 
 BOOL MethodTable::Validate()
@@ -9670,13 +9669,14 @@ BOOL MethodTable::Validate()
     ASSERT_AND_CHECK(SanityCheck());
     
 #ifdef _DEBUG    
-    if (m_pWriteableData == NULL)
+    if (m_pWriteableData.IsNull())
     {
         _ASSERTE(IsAsyncPinType());
         return TRUE;
     }
 
-    DWORD dwLastVerifiedGCCnt = m_pWriteableData->m_dwLastVerifedGCCnt;
+    MethodTableWriteableData *pWriteableData = m_pWriteableData.GetValue();
+    DWORD dwLastVerifiedGCCnt = pWriteableData->m_dwLastVerifedGCCnt;
     // Here we used to assert that (dwLastVerifiedGCCnt <= GCHeapUtilities::GetGCHeap()->GetGcCount()) but 
     // this is no longer true because with background gc. Since the purpose of having 
     // m_dwLastVerifedGCCnt is just to only verify the same method table once for each GC
@@ -9707,13 +9707,15 @@ BOOL MethodTable::Validate()
 #ifdef _DEBUG    
     // It is not a fatal error to fail the update the counter. We will run slower and retry next time, 
     // but the system will function properly.
-    if (EnsureWritablePagesNoThrow(m_pWriteableData, sizeof(MethodTableWriteableData)))
-        m_pWriteableData->m_dwLastVerifedGCCnt = GCHeapUtilities::GetGCHeap()->GetGcCount();
+    if (EnsureWritablePagesNoThrow(pWriteableData, sizeof(MethodTableWriteableData)))
+        pWriteableData->m_dwLastVerifedGCCnt = GCHeapUtilities::GetGCHeap()->GetGcCount();
 #endif //_DEBUG
 
     return TRUE;
 }
 
+#endif // !DACCESS_COMPILE
+
 NOINLINE BYTE *MethodTable::GetLoaderAllocatorObjectForGC()
 {
     WRAPPER_NO_CONTRACT;
diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h
index ef0cb44..63d35e6 100644
--- a/src/vm/methodtable.h
+++ b/src/vm/methodtable.h
@@ -3148,36 +3148,39 @@ public:
     // Private part of MethodTable
     // ------------------------------------------------------------------
 
+#ifndef DACCESS_COMPILE
     inline void SetWriteableData(PTR_MethodTableWriteableData pMTWriteableData)
     {
         LIMITED_METHOD_CONTRACT;
         _ASSERTE(pMTWriteableData);
-        m_pWriteableData = pMTWriteableData;
+        m_pWriteableData.SetValue(pMTWriteableData);
     }
-    
+#endif
+
     inline PTR_Const_MethodTableWriteableData GetWriteableData() const
     {
         LIMITED_METHOD_DAC_CONTRACT;
         g_IBCLogger.LogMethodTableWriteableDataAccess(this);
-        return m_pWriteableData;
+        return GetWriteableData_NoLogging();
     }
 
     inline PTR_Const_MethodTableWriteableData GetWriteableData_NoLogging() const
     {
         LIMITED_METHOD_DAC_CONTRACT;
-        return m_pWriteableData;
+        return ReadPointer(this, &MethodTable::m_pWriteableData);
     }
 
     inline PTR_MethodTableWriteableData GetWriteableDataForWrite()
     {
-        LIMITED_METHOD_CONTRACT;
+        LIMITED_METHOD_DAC_CONTRACT;
         g_IBCLogger.LogMethodTableWriteableDataWriteAccess(this);
-        return m_pWriteableData;
+        return GetWriteableDataForWrite_NoLogging();
     }
 
     inline PTR_MethodTableWriteableData GetWriteableDataForWrite_NoLogging()
     {
-        return m_pWriteableData;
+        LIMITED_METHOD_DAC_CONTRACT;
+        return ReadPointer(this, &MethodTable::m_pWriteableData);
     }
 
     //-------------------------------------------------------------------
@@ -4076,7 +4079,11 @@ private:
 
     RelativePointer<PTR_Module> m_pLoaderModule;    // LoaderModule. It is equal to the ZapModule in ngened images
     
-    PTR_MethodTableWriteableData m_pWriteableData;
+#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_)
+    RelativePointer<PTR_MethodTableWriteableData> m_pWriteableData;
+#else
+    PlainPointer<PTR_MethodTableWriteableData> m_pWriteableData;
+#endif
     
     // The value of lowest two bits describe what the union contains
     enum LowBits {
diff --git a/src/vm/methodtable.inl b/src/vm/methodtable.inl
index eb1abb0..4c808ee 100644
--- a/src/vm/methodtable.inl
+++ b/src/vm/methodtable.inl
@@ -1737,7 +1737,7 @@ FORCEINLINE PTR_Module MethodTable::GetGenericsStaticsModuleAndID(DWORD * pID)
     _ASSERTE(!IsStringOrArray());
     if (m_dwFlags & enum_flag_StaticsMask_IfGenericsThenCrossModule)
     {
-        CrossModuleGenericsStaticsInfo *pInfo = m_pWriteableData->GetCrossModuleGenericsStaticsInfo();
+        CrossModuleGenericsStaticsInfo *pInfo = ReadPointer(this, &MethodTable::m_pWriteableData)->GetCrossModuleGenericsStaticsInfo();
         _ASSERTE(FitsIn<DWORD>(pInfo->m_DynamicTypeID) || pInfo->m_DynamicTypeID == (SIZE_T)-1);
         *pID = static_cast<DWORD>(pInfo->m_DynamicTypeID);
         return pInfo->m_pModuleForStatics;
diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp
index e8f3b9c..5d77463 100644
--- a/src/vm/methodtablebuilder.cpp
+++ b/src/vm/methodtablebuilder.cpp
@@ -10215,7 +10215,7 @@ MethodTable * MethodTableBuilder::AllocateNewMT(Module *pLoaderModule,
     }
 
 #ifdef _DEBUG
-    pMT->m_pWriteableData->m_dwLastVerifedGCCnt = (DWORD)-1;
+    pMT->m_pWriteableData.GetValue()->m_dwLastVerifedGCCnt = (DWORD)-1;
 #endif // _DEBUG
 
     RETURN(pMT);
-- 
2.7.4