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#ifndef _JITCONFIG_H_
6#define _JITCONFIG_H_
7
8#include "switches.h"
9
10struct CORINFO_SIG_INFO;
11class ICorJitHost;
12
13class JitConfigValues
14{
15public:
16 class MethodSet
17 {
18 private:
19 struct MethodName
20 {
21 MethodName* m_next;
22 int m_methodNameStart;
23 int m_methodNameLen;
24 bool m_methodNameWildcardAtEnd;
25 int m_classNameStart;
26 int m_classNameLen;
27 bool m_classNameWildcardAtEnd;
28 int m_numArgs;
29 };
30
31 char* m_list;
32 MethodName* m_names;
33
34 MethodSet(const MethodSet& other) = delete;
35 MethodSet& operator=(const MethodSet& other) = delete;
36
37 public:
38 MethodSet()
39 {
40 }
41
42 inline const char* list() const
43 {
44 return const_cast<const char*>(m_list);
45 }
46
47 void initialize(const wchar_t* list, ICorJitHost* host);
48 void destroy(ICorJitHost* host);
49
50 inline bool isEmpty() const
51 {
52 return m_names == nullptr;
53 }
54 bool contains(const char* methodName, const char* className, CORINFO_SIG_INFO* sigInfo) const;
55 };
56
57private:
58#define CONFIG_INTEGER(name, key, defaultValue) int m_##name;
59#define CONFIG_STRING(name, key) const wchar_t* m_##name;
60#define CONFIG_METHODSET(name, key) MethodSet m_##name;
61#include "jitconfigvalues.h"
62
63public:
64#define CONFIG_INTEGER(name, key, defaultValue) \
65 inline int name() const \
66 { \
67 return m_##name; \
68 }
69#define CONFIG_STRING(name, key) \
70 inline const wchar_t* name() const \
71 { \
72 return m_##name; \
73 }
74#define CONFIG_METHODSET(name, key) \
75 inline const MethodSet& name() const \
76 { \
77 return m_##name; \
78 }
79#include "jitconfigvalues.h"
80
81private:
82 bool m_isInitialized;
83
84 JitConfigValues(const JitConfigValues& other) = delete;
85 JitConfigValues& operator=(const JitConfigValues& other) = delete;
86
87public:
88 JitConfigValues()
89 {
90 }
91
92 inline bool isInitialized() const
93 {
94 return m_isInitialized != 0;
95 }
96 void initialize(ICorJitHost* host);
97 void destroy(ICorJitHost* host);
98};
99
100extern JitConfigValues JitConfig;
101
102#endif
103