summaryrefslogtreecommitdiff
path: root/src/inc/switches.h
blob: bb3ca28e12c8f2466f31fb0cc10ef49ef25b072c (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
// 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.
//
// switches.h switch configuration of common runtime features
//


#ifndef CROSSGEN_COMPILE
#define STRESS_HEAP
#endif

#if !defined(CROSSGEN_COMPILE) && !defined(FEATURE_CORECLR)
#define STRESS_THREAD
#endif

#define VERIFY_HEAP

#define GC_CONFIG_DRIVEN

// define this to test data safety for the DAC. See code:DataTest::TestDataSafety. 
#define TEST_DATA_CONSISTENCY

#if !defined(STRESS_LOG) && !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
#define STRESS_LOG
#endif

#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
#define USE_CHECKED_OBJECTREFS
#endif

#define FAT_DISPATCH_TOKENS

#define FEATURE_SHARE_GENERIC_CODE

#if defined(_DEBUG) && !defined(DACCESS_COMPILE)
    #define LOGGING
#endif

#if !defined(_TARGET_X86_) || defined(FEATURE_PAL)
#define WIN64EXCEPTIONS
#endif

#if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
// Failpoint support
#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && !defined(FEATURE_PAL)
#define FAILPOINTS_ENABLED
#endif
#endif //!defined(FEATURE_UTILCODE_NO_DEPENDENCIES)

#if 0
    #define APPDOMAIN_STATE
    #define BREAK_ON_UNLOAD
    #define AD_LOG_MEMORY
    #define AD_NO_UNLOAD
    #define AD_SNAPSHOT
    #define BREAK_META_ACCESS
    #define AD_BREAK_ON_CANNOT_UNLOAD
    #define BREAK_ON_CLSLOAD

    // Enable to track details of EESuspension
    #define TIME_SUSPEND
#endif // 0

#ifndef DACCESS_COMPILE
// Enabled to track GC statistics
#define GC_STATS
#endif

#if !defined(FEATURE_CORECLR)
#define EMIT_FIXUPS
#endif

#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && (defined(_TARGET_X86_) || defined(_TARGET_AMD64_))
// On x86/x64 Windows debug builds, respect the COMPlus_EnforceEEThreadNotRequiredContracts
// runtime switch. See code:InitThreadManager and code:GetThreadGenericFullCheck
#define ENABLE_GET_THREAD_GENERIC_FULL_CHECK
#endif

#if defined(_TARGET_X86_) || defined(_TARGET_ARM_)
    #define PAGE_SIZE               0x1000
    #define USE_UPPER_ADDRESS       0

#elif defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
    #define PAGE_SIZE               0x1000
    #define UPPER_ADDRESS_MAPPING_FACTOR 2
    #define CLR_UPPER_ADDRESS_MIN   0x64400000000
    #define CODEHEAP_START_ADDRESS  0x64480000000
    #define CLR_UPPER_ADDRESS_MAX   0x644FC000000

#if !defined(FEATURE_PAL)
    #define USE_UPPER_ADDRESS       1
#else
    #define USE_UPPER_ADDRESS       0
#endif // !FEATURE_PAL

#else
    #error Please add a new #elif clause and define all portability macros for the new platform
#endif

#ifndef OS_PAGE_SIZE
#define OS_PAGE_SIZE PAGE_SIZE
#endif

#if defined(_WIN64)
#define JIT_IS_ALIGNED
#endif

// ALLOW_SXS_JIT enables AltJit support for JIT-ing, via COMPlus_AltJit / COMPlus_AltJitName.
// ALLOW_SXS_JIT_NGEN enables AltJit support for NGEN, via COMPlus_AltJitNgen / COMPlus_AltJitName.
// Note that if ALLOW_SXS_JIT_NGEN is defined, then ALLOW_SXS_JIT must be defined.
#define ALLOW_SXS_JIT
#if defined(ALLOW_SXS_JIT)
#define ALLOW_SXS_JIT_NGEN
#endif // ALLOW_SXS_JIT

#if defined(FEATURE_CORECLR)
//master switch for gc suspension not based on hijacking
#define FEATURE_ENABLE_GCPOLL
#endif //FEATURE_CORECLR

#if defined(FEATURE_ENABLE_GCPOLL) && defined(_TARGET_X86_)
//this enables a fast version of the GC Poll helper instead of the default portable one.
#define ENABLE_FAST_GCPOLL_HELPER
#endif // defined(FEATURE_ENABLE_GCPOLL) && defined(_TARGET_X86_)

#if !defined(FEATURE_PAL)
// PLATFORM_SUPPORTS_THREADSUSPEND is defined for platforms where it is safe to call 
//   SuspendThread.  This API is dangerous on non-Windows platforms, as it can lead to 
//   deadlocks, due to low level OS resources that the PAL is not aware of, or due to 
//   the fact that PAL-unaware code in the process may hold onto some OS resources.
#define PLATFORM_SUPPORTS_SAFE_THREADSUSPEND
#endif // !FEATURE_PAL

#if !defined(PLATFORM_SUPPORTS_SAFE_THREADSUSPEND) && !defined(FEATURE_ENABLE_GCPOLL)
#error "Platform must support either safe thread suspension or GC polling"
#endif

#if defined(STRESS_HEAP) && defined(_DEBUG) && defined(FEATURE_HIJACK)
#define HAVE_GCCOVER
#endif

#ifdef FEATURE_CORECLR
//Turns on a startup delay to allow simulation of slower and faster startup times.
#define ENABLE_STARTUP_DELAY
#endif


#ifndef ALLOW_LOCAL_WORKER
#define ALLOW_LOCAL_WORKER
#endif


#ifdef _DEBUG

//hurray DAC makes everything more fun - you can't have defines that control whether
//or not data members are visible which differ between DAC and non-DAC builds.
//All of the _DATA defines match DAC and non-DAC, the other defines here are off in the DAC.
#if defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPORTED)
// See code:ProfControlBlock#TestOnlyELT.
#define PROF_TEST_ONLY_FORCE_ELT_DATA
// See code:ProfControlBlock#TestOnlyObjectAllocated.
#define PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED_DATA
#endif // PROFILING_SUPPORTED_DATA || PROFILING_SUPPORTED

#if defined(PROFILING_SUPPORTED)
// See code:ProfControlBlock#TestOnlyELT.
#define PROF_TEST_ONLY_FORCE_ELT
// See code:ProfControlBlock#TestOnlyObjectAllocated.
#define PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED
#endif // PROFILING_SUPPORTED

#endif // _DEBUG



#if defined(PROFILING_SUPPORTED)
// On desktop CLR builds, the profiling API uses the event log for end-user-friendly
// diagnostic messages.  CoreCLR on Windows ouputs debug strings for diagnostic messages.
// Rotor builds have no access to event log message resources, though, so they simply 
// display popup dialogs for now.
#define FEATURE_PROFAPI_EVENT_LOGGING
#endif // defined(PROFILING_SUPPORTED)

// Windows desktop supports the profiling API attach / detach feature.
// This will eventually be supported on coreclr as well. 
#if defined(PROFILING_SUPPORTED) && !defined(FEATURE_CORECLR)
#define FEATURE_PROFAPI_ATTACH_DETACH
#endif

// Windows desktop DAC builds need to see some of the data used in the profiling API
// attach / detach feature, particularly Thread::m_dwProfilerEvacuationCounter 
#if defined(PROFILING_SUPPORTED_DATA) && !defined(FEATURE_CORECLR)
#define DATA_PROFAPI_ATTACH_DETACH
#endif

// MUST NEVER CHECK IN WITH THIS ENABLED.
// This is just for convenience in doing performance investigations in a checked-out enlistment.
// #define FEATURE_ENABLE_NO_RANGE_CHECKS

#ifndef FEATURE_CORECLR
// This controls whether a compilation-timing feature that relies on Windows APIs, if available, else direct
// hardware instructions (rdtsc), for accessing high-resolution hardware timers is enabled. This is disabled
// in Silverlight (just to avoid thinking about whether the extra code space is worthwhile).
#define FEATURE_JIT_TIMER
#endif // FEATURE_CORECLR

// This feature in RyuJIT supersedes the FEATURE_JIT_TIMER. In addition to supporting the time log file, this
// feature also supports using COMPlus_JitTimeLogCsv=a.csv, which will dump method-level and phase-level timing
// statistics. Also see comments on FEATURE_JIT_TIMER.
#define FEATURE_JIT_METHOD_PERF


#ifndef FEATURE_USE_ASM_GC_WRITE_BARRIERS
// If we're not using assembly write barriers, then this turns on a performance measurement
// mode that gathers and prints statistics about # of GC write barriers invokes.
// #define FEATURE_COUNT_GC_WRITE_BARRIERS
#endif

// Enables a mode in which GC is completely conservative in stacks and registers: all stack slots and registers
// are treated as potential pinned interior pointers. When enabled, the runtime flag COMPLUS_GCCONSERVATIVE 
// determines dynamically whether GC is conservative. Note that appdomain unload, LCG and unloadable assemblies
// do not work reliably with conservative GC.
#ifdef FEATURE_CORECLR
#define FEATURE_CONSERVATIVE_GC 1
#endif

#if (defined(_TARGET_ARM_) && !defined(ARM_SOFTFP)) || defined(_TARGET_ARM64_)
#define FEATURE_HFA
#endif

// ARM requires that 64-bit primitive types are aligned at 64-bit boundaries for interlocked-like operations.
// Additionally the platform ABI requires these types and composite type containing them to be similarly
// aligned when passed as arguments.
#ifdef _TARGET_ARM_
#define FEATURE_64BIT_ALIGNMENT
#endif

// Prefer double alignment for structs and arrays with doubles. Put arrays of doubles more agressively 
// into large object heap for performance because large object heap is 8 byte aligned 
#if !defined(FEATURE_64BIT_ALIGNMENT) && !defined(_WIN64)
#define FEATURE_DOUBLE_ALIGNMENT_HINT
#endif

#if defined(FEATURE_CORESYSTEM)
#define FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
#endif // defined(FEATURE_CORESYSTEM)

#if defined(FEATURE_PREJIT) && defined(FEATURE_CORECLR) && defined(FEATURE_CORESYSTEM)
// Desktop CLR allows profilers and debuggers to opt out of loading NGENd images, and to
// JIT everything instead. "FEATURE_TREAT_NI_AS_MSIL_DURING_DIAGNOSTICS" is roughly the
// equivalent for Apollo, where MSIL images may not be available at all.
// FEATURE_TREAT_NI_AS_MSIL_DURING_DIAGNOSTICS allows profilers or debuggers to state
// they don't want to use pregenerated code, and to instead load the NGENd image but
// treat it as if it were MSIL by ignoring the prejitted code and prebaked structures,
// and instead to JIT and load types at run-time.
#define FEATURE_TREAT_NI_AS_MSIL_DURING_DIAGNOSTICS
#endif

// If defined, support interpretation.
#if !defined(CROSSGEN_COMPILE)

#if defined(ALLOW_SXS_JIT) && !defined(FEATURE_PAL)
#define FEATURE_STACK_SAMPLING
#endif // defined (ALLOW_SXS_JIT)

#endif // !defined(CROSSGEN_COMPILE)