summaryrefslogtreecommitdiff
path: root/src/jit/jittelemetry.h
blob: 24a0ce7b5db81f61f9ec6f91fee57f3b4f22f5a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*****************************************************************************/
// <OWNER>clrjit</OWNER>
#pragma once

#ifdef FEATURE_TRACELOGGING

class Compiler;

class JitTelemetry
{
public:
    // Notify DLL load.
    static void NotifyDllProcessAttach();

    // Notify DLL unload.
    static void NotifyDllProcessDetach();

    // Constructor
    JitTelemetry();

    // Initialize with compiler instance
    void Initialize(Compiler* comp);

    // Notification of end of compilation of the current method.
    void NotifyEndOfCompilation();

    // Notification of noway_assert.
    void NotifyNowayAssert(const char* filename, unsigned line);

    // Is telemetry enabled through COMPlus_JitTelemetry?
    static bool IsTelemetryEnabled();

private:
    // Obtain current method information from VM and cache for
    // future uses.
    void CacheCurrentMethodInfo();

    //
    //--------------------------------------------------------------------------------
    // The below per process counters are updated without synchronization or
    // thread-safety to avoid interfering with the JIT throughput. Accuracy
    // of these counters will be traded-off for throughput.
    //

    // Methods compiled per DLL unload
    static volatile UINT32 s_uMethodsCompiled;

    // Methods compiled per DLL unload that hit noway assert (per process)
    static volatile UINT32 s_uMethodsHitNowayAssert;
    //--------------------------------------------------------------------------------

    // Has the provider been registered already (per process)
    static volatile bool s_fProviderRegistered;

    // Cached value of current method hash.
    unsigned m_uMethodHash;

    // Cached value of current assembly name.
    const char* m_pszAssemblyName;

    // Cached value of current scope name, i.e., "Program.Foo" in "Program.Foo:Main"
    const char* m_pszScopeName;

    // Cached value of current method name, i.e., "Main" in "Program.Foo:Main"
    const char* m_pszMethodName;

    // Have we already cached the method/scope/assembly names?
    bool m_fMethodInfoCached;

    // Compiler instance.
    Compiler* comp;
};

#endif // FEATURE_TRACELOGGING