From: Michal Strehovský Date: Mon, 14 Oct 2019 20:08:06 +0000 (+0200) Subject: Wrap PerfEventSource usage in IsEnabled checks (dotnet/coreclr#27177) X-Git-Tag: submit/tizen/20210909.063632~11030^2~400 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=910e442eac92c85efaad078578b444ae527958af;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Wrap PerfEventSource usage in IsEnabled checks (dotnet/coreclr#27177) After the recent start/stop event refactoring, this is the only use of PerfEventSource that is not wrapped in a IsEnabled call. Tools like IL Linker are able to strip EventSource usage to make the app smaller and the way they do it is by replacing IsEnabled to always return false and making Write methods always throw. If we don't wrap EventSource usage in IsEnabled checks, this results in a broken app. Commit migrated from https://github.com/dotnet/coreclr/commit/2d636cdcb90b0e880b45126b4f65cb815f3872f4 --- diff --git a/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs b/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs index 18187a1..e734a31 100644 --- a/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs +++ b/src/coreclr/src/tools/crossgen2/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs @@ -287,7 +287,8 @@ namespace ILCompiler.DependencyAnalysisFramework { if (_marker.MarkNode(node, reason1, reason2, reason)) { - PerfEventSource.Log.AddedNodeToMarkStack(); + if (PerfEventSource.Log.IsEnabled()) + PerfEventSource.Log.AddedNodeToMarkStack(); // Pop the top node of the mark stack if (_stackPopRandomizer == null)