Browse Source

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

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

19
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 (bound.ILOffset == (uint)DebugInfoBoundsType.Prolog) if (boundILOffset == (uint)DebugInfoBoundsType.Prolog)
{ {
WriteCommentLine("Prolog"); WriteCommentLine("Prolog");
} }
else if (bound.ILOffset == (uint)DebugInfoBoundsType.Epilog) else if (boundILOffset == (uint)DebugInfoBoundsType.Epilog)
{ {
WriteCommentLine("Epilog"); WriteCommentLine("Epilog");
} }
else else
{ {
WriteCommentLine($"IL_{bound.ILOffset:x4}"); WriteCommentLine($"IL_{boundILOffset:x4}");
}
} }
} }
} }

Loading…
Cancel
Save