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// switches.h switch configuration of common runtime features
6//
7
8
9#ifndef CROSSGEN_COMPILE
10#define STRESS_HEAP
11#endif
12
13
14#define VERIFY_HEAP
15
16#define GC_CONFIG_DRIVEN
17
18// define this to test data safety for the DAC. See code:DataTest::TestDataSafety.
19#define TEST_DATA_CONSISTENCY
20
21#if !defined(STRESS_LOG) && !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
22#define STRESS_LOG
23#endif
24
25#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
26#define USE_CHECKED_OBJECTREFS
27#endif
28
29#define FAT_DISPATCH_TOKENS
30
31#define FEATURE_SHARE_GENERIC_CODE
32
33#if defined(_DEBUG) && !defined(DACCESS_COMPILE)
34 #define LOGGING
35#endif
36
37#if !defined(_TARGET_X86_) || defined(FEATURE_PAL)
38#define WIN64EXCEPTIONS
39#endif
40
41#if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
42// Failpoint support
43#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && !defined(FEATURE_PAL)
44#define FAILPOINTS_ENABLED
45#endif
46#endif //!defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
47
48#if 0
49 #define APPDOMAIN_STATE
50 #define BREAK_ON_UNLOAD
51 #define AD_LOG_MEMORY
52 #define AD_NO_UNLOAD
53 #define AD_SNAPSHOT
54 #define BREAK_META_ACCESS
55 #define AD_BREAK_ON_CANNOT_UNLOAD
56 #define BREAK_ON_CLSLOAD
57
58 // Enable to track details of EESuspension
59 #define TIME_SUSPEND
60#endif // 0
61
62#ifndef DACCESS_COMPILE
63// Enabled to track GC statistics
64#define GC_STATS
65#endif
66
67#if defined(_TARGET_X86_) || defined(_TARGET_ARM_)
68 #define USE_UPPER_ADDRESS 0
69
70#elif defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
71 #define UPPER_ADDRESS_MAPPING_FACTOR 2
72 #define CLR_UPPER_ADDRESS_MIN 0x64400000000
73 #define CODEHEAP_START_ADDRESS 0x64480000000
74 #define CLR_UPPER_ADDRESS_MAX 0x644FC000000
75
76#if !defined(FEATURE_PAL)
77 #define USE_UPPER_ADDRESS 1
78#else
79 #define USE_UPPER_ADDRESS 0
80#endif // !FEATURE_PAL
81
82#else
83 #error Please add a new #elif clause and define all portability macros for the new platform
84#endif
85
86#if defined(_WIN64)
87#define JIT_IS_ALIGNED
88#endif
89
90// ALLOW_SXS_JIT enables AltJit support for JIT-ing, via COMPlus_AltJit / COMPlus_AltJitName.
91// ALLOW_SXS_JIT_NGEN enables AltJit support for NGEN, via COMPlus_AltJitNgen / COMPlus_AltJitName.
92// Note that if ALLOW_SXS_JIT_NGEN is defined, then ALLOW_SXS_JIT must be defined.
93#define ALLOW_SXS_JIT
94#define ALLOW_SXS_JIT_NGEN
95
96//master switch for gc suspension not based on hijacking
97#define FEATURE_ENABLE_GCPOLL
98
99#if defined(_TARGET_X86_)
100//this enables a fast version of the GC Poll helper instead of the default portable one.
101#define ENABLE_FAST_GCPOLL_HELPER
102#endif // defined(FEATURE_ENABLE_GCPOLL) && defined(_TARGET_X86_)
103
104#if !defined(FEATURE_PAL)
105// PLATFORM_SUPPORTS_THREADSUSPEND is defined for platforms where it is safe to call
106// SuspendThread. This API is dangerous on non-Windows platforms, as it can lead to
107// deadlocks, due to low level OS resources that the PAL is not aware of, or due to
108// the fact that PAL-unaware code in the process may hold onto some OS resources.
109#define PLATFORM_SUPPORTS_SAFE_THREADSUSPEND
110#endif // !FEATURE_PAL
111
112
113#if defined(STRESS_HEAP) && defined(_DEBUG) && defined(FEATURE_HIJACK)
114#define HAVE_GCCOVER
115#endif
116
117// Some platforms may see spurious AVs when GcCoverage is enabled because of races.
118// Enable further processing to see if they recur.
119#if defined(HAVE_GCCOVER) && (defined(_TARGET_X86_) || defined(_TARGET_AMD64_)) && !defined(FEATURE_PAL)
120#define GCCOVER_TOLERATE_SPURIOUS_AV
121#endif
122
123//Turns on a startup delay to allow simulation of slower and faster startup times.
124#define ENABLE_STARTUP_DELAY
125
126
127#ifdef _DEBUG
128
129//hurray DAC makes everything more fun - you can't have defines that control whether
130//or not data members are visible which differ between DAC and non-DAC builds.
131//All of the _DATA defines match DAC and non-DAC, the other defines here are off in the DAC.
132#if defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPORTED)
133// See code:ProfControlBlock#TestOnlyELT.
134#define PROF_TEST_ONLY_FORCE_ELT_DATA
135// See code:ProfControlBlock#TestOnlyObjectAllocated.
136#define PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED_DATA
137#endif // PROFILING_SUPPORTED_DATA || PROFILING_SUPPORTED
138
139#if defined(PROFILING_SUPPORTED)
140// See code:ProfControlBlock#TestOnlyELT.
141#define PROF_TEST_ONLY_FORCE_ELT
142// See code:ProfControlBlock#TestOnlyObjectAllocated.
143#define PROF_TEST_ONLY_FORCE_OBJECT_ALLOCATED
144#endif // PROFILING_SUPPORTED
145
146#endif // _DEBUG
147
148// MUST NEVER CHECK IN WITH THIS ENABLED.
149// This is just for convenience in doing performance investigations in a checked-out enlistment.
150// #define FEATURE_ENABLE_NO_RANGE_CHECKS
151
152// This controls whether a compilation-timing feature that relies on Windows APIs, if available, else direct
153// hardware instructions (rdtsc), for accessing high-resolution hardware timers is enabled. This is disabled
154// in Silverlight (just to avoid thinking about whether the extra code space is worthwhile).
155#define FEATURE_JIT_TIMER
156
157// This feature in RyuJIT supersedes the FEATURE_JIT_TIMER. In addition to supporting the time log file, this
158// feature also supports using COMPlus_JitTimeLogCsv=a.csv, which will dump method-level and phase-level timing
159// statistics. Also see comments on FEATURE_JIT_TIMER.
160#define FEATURE_JIT_METHOD_PERF
161
162
163#ifndef FEATURE_USE_ASM_GC_WRITE_BARRIERS
164// If we're not using assembly write barriers, then this turns on a performance measurement
165// mode that gathers and prints statistics about # of GC write barriers invokes.
166// #define FEATURE_COUNT_GC_WRITE_BARRIERS
167#endif
168
169// Enables a mode in which GC is completely conservative in stacks and registers: all stack slots and registers
170// are treated as potential pinned interior pointers. When enabled, the runtime flag COMPLUS_GCCONSERVATIVE
171// determines dynamically whether GC is conservative. Note that appdomain unload, LCG and unloadable assemblies
172// do not work reliably with conservative GC.
173#define FEATURE_CONSERVATIVE_GC 1
174
175#if (defined(_TARGET_ARM_) && !defined(ARM_SOFTFP)) || defined(_TARGET_ARM64_)
176#define FEATURE_HFA
177#endif
178
179// ARM requires that 64-bit primitive types are aligned at 64-bit boundaries for interlocked-like operations.
180// Additionally the platform ABI requires these types and composite type containing them to be similarly
181// aligned when passed as arguments.
182#ifdef _TARGET_ARM_
183#define FEATURE_64BIT_ALIGNMENT
184#endif
185
186// Prefer double alignment for structs and arrays with doubles. Put arrays of doubles more agressively
187// into large object heap for performance because large object heap is 8 byte aligned
188#if !defined(FEATURE_64BIT_ALIGNMENT) && !defined(_WIN64)
189#define FEATURE_DOUBLE_ALIGNMENT_HINT
190#endif
191
192#if defined(FEATURE_CORESYSTEM)
193#define FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
194#endif // defined(FEATURE_CORESYSTEM)
195
196// If defined, support interpretation.
197#if !defined(CROSSGEN_COMPILE)
198
199#if !defined(FEATURE_PAL)
200#define FEATURE_STACK_SAMPLING
201#endif // defined (ALLOW_SXS_JIT)
202
203#endif // !defined(CROSSGEN_COMPILE)
204
205#if defined(FEATURE_INTERPRETER) && defined(CROSSGEN_COMPILE)
206#undef FEATURE_INTERPRETER
207#endif
208