From 7a7036e54971fb735c45b51fd5739b45fab7d1bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Sowi=C5=84ski?= Date: Thu, 30 Jan 2025 15:47:21 +0100 Subject: [PATCH 1/2] R2RDump: normalize totalInterruptibleLength --- .../aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs index a64ae72b6cd4e0..c7e77c3a15eeb9 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs @@ -525,13 +525,15 @@ private Dictionary> GetTransitions(byte[] image, ref int totalInterruptibleLength = 0; if (NumInterruptibleRanges == 0) { - totalInterruptibleLength = CodeLength; + totalInterruptibleLength = _gcInfoTypes.NormalizeCodeLength(CodeLength); } else { foreach (InterruptibleRange range in InterruptibleRanges) { - totalInterruptibleLength += (int)(range.StopOffset - range.StartOffset); + uint normStart = _gcInfoTypes.NormalizeCodeOffset(range.StartOffset); + uint normStop = _gcInfoTypes.NormalizeCodeOffset(range.StopOffset); + totalInterruptibleLength += (int)(normStop - normStart); } } @@ -629,6 +631,7 @@ private uint GetNumCouldBeLiveSlots(byte[] image, ref int bitOffset) fSkip = !fSkip; fReport = !fReport; } + Debug.Assert(readSlots == numTracked); } else { @@ -642,6 +645,7 @@ private uint GetNumCouldBeLiveSlots(byte[] image, ref int bitOffset) numCouldBeLiveSlots++; } } + Debug.Assert(numCouldBeLiveSlots > 0); return numCouldBeLiveSlots; } From 09e5eb9b9520cbe3cb7ea971536da84b0ed2984a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Sowi=C5=84ski?= Date: Thu, 30 Jan 2025 17:17:55 +0100 Subject: [PATCH 2/2] Early exit from GetTransitions like in gcinfodecoder.cpp --- .../tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs index c7e77c3a15eeb9..3170dadd9dcafd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs @@ -537,6 +537,9 @@ private Dictionary> GetTransitions(byte[] image, ref } } + if (SlotTable.NumTracked == 0) + return new Dictionary>(); + int numChunks = (totalInterruptibleLength + _gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK - 1) / _gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK; int numBitsPerPointer = (int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.POINTER_SIZE_ENCBASE, ref bitOffset); if (numBitsPerPointer == 0)