GCInfo: Fix ARM64 GCInfo decoding
authorSwaroop Sridhar <swaroops@microsoft.com>
Fri, 8 Apr 2016 01:09:13 +0000 (18:09 -0700)
committerSwaroop Sridhar <swaroops@microsoft.com>
Mon, 11 Apr 2016 23:51:34 +0000 (16:51 -0700)
GCStress traps were not inserted in ARM64 code correctly because safepoint
offsets were not correctly computed by EnumerateSafepoints().

This change fixes the issue by adding the (-1) adjustment to the ARM64
Safepoint offsets, similar to ARM and AMD64.

Commit migrated from https://github.com/dotnet/coreclr/commit/b6502aae0447fe7ccbc21b354c545c8ba58c902a

src/coreclr/src/gcinfo/gcinfodumper.cpp
src/coreclr/src/vm/gcinfodecoder.cpp

index 34666d6..01e7c98 100644 (file)
@@ -667,7 +667,7 @@ PORTABILITY_ASSERT("GcInfoDumper::EnumerateStateChanges is not implemented on th
 
 #ifdef PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED
         UINT32 safePointOffset = offset;
-#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_) 
+#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_) 
         safePointOffset++;
 #endif
         if(safePointDecoder.IsSafePoint(safePointOffset))
index 674dce0..068d234 100644 (file)
@@ -374,7 +374,7 @@ bool GcInfoDecoder::IsSafePoint(UINT32 codeOffset)
     if(m_NumSafePoints == 0)
         return false;
 
-#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_)
+#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)
     // Safepoints are encoded with a -1 adjustment
     codeOffset--;
 #endif
@@ -394,7 +394,7 @@ UINT32 GcInfoDecoder::FindSafePoint(UINT32 breakOffset)
     const UINT32 numBitsPerOffset = CeilOfLog2(NORMALIZE_CODE_OFFSET(m_CodeLength));
     UINT32 result = m_NumSafePoints;
 
-#if defined(_TARGET_ARM_)
+#if defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)
     // Safepoints are encoded with a -1 adjustment
     // but normalizing them masks off the low order bit
     // Thus only bother looking if the address is odd
@@ -440,6 +440,12 @@ void GcInfoDecoder::EnumerateSafePoints(EnumerateSafePointsCallback *pCallback,
     {
         UINT32 normOffset = (UINT32)m_Reader.Read(numBitsPerOffset);
         UINT32 offset = DENORMALIZE_CODE_OFFSET(normOffset) + 2;
+
+#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM_) || defined(_TARGET_ARM64_)
+        // Safepoints are encoded with a -1 adjustment
+        offset--;
+#endif
+
         pCallback(offset, hCallback);
     }
 }