Browse Source

Stop iterating through all of runtimeFunction.DebugInfo.BoundsList for each instruction

pull/3076/head
unknown 2 years ago
parent
commit
232582b81d
  1. 33
      ILSpy.ReadyToRun/ReadyToRunDisassembler.cs

33
ILSpy.ReadyToRun/ReadyToRunDisassembler.cs

@ -105,27 +105,32 @@ namespace ICSharpCode.ILSpy.ReadyToRun
formatter.Options.FirstOperandCharIndex = 10; formatter.Options.FirstOperandCharIndex = 10;
var tempOutput = new StringOutput(); var tempOutput = new StringOutput();
ulong baseInstrIP = instructions[0].IP; ulong baseInstrIP = instructions[0].IP;
var boundsMap = new Dictionary<uint, uint>();
foreach (var bound in runtimeFunction.DebugInfo.BoundsList)
{
// ignoring the return value assuming the same key is always mapped to the same value in runtimeFunction.DebugInfo.BoundsList
boundsMap.TryAdd(bound.NativeOffset, bound.ILOffset);
}
foreach (var instr in instructions) foreach (var instr in instructions)
{ {
int byteBaseIndex = (int)(instr.IP - address); int byteBaseIndex = (int)(instr.IP - address);
if (isShowDebugInfo && runtimeFunction.DebugInfo != null) if (isShowDebugInfo && runtimeFunction.DebugInfo != null)
{ {
foreach (var bound in runtimeFunction.DebugInfo.BoundsList) if (byteBaseIndex >= 0 && boundsMap.TryGetValue((uint)byteBaseIndex, out uint boundILOffset))
{ {
if (bound.NativeOffset == byteBaseIndex) if (boundILOffset == (uint)DebugInfoBoundsType.Prolog)
{ {
if (bound.ILOffset == (uint)DebugInfoBoundsType.Prolog) WriteCommentLine("Prolog");
{ }
WriteCommentLine("Prolog"); else if (boundILOffset == (uint)DebugInfoBoundsType.Epilog)
} {
else if (bound.ILOffset == (uint)DebugInfoBoundsType.Epilog) WriteCommentLine("Epilog");
{ }
WriteCommentLine("Epilog"); else
} {
else WriteCommentLine($"IL_{boundILOffset:x4}");
{
WriteCommentLine($"IL_{bound.ILOffset:x4}");
}
} }
} }
} }

Loading…
Cancel
Save