summaryrefslogtreecommitdiff
path: root/src/jit/jitconfig.h
blob: 9186e12982f8f8bdfa52a99f81089f91a8affb06 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// 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.

#ifndef _JITCONFIG_H_
#define _JITCONFIG_H_

#include "switches.h"

struct CORINFO_SIG_INFO;
class ICorJitHost;

class JitConfigValues
{
public:
    class MethodSet
    {
    private:
        struct MethodName
        {
            MethodName* m_next;
            int         m_methodNameStart;
            int         m_methodNameLen;
            int         m_classNameStart;
            int         m_classNameLen;
            int         m_numArgs;
        };

        const char* m_list;
        MethodName* m_names;

        MethodSet(const MethodSet& other) = delete;
        MethodSet& operator=(const MethodSet& other) = delete;

    public:
        MethodSet()
        {
        }
        inline const char* list() const
        {
            return m_list;
        }

        void initialize(const wchar_t* list, ICorJitHost* host);
        void destroy(ICorJitHost* host);

        inline bool isEmpty() const
        {
            return m_names == nullptr;
        }
        bool contains(const char* methodName, const char* className, CORINFO_SIG_INFO* sigInfo) const;
    };

private:
#define CONFIG_INTEGER(name, key, defaultValue) int m_##name;
#define CONFIG_STRING(name, key) const wchar_t* m_##name;
#define CONFIG_METHODSET(name, key) MethodSet   m_##name;
#include "jitconfigvalues.h"

public:
#define CONFIG_INTEGER(name, key, defaultValue)                                                                        \
    inline int name() const                                                                                            \
    {                                                                                                                  \
        return m_##name;                                                                                               \
    }
#define CONFIG_STRING(name, key)                                                                                       \
    inline const wchar_t* name() const                                                                                 \
    {                                                                                                                  \
        return m_##name;                                                                                               \
    }
#define CONFIG_METHODSET(name, key)                                                                                    \
    inline const MethodSet& name() const                                                                               \
    {                                                                                                                  \
        return m_##name;                                                                                               \
    }
#include "jitconfigvalues.h"

private:
    bool m_isInitialized;

    JitConfigValues(const JitConfigValues& other) = delete;
    JitConfigValues& operator=(const JitConfigValues& other) = delete;

public:
    JitConfigValues()
    {
    }

    inline bool isInitialized() const
    {
        return m_isInitialized != 0;
    }
    void initialize(ICorJitHost* host);
    void destroy(ICorJitHost* host);
};

extern JitConfigValues JitConfig;

#endif