Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix perfview handling of events reporting dynamic helpers #1883

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/TraceEvent/Parsers/ClrEtwAll.cs.base
Original file line number Diff line number Diff line change
Expand Up @@ -6884,6 +6884,7 @@ namespace Microsoft.Diagnostics.Tracing.Parsers.MicrosoftWindowsDotNETRuntime
Generic = 0x2,
HasSharedGenericCode = 0x4,
Jitted = 0x8,
JitHelperMethod = 0x10,
}
[Flags]
public enum ModuleFlags
Expand Down
1 change: 1 addition & 0 deletions src/TraceEvent/Parsers/ClrTraceEventParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11440,6 +11440,7 @@ public abstract class MethodLoadUnloadTraceDataBase : TraceEvent
public bool IsDynamic { get { return (MethodFlags & MethodFlags.Dynamic) != 0; } }
public bool IsGeneric { get { return (MethodFlags & MethodFlags.Generic) != 0; } }
public bool IsJitted { get { return (MethodFlags & MethodFlags.Jitted) != 0; } }
public bool IsJitHelper { get { return (MethodFlags & MethodFlags.JitHelper) != 0; } }

public OptimizationTier OptimizationTier
{
Expand Down
4 changes: 4 additions & 0 deletions src/TraceEvent/Symbols/NativeSymbolModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,10 @@ internal static string GetTypeName(IDiaSymbol symbol)
break;
}
return sb.ToString();
case BasicType.btChar16:
return "char16_t";
case BasicType.btChar32:
return "char32_t";
Comment on lines +1427 to +1430
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a separate fix, or is this related to the jit helpers? I would expect it to be a separate fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually not sure; I've made this change couple of months ago to address my immediate need and forgotten about it. It is possible that this was a separate thing. I am going to test it locally with a dump from @TIHan, so I'll see.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Thanks @janvorli.

case BasicType.btFloat:
return symbol.length == 4 ? "float" : "double";
default:
Expand Down
14 changes: 13 additions & 1 deletion src/TraceEvent/TraceLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,7 @@ private unsafe void SetupCallbacks(TraceEventDispatcher rawEvents)

// FIX NOW HACK, because Method and Module unload methods are missing.
jittedMethods = new List<MethodLoadUnloadVerboseTraceData>();
jitHelpers = new List<MethodLoadUnloadVerboseTraceData>();
jsJittedMethods = new List<MethodLoadUnloadJSTraceData>();
sourceFilesByID = new Dictionary<JavaScriptSourceKey, string>();

Expand Down Expand Up @@ -1374,7 +1375,7 @@ private unsafe void SetupCallbacks(TraceEventDispatcher rawEvents)
Action<MethodLoadUnloadVerboseTraceData> onMethodStart = delegate (MethodLoadUnloadVerboseTraceData data)
{
// We only capture data on unload, because we collect the addresses first.
if (!data.IsDynamic && !data.IsJitted)
if (!data.IsDynamic && !data.IsJitted && !data.IsJitHelper)
{
bookKeepingEvent = true;
}
Expand All @@ -1396,6 +1397,11 @@ private unsafe void SetupCallbacks(TraceEventDispatcher rawEvents)

jittedMethods.Add((MethodLoadUnloadVerboseTraceData)data.Clone());
}

if (data.IsJitHelper)
{
jitHelpers.Add((MethodLoadUnloadVerboseTraceData)data.Clone());
}
};
rawEvents.Clr.MethodLoadVerbose += onMethodStart;
rawEvents.Clr.MethodDCStartVerboseV2 += onMethodStart;
Expand Down Expand Up @@ -2117,6 +2123,11 @@ private unsafe void CopyRawEvents(TraceEventDispatcher rawEvents, IStreamWriter
codeAddresses.AddMethod(jittedMethod);
}

foreach (var jitHelper in jitHelpers)
{
codeAddresses.AddMethod(jitHelper);
}

foreach (var jsJittedMethod in jsJittedMethods)
{
codeAddresses.AddMethod(jsJittedMethod, sourceFilesByID);
Expand Down Expand Up @@ -3882,6 +3893,7 @@ int IFastSerializableVersion.MinimumReaderVersion

// TODO FIX NOW remove the jittedMethods ones.
private List<MethodLoadUnloadVerboseTraceData> jittedMethods;
private List<MethodLoadUnloadVerboseTraceData> jitHelpers;
private List<MethodLoadUnloadJSTraceData> jsJittedMethods;
private Dictionary<JavaScriptSourceKey, string> sourceFilesByID;

Expand Down