Changes for doubly linked freelists in the 64-bit GC (#1719)
authorPeter Sollich <petersol@microsoft.com>
Thu, 19 Nov 2020 13:34:18 +0000 (14:34 +0100)
committerGitHub <noreply@github.com>
Thu, 19 Nov 2020 13:34:18 +0000 (14:34 +0100)
In the 64-bit implementation, we now use one more bit in the method table pointer, so SOS needs to mask out one more bit as well.

Update SOS_BREAKING_CHANGE_VERSION to 2, so users get a warning if they are using an older SOS. This should almost always work just fine though, as the new bit is only set in rare cases during plan_phase.

src/SOS/Strike/eeheap.cpp
src/SOS/Strike/sos.cpp
src/SOS/Strike/sos.h
src/inc/sospriv.idl
src/pal/prebuilt/inc/sospriv.h

index 00b2fea93a7a518ce970c13a6e793811cae08d2b..dd0a68e3ba03806a5cf951569c825707b59b13f7 100644 (file)
@@ -970,7 +970,7 @@ DWORD GetNumComponents(TADDR obj)
 static MethodTableInfo* GetMethodTableInfo(DWORD_PTR dwAddrMethTable)
 {
     // Remove lower bits in case we are in mark phase
-    dwAddrMethTable = dwAddrMethTable & ~3;
+    dwAddrMethTable = dwAddrMethTable & ~sos::Object::METHODTABLE_PTR_LOW_BITMASK;
     MethodTableInfo* info = g_special_mtCache.Lookup(dwAddrMethTable);
     if (!info->IsInitialized())        // An uninitialized entry
     {
@@ -1214,7 +1214,7 @@ BOOL GCHeapTraverse(const GCHeapDetails &heap, AllocInfo* pallocInfo, VISITGCHEA
             return FALSE;
         }
 
-        dwAddrMethTable = dwAddrMethTable & ~3;
+        dwAddrMethTable = dwAddrMethTable & ~sos::Object::METHODTABLE_PTR_LOW_BITMASK;
         if (dwAddrMethTable == 0)
         {
             // Is this the beginning of an allocation context?
@@ -1338,7 +1338,7 @@ BOOL GCHeapTraverse(const GCHeapDetails &heap, AllocInfo* pallocInfo, VISITGCHEA
             return FALSE;
         }
 
-        dwAddrMethTable = dwAddrMethTable & ~3;
+        dwAddrMethTable = dwAddrMethTable & ~sos::Object::METHODTABLE_PTR_LOW_BITMASK;
         BOOL bContainsPointers;
         BOOL bMTOk = GetSizeEfficient(dwAddrCurrObj, dwAddrMethTable, TRUE, s, bContainsPointers);
         if (verify && bMTOk)
index 939862171219dd4ab9bcbc82f55bc4e41b7dbacb..cc719fb4e666520802f9b7e44e0e9b7ec8ad0d33 100644 (file)
@@ -119,7 +119,7 @@ namespace sos
             if (temp == NULL)
                 sos::Throw<HeapCorruption>("Object %s has an invalid method table.", DMLListNearObj(mAddress));
 
-            mMT = temp & ~3;
+            mMT = temp & ~METHODTABLE_PTR_LOW_BITMASK;
         }
 
         return mMT;
@@ -135,7 +135,7 @@ namespace sos
             sos::Throw<DataRead>("Failed to request object data for %s.", DMLListNearObj(mAddress));
 
         if (mMT == NULL)
-            mMT = TO_TADDR(objData.MethodTable) & ~3;
+            mMT = TO_TADDR(objData.MethodTable) & ~METHODTABLE_PTR_LOW_BITMASK;
 
         return TO_TADDR(objData.ElementTypeHandle);
     }
index 458b013ed42e3ad207ddc6bd543c396d86852fb7..0c8974e54f912223522b3f8827a28bf144bda1d6 100644 (file)
@@ -262,6 +262,15 @@ namespace sos
 #endif
         }
 
+        // GC uses the low bits of the method table ptr in objects to store information
+        // it uses one more bit in the 64-bit implementations for the doubly linked free lists
+        static const size_t METHODTABLE_PTR_LOW_BITMASK =
+#ifdef _TARGET_WIN64_
+            7;
+#else
+            3;
+#endif
+
     public:
         /* Constructor.  Use Object(TADDR, TADDR) instead if you know the method table.
          * Parameters:
index dae0a4ff520888160d3281025d9c1237dfb9b8d0..6da8b5814f7ee1ded6aed34bb119f2f2edf8b875 100644 (file)
@@ -413,7 +413,7 @@ interface ISOSDacInterface8 : IUnknown
 // Increment anytime there is a change in the data structures that SOS depends on like
 // stress log structs (StressMsg, StressLogChunck, ThreadStressLog, etc), exception
 // stack traces (StackTraceElement), the PredefinedTlsSlots enums, etc.
-cpp_quote("#define SOS_BREAKING_CHANGE_VERSION 1")
+cpp_quote("#define SOS_BREAKING_CHANGE_VERSION 2")
 
 [
     object,
index 72b1871e40f0cb7685443ed91a7782c4b5751d09..03d87d706f8b390445d5d62a72179fc76235cb20 100644 (file)
@@ -2675,7 +2675,7 @@ EXTERN_C const IID IID_ISOSDacInterface8;
 /* interface __MIDL_itf_sospriv_0000_0012 */
 /* [local] */ 
 
-#define SOS_BREAKING_CHANGE_VERSION 1
+#define SOS_BREAKING_CHANGE_VERSION 2
 
 
 extern RPC_IF_HANDLE __MIDL_itf_sospriv_0000_0012_v0_0_c_ifspec;