| 1 | // Licensed to the .NET Foundation under one or more agreements. |
| 2 | // The .NET Foundation licenses this file to you under the MIT license. |
| 3 | // See the LICENSE file in the project root for more information. |
| 4 | |
| 5 | /*****************************************************************************/ |
| 6 | // <OWNER>clrjit</OWNER> |
| 7 | #pragma once |
| 8 | |
| 9 | #ifdef FEATURE_TRACELOGGING |
| 10 | |
| 11 | class Compiler; |
| 12 | |
| 13 | class JitTelemetry |
| 14 | { |
| 15 | public: |
| 16 | // Notify DLL load. |
| 17 | static void NotifyDllProcessAttach(); |
| 18 | |
| 19 | // Notify DLL unload. |
| 20 | static void NotifyDllProcessDetach(); |
| 21 | |
| 22 | // Constructor |
| 23 | JitTelemetry(); |
| 24 | |
| 25 | // Initialize with compiler instance |
| 26 | void Initialize(Compiler* comp); |
| 27 | |
| 28 | // Notification of end of compilation of the current method. |
| 29 | void NotifyEndOfCompilation(); |
| 30 | |
| 31 | // Notification of noway_assert. |
| 32 | void NotifyNowayAssert(const char* filename, unsigned line); |
| 33 | |
| 34 | // Is telemetry enabled through COMPlus_JitTelemetry? |
| 35 | static bool IsTelemetryEnabled(); |
| 36 | |
| 37 | private: |
| 38 | // Obtain current method information from VM and cache for |
| 39 | // future uses. |
| 40 | void CacheCurrentMethodInfo(); |
| 41 | |
| 42 | // |
| 43 | //-------------------------------------------------------------------------------- |
| 44 | // The below per process counters are updated without synchronization or |
| 45 | // thread-safety to avoid interfering with the JIT throughput. Accuracy |
| 46 | // of these counters will be traded-off for throughput. |
| 47 | // |
| 48 | |
| 49 | // Methods compiled per DLL unload |
| 50 | static volatile UINT32 s_uMethodsCompiled; |
| 51 | |
| 52 | // Methods compiled per DLL unload that hit noway assert (per process) |
| 53 | static volatile UINT32 s_uMethodsHitNowayAssert; |
| 54 | //-------------------------------------------------------------------------------- |
| 55 | |
| 56 | // Has the provider been registered already (per process) |
| 57 | static volatile bool s_fProviderRegistered; |
| 58 | |
| 59 | // Cached value of current method hash. |
| 60 | unsigned m_uMethodHash; |
| 61 | |
| 62 | // Cached value of current assembly name. |
| 63 | const char* m_pszAssemblyName; |
| 64 | |
| 65 | // Cached value of current scope name, i.e., "Program.Foo" in "Program.Foo:Main" |
| 66 | const char* m_pszScopeName; |
| 67 | |
| 68 | // Cached value of current method name, i.e., "Main" in "Program.Foo:Main" |
| 69 | const char* m_pszMethodName; |
| 70 | |
| 71 | // Have we already cached the method/scope/assembly names? |
| 72 | bool m_fMethodInfoCached; |
| 73 | |
| 74 | // Compiler instance. |
| 75 | Compiler* comp; |
| 76 | }; |
| 77 | |
| 78 | #endif // FEATURE_TRACELOGGING |
| 79 | |