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..3170dadd9dcafd 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs @@ -525,16 +525,21 @@ 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); } } + 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) @@ -629,6 +634,7 @@ private uint GetNumCouldBeLiveSlots(byte[] image, ref int bitOffset) fSkip = !fSkip; fReport = !fReport; } + Debug.Assert(readSlots == numTracked); } else { @@ -642,6 +648,7 @@ private uint GetNumCouldBeLiveSlots(byte[] image, ref int bitOffset) numCouldBeLiveSlots++; } } + Debug.Assert(numCouldBeLiveSlots > 0); return numCouldBeLiveSlots; }