make GC/GCHandle tracing pay-for-play (dotnet/coreclr#21479)
authorSung Yoon Whang <suwhang@microsoft.com>
Tue, 11 Dec 2018 06:49:18 +0000 (22:49 -0800)
committerGitHub <noreply@github.com>
Tue, 11 Dec 2018 06:49:18 +0000 (22:49 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/b25304c757219d3103f691f615b5fa70ed22e92e

src/coreclr/src/gc/gceventstatus.h

index 5482fb5..c49e767 100644 (file)
@@ -241,9 +241,12 @@ void FireDynamicEvent(const char* name, EventArgument... arguments)
   template<typename... EventActualArgument>                       \
   inline void GCEventFire##name(EventActualArgument... arguments) \
   {                                                               \
-      IGCToCLREventSink* sink = GCToEEInterface::EventSink();     \
-      assert(sink != nullptr);                                    \
-      sink->Fire##name(arguments...);                             \
+      if (GCEventEnabled##name())                                 \
+      {                                                           \
+          IGCToCLREventSink* sink = GCToEEInterface::EventSink(); \
+          assert(sink != nullptr);                                \
+          sink->Fire##name(arguments...);                         \
+      }                                                           \
   }
 
 #define DYNAMIC_EVENT(name, level, keyword, ...)                                                                   \