[Tizen] Unify dnetmemoryenumlib terms to match the codebase (#291)
[platform/upstream/coreclr.git] / src / vm / eeconfig.h
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 // EEConfig.H
5 //
6
7 //
8 // Fetched configuration data from the registry (should we Jit, run GC checks ...)
9 //
10 //
11
12
13
14 #ifndef EECONFIG_H
15 #define EECONFIG_H
16
17 class MethodDesc;
18
19 #include "shash.h"
20 #include "corhost.h"
21
22 #ifdef _DEBUG
23 class TypeNamesList
24 {
25     class TypeName
26     {
27         LPUTF8      typeName;
28         TypeName *next;           // Next name
29
30         friend class TypeNamesList;
31     };
32
33     TypeName     *pNames;         // List of names
34
35 public:
36     TypeNamesList();
37     ~TypeNamesList();
38
39     HRESULT Init(__in_z LPCWSTR str);
40     bool IsInList(LPCUTF8 typeName);
41 };
42 #endif
43
44 typedef struct _ConfigStringKeyValuePair
45 {
46     WCHAR * key;
47     WCHAR * value;
48     
49     _ConfigStringKeyValuePair()
50     {
51         key = NULL;
52         value = NULL;
53     }
54     
55     WCHAR * GetKey()
56     {
57         return key;
58     }
59 } ConfigStringKeyValuePair;
60
61 typedef WStringSHash<ConfigStringKeyValuePair> ConfigStringHashtable;
62
63 class ConfigList;
64
65 //
66 // Holds a pointer to a hashtable that is populated with data from config files.
67 // Also acts as a node for a circular doubly-linked list.
68 //
69 class ConfigSource
70 {
71     friend class ConfigList;
72 public:
73     ConfigSource();
74     ~ConfigSource();
75
76     ConfigStringHashtable* Table();
77
78     //
79     // Connect this node into the list that prev is in.
80     //
81     void Add(ConfigSource* prev);
82
83     ConfigSource* Next()
84     {
85         LIMITED_METHOD_CONTRACT;
86         return m_pNext;
87     }
88
89     ConfigSource* Previous()
90     {
91         LIMITED_METHOD_CONTRACT;
92         return m_pPrev;
93     }
94
95
96 private:
97     ConfigStringHashtable m_Table;
98     ConfigSource *m_pNext;
99     ConfigSource *m_pPrev;
100 };
101
102 //
103 // Wrapper around the ConfigSource circular doubly-linked list.
104 //
105 class ConfigList
106 {
107 public:
108     //
109     // Iterator  for traversing through a ConfigList.
110     //
111     class ConfigIter
112     {
113     public:
114         ConfigIter(ConfigList* pList)
115         {
116             CONTRACTL {
117                 NOTHROW;
118                 GC_NOTRIGGER;
119                 // MODE_ANY;
120                 FORBID_FAULT;
121             } CONTRACTL_END;
122             
123             pEnd = &(pList->m_pElement);
124             pCurrent = pEnd;
125         }
126
127         //
128         // TODO: Check if iterating through the list once skips an element.
129         // Returns the next node. If the next node is the head, returns null.
130         // Note that iteration can be resumed by calling next again.
131         //
132         ConfigStringHashtable* Next()
133         {
134             CONTRACT (ConfigStringHashtable*) {
135                 NOTHROW;
136                 GC_NOTRIGGER;
137                 // MODE_ANY;
138                 FORBID_FAULT;
139                 POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
140             } CONTRACT_END;
141         
142             pCurrent = pCurrent->Next();;
143             if(pCurrent == pEnd)
144                 RETURN NULL;
145             else
146                 RETURN pCurrent->Table();
147         }
148
149         ConfigStringHashtable* Previous()
150         {
151             CONTRACT (ConfigStringHashtable*) {
152                 NOTHROW;
153                 GC_NOTRIGGER;
154                 FORBID_FAULT;
155                 // MODE_ANY; 
156                 POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
157             } CONTRACT_END;
158
159             pCurrent = pCurrent->Previous();
160             if(pCurrent == pEnd)
161                 RETURN NULL;
162             else
163                 RETURN pCurrent->Table();
164         }
165
166     private:
167         ConfigSource* pEnd;
168         ConfigSource* pCurrent;
169     };
170
171     ConfigStringHashtable* Add()
172     {
173         CONTRACT (ConfigStringHashtable*) {
174             NOTHROW;
175             GC_NOTRIGGER;
176             // MODE_ANY;
177             POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
178         } CONTRACT_END;
179
180         ConfigSource* pEntry = new (nothrow) ConfigSource();
181
182         if (pEntry == NULL)
183             RETURN NULL;
184         
185         pEntry->Add(&m_pElement);
186         RETURN pEntry->Table();
187     }
188
189     ConfigStringHashtable* Append()
190     {
191         CONTRACT (ConfigStringHashtable*) {
192             NOTHROW;
193             GC_NOTRIGGER;
194             // MODE_ANY;
195             POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
196         } CONTRACT_END;
197         
198         ConfigSource* pEntry = new (nothrow) ConfigSource();
199         if (pEntry == NULL)
200             RETURN NULL;
201         
202         pEntry->Add(m_pElement.Previous());
203         RETURN pEntry->Table();
204     }
205
206     void Append(ConfigSource * pEntry)
207     {
208         LIMITED_METHOD_CONTRACT;
209         PRECONDITION(CheckPointer(pEntry));
210
211         pEntry->Add(m_pElement.Previous());
212     }
213
214     ~ConfigList()
215     {
216         CONTRACTL {
217             NOTHROW;
218             GC_NOTRIGGER;
219             // MODE_ANY;
220             FORBID_FAULT;
221         } CONTRACTL_END;
222
223         ConfigSource* pNext = m_pElement.Next();
224         while(pNext != &m_pElement) {
225             ConfigSource *last = pNext;
226             pNext = pNext->m_pNext;
227             delete last;
228         }
229     }
230
231 friend class ConfigIter;
232
233 private:
234     ConfigSource m_pElement;
235 };
236
237 enum { OPT_BLENDED,
238     OPT_SIZE,
239     OPT_SPEED,
240     OPT_RANDOM,
241     OPT_DEFAULT = OPT_BLENDED };
242
243 enum ParseCtl {
244     parseAll,               // parse entire config file
245     stopAfterRuntimeSection // stop after <runtime>...</runtime> section
246 };
247
248 class EEConfig
249 {
250 public:
251     typedef enum {
252         CONFIG_SYSTEM,
253         CONFIG_APPLICATION,
254         CONFIG_SYSTEMONLY
255     } ConfigSearch;
256
257     static HRESULT Setup();
258
259     HRESULT Init();
260     HRESULT Cleanup();
261
262     // Spinning heuristics
263
264     DWORD         SpinInitialDuration(void)       const {LIMITED_METHOD_CONTRACT;  return dwSpinInitialDuration; }
265     DWORD         SpinBackoffFactor(void)         const {LIMITED_METHOD_CONTRACT;  return dwSpinBackoffFactor; }
266     DWORD         SpinLimitProcCap(void)          const {LIMITED_METHOD_CONTRACT;  return dwSpinLimitProcCap; }
267     DWORD         SpinLimitProcFactor(void)       const {LIMITED_METHOD_CONTRACT;  return dwSpinLimitProcFactor; }
268     DWORD         SpinLimitConstant(void)         const {LIMITED_METHOD_CONTRACT;  return dwSpinLimitConstant; }
269     DWORD         SpinRetryCount(void)            const {LIMITED_METHOD_CONTRACT;  return dwSpinRetryCount; }
270     DWORD         MonitorSpinCount(void)          const {LIMITED_METHOD_CONTRACT;  return dwMonitorSpinCount; }
271
272     // Jit-config
273
274     DWORD         JitHostMaxSlabCache(void)                 const {LIMITED_METHOD_CONTRACT;  return dwJitHostMaxSlabCache; }
275     bool          GetTrackDynamicMethodDebugInfo(void)      const {LIMITED_METHOD_CONTRACT;  return fTrackDynamicMethodDebugInfo; }    
276     unsigned int  GenOptimizeType(void)                     const {LIMITED_METHOD_CONTRACT;  return iJitOptimizeType; }
277     bool          JitFramed(void)                           const {LIMITED_METHOD_CONTRACT;  return fJitFramed; }
278     bool          JitAlignLoops(void)                       const {LIMITED_METHOD_CONTRACT;  return fJitAlignLoops; }
279     bool          AddRejitNops(void)                        const {LIMITED_METHOD_DAC_CONTRACT;  return fAddRejitNops; }
280     bool          JitMinOpts(void)                          const {LIMITED_METHOD_CONTRACT;  return fJitMinOpts; }
281     
282     // Tiered Compilation config
283 #if defined(FEATURE_TIERED_COMPILATION)
284     bool          TieredCompilation(void)           const { LIMITED_METHOD_CONTRACT;  return fTieredCompilation; }
285     bool          TieredCompilation_QuickJit() const { LIMITED_METHOD_CONTRACT; return fTieredCompilation_QuickJit; }
286     bool          TieredCompilation_QuickJitForLoops() const { LIMITED_METHOD_CONTRACT; return fTieredCompilation_QuickJitForLoops; }
287     bool          TieredCompilation_CallCounting()  const { LIMITED_METHOD_CONTRACT; return fTieredCompilation_CallCounting; }
288     DWORD         TieredCompilation_CallCountThreshold() const { LIMITED_METHOD_CONTRACT; return tieredCompilation_CallCountThreshold; }
289     DWORD         TieredCompilation_CallCountingDelayMs() const { LIMITED_METHOD_CONTRACT; return tieredCompilation_CallCountingDelayMs; }
290 #endif
291
292 #ifndef CROSSGEN_COMPILE
293     bool          BackpatchEntryPointSlots() const { LIMITED_METHOD_CONTRACT; return backpatchEntryPointSlots; }
294 #endif
295
296 #if defined(FEATURE_GDBJIT) && defined(_DEBUG)
297     inline bool ShouldDumpElfOnMethod(LPCUTF8 methodName) const
298     {
299         CONTRACTL {
300             NOTHROW;
301             GC_NOTRIGGER;
302             PRECONDITION(CheckPointer(methodName, NULL_OK));
303         } CONTRACTL_END
304         return RegexOrExactMatch(pszGDBJitElfDump, methodName);
305     }
306 #endif // FEATURE_GDBJIT && _DEBUG
307
308 #if defined(FEATURE_GDBJIT_FRAME)
309     inline bool ShouldEmitDebugFrame(void) const {LIMITED_METHOD_CONTRACT; return fGDBJitEmitDebugFrame;}
310 #endif // FEATURE_GDBJIT_FRAME
311     BOOL PInvokeRestoreEsp(BOOL fDefault) const
312     {
313         LIMITED_METHOD_CONTRACT;
314         
315         switch (fPInvokeRestoreEsp)
316         {
317             case (unsigned)-1: return fDefault;
318             case            0: return FALSE;
319             default          : return TRUE;
320         }
321     }
322
323     bool LegacyNullReferenceExceptionPolicy(void)   const {LIMITED_METHOD_CONTRACT;  return fLegacyNullReferenceExceptionPolicy; }
324     bool LegacyUnhandledExceptionPolicy(void)       const {LIMITED_METHOD_CONTRACT;  return fLegacyUnhandledExceptionPolicy; }
325
326 #ifdef FEATURE_CORRUPTING_EXCEPTIONS
327     // Returns a bool to indicate if the legacy CSE (pre-v4) behaviour is enabled or not
328     bool LegacyCorruptedStateExceptionsPolicy(void) const {LIMITED_METHOD_CONTRACT;  return fLegacyCorruptedStateExceptionsPolicy; }
329 #endif // FEATURE_CORRUPTING_EXCEPTIONS
330
331     bool InteropValidatePinnedObjects()             const { LIMITED_METHOD_CONTRACT;  return m_fInteropValidatePinnedObjects; }
332     bool InteropLogArguments()                      const { LIMITED_METHOD_CONTRACT;  return m_fInteropLogArguments; }
333
334 #ifdef _DEBUG
335     bool GenDebuggableCode(void)                    const {LIMITED_METHOD_CONTRACT;  return fDebuggable; }
336     bool IsStressOn(void)                           const {LIMITED_METHOD_CONTRACT;  return fStressOn; }
337     int GetAPIThreadStressCount(void)               const {LIMITED_METHOD_CONTRACT;  return apiThreadStressCount; }
338
339     bool ShouldExposeExceptionsInCOMToConsole()     const {LIMITED_METHOD_CONTRACT;  return (iExposeExceptionsInCOM & 1) != 0; }
340     bool ShouldExposeExceptionsInCOMToMsgBox()      const {LIMITED_METHOD_CONTRACT;  return (iExposeExceptionsInCOM & 2) != 0; }
341
342     static bool RegexOrExactMatch(LPCUTF8 regex, LPCUTF8 input);
343
344     inline bool ShouldPrestubHalt(MethodDesc* pMethodInfo) const
345     {
346         WRAPPER_NO_CONTRACT;
347         return IsInMethList(pPrestubHalt, pMethodInfo);
348     }
349
350     inline bool ShouldInvokeHalt(MethodDesc* pMethodInfo) const
351     {
352         WRAPPER_NO_CONTRACT;
353         return IsInMethList(pInvokeHalt, pMethodInfo);
354     }
355
356
357     inline bool ShouldPrestubGC(MethodDesc* pMethodInfo) const
358     { 
359         WRAPPER_NO_CONTRACT;
360         return IsInMethList(pPrestubGC, pMethodInfo);
361     }
362     inline bool ShouldBreakOnClassLoad(LPCUTF8 className) const
363     { 
364         CONTRACTL {
365             NOTHROW;
366             GC_NOTRIGGER;
367             // MODE_ANY;
368             PRECONDITION(CheckPointer(className, NULL_OK));
369         } CONTRACTL_END
370         return RegexOrExactMatch(pszBreakOnClassLoad, className);
371     }
372     inline bool ShouldBreakOnClassBuild(LPCUTF8 className) const
373     { 
374         CONTRACTL {
375             NOTHROW;
376             GC_NOTRIGGER;
377             // MODE_ANY;
378             PRECONDITION(CheckPointer(className, NULL_OK));
379         } CONTRACTL_END
380         return RegexOrExactMatch(pszBreakOnClassBuild, className);
381     }
382     inline bool BreakOnInstantiationEnabled() const
383     { 
384         LIMITED_METHOD_CONTRACT;
385         return pszBreakOnInstantiation != NULL;
386     }
387     inline bool ShouldBreakOnInstantiation(LPCUTF8 className) const
388     { 
389         CONTRACTL {
390             NOTHROW;
391             GC_NOTRIGGER;
392             // MODE_ANY;
393             PRECONDITION(CheckPointer(className, NULL_OK));
394         } CONTRACTL_END
395         return RegexOrExactMatch(pszBreakOnInstantiation, className);
396     }
397     inline bool ShouldBreakOnMethod(LPCUTF8 methodName) const
398     {
399         CONTRACTL {
400             NOTHROW;
401             GC_NOTRIGGER;
402             // MODE_ANY;
403             PRECONDITION(CheckPointer(methodName, NULL_OK));
404         } CONTRACTL_END
405         return RegexOrExactMatch(pszBreakOnMethodName, methodName);
406     }
407     inline bool ShouldDumpOnClassLoad(LPCUTF8 className) const
408     {
409         CONTRACTL {
410             NOTHROW;
411             GC_NOTRIGGER;
412             // MODE_ANY;
413             PRECONDITION(CheckPointer(className, NULL_OK));
414         } CONTRACTL_END
415         return RegexOrExactMatch(pszDumpOnClassLoad, className);
416     }
417     inline bool ShouldBreakOnInteropStubSetup(LPCUTF8 methodName) const
418     {
419         CONTRACTL {
420             NOTHROW;
421             GC_NOTRIGGER;
422             // MODE_ANY;
423             PRECONDITION(CheckPointer(methodName, NULL_OK));
424         } CONTRACTL_END
425         return RegexOrExactMatch(pszBreakOnInteropStubSetup, methodName);
426     }
427     inline bool ShouldBreakOnComToClrNativeInfoInit(LPCUTF8 methodName) const
428     {
429         CONTRACTL {
430             NOTHROW;
431             GC_NOTRIGGER;
432             // MODE_ANY;
433             PRECONDITION(CheckPointer(methodName, NULL_OK));
434         } CONTRACTL_END
435         return RegexOrExactMatch(pszBreakOnComToClrNativeInfoInit, methodName);
436     }
437     inline bool ShouldBreakOnStructMarshalSetup(LPCUTF8 className) const
438     { 
439         CONTRACTL {
440             NOTHROW;
441             GC_NOTRIGGER;
442             // MODE_ANY;
443             PRECONDITION(CheckPointer(className, NULL_OK));
444         } CONTRACTL_END
445         return RegexOrExactMatch(pszBreakOnStructMarshalSetup, className);
446     }
447     static HRESULT ParseTypeList(__in_z LPWSTR str, TypeNamesList** out);
448     static void DestroyTypeList(TypeNamesList* list);
449
450     inline bool ShouldGcCoverageOnMethod(LPCUTF8 methodName) const
451     { 
452         CONTRACTL {
453             NOTHROW;
454             GC_NOTRIGGER;
455             // MODE_ANY;
456             PRECONDITION(CheckPointer(methodName, NULL_OK));
457         } CONTRACTL_END
458         return (pszGcCoverageOnMethod == 0 || methodName == 0 || RegexOrExactMatch(pszGcCoverageOnMethod, methodName));
459     }
460
461     bool IsJitVerificationDisabled(void)    const {LIMITED_METHOD_CONTRACT;  return fJitVerificationDisable; }
462
463 #ifdef WIN64EXCEPTIONS
464     bool SuppressLockViolationsOnReentryFromOS() const {LIMITED_METHOD_CONTRACT;  return fSuppressLockViolationsOnReentryFromOS; }
465 #endif
466
467 #ifdef STUBLINKER_GENERATES_UNWIND_INFO
468     bool IsStubLinkerUnwindInfoVerificationOn() const { LIMITED_METHOD_CONTRACT; return fStubLinkerUnwindInfoVerificationOn; }
469 #endif
470
471 #endif // _DEBUG
472
473 #ifdef FEATURE_COMINTEROP
474     inline bool LogCCWRefCountChangeEnabled()
475     {
476         LIMITED_METHOD_CONTRACT;
477         return bLogCCWRefCountChange;
478     }
479
480     void SetLogCCWRefCountChangeEnabled(bool newVal);
481     bool ShouldLogCCWRefCountChange(LPCUTF8 pszClassName, LPCUTF8 pszNamespace) const;
482
483     inline bool EnableRCWCleanupOnSTAShutdown()
484     {
485         LIMITED_METHOD_CONTRACT;
486         return fEnableRCWCleanupOnSTAShutdown;
487     }
488 #endif // FEATURE_COMINTEROP
489
490 #ifdef _DEBUG
491     bool ExpandModulesOnLoad(void) const { LIMITED_METHOD_CONTRACT; return fExpandAllOnLoad; }
492 #endif //_DEBUG
493
494 #ifdef FEATURE_DOUBLE_ALIGNMENT_HINT
495     // Because the large object heap is 8 byte aligned, we want to put
496     // arrays of doubles there more agressively than normal objects.
497     // This is the threshold for this.  It is the number of doubles,
498     // not the number of bytes in the array.
499     unsigned int  GetDoubleArrayToLargeObjectHeapThreshold() const { LIMITED_METHOD_CONTRACT; return DoubleArrayToLargeObjectHeapThreshold; }
500 #endif
501
502     inline bool ProbeForStackOverflow() const
503     {
504         LIMITED_METHOD_CONTRACT;
505         return fProbeForStackOverflow;
506     }
507
508 #ifdef _DEBUG
509     inline bool AppDomainLeaks() const
510     {
511         // Workaround for CoreCLR bug #12075, until this configuration option is removed
512         // (CoreCLR Bug #12094)
513         LIMITED_METHOD_DAC_CONTRACT;
514         return false;
515     }
516 #endif
517
518 #ifdef TEST_DATA_CONSISTENCY
519     // get the value of fTestDataConsistency, which controls whether we test that we can correctly detect
520     // held locks in DAC builds. This is determined by an environment variable. 
521     inline bool TestDataConsistency() const { LIMITED_METHOD_DAC_CONTRACT; return fTestDataConsistency; }
522 #endif
523
524 #ifdef _DEBUG
525
526     unsigned SuspendThreadDeadlockTimeoutMs() const
527     {LIMITED_METHOD_CONTRACT; return m_SuspendThreadDeadlockTimeoutMs; }
528     
529     unsigned SuspendDeadlockTimeout() const
530     {LIMITED_METHOD_CONTRACT; return m_SuspendDeadlockTimeout; }
531
532     // Verifier
533     bool    IsVerifierOff()                 const {LIMITED_METHOD_CONTRACT;  return fVerifierOff; }
534
535     inline bool fAssertOnBadImageFormat() const
536     {LIMITED_METHOD_CONTRACT;  return m_fAssertOnBadImageFormat; }
537
538     inline bool fAssertOnFailFast() const
539     {LIMITED_METHOD_CONTRACT;  return m_fAssertOnFailFast; }
540
541     inline bool SuppressChecks() const
542     {LIMITED_METHOD_CONTRACT;  return fSuppressChecks; }
543
544     inline bool EnableFullDebug() const
545     {LIMITED_METHOD_CONTRACT;  return fEnableFullDebug; }
546
547 #endif
548 #ifdef ENABLE_STARTUP_DELAY
549     inline int StartupDelayMS()
550     { LIMITED_METHOD_CONTRACT; return iStartupDelayMS; }
551 #endif
552
553 #ifdef VERIFY_HEAP
554     // GC config
555     enum HeapVerifyFlags {
556         HEAPVERIFY_NONE             = 0,
557         HEAPVERIFY_GC               = 1,   // Verify the heap at beginning and end of GC
558         HEAPVERIFY_BARRIERCHECK     = 2,   // Verify the brick table
559         HEAPVERIFY_SYNCBLK          = 4,   // Verify sync block scanning
560
561         // the following options can be used to mitigate some of the overhead introduced
562         // by heap verification.  some options might cause heap verifiction to be less
563         // effective depending on the scenario.
564
565         HEAPVERIFY_NO_RANGE_CHECKS  = 0x10,   // Excludes checking if an OBJECTREF is within the bounds of the managed heap
566         HEAPVERIFY_NO_MEM_FILL      = 0x20,   // Excludes filling unused segment portions with fill pattern
567         HEAPVERIFY_POST_GC_ONLY     = 0x40,   // Performs heap verification post-GCs only (instead of before and after each GC)
568         HEAPVERIFY_DEEP_ON_COMPACT  = 0x80    // Performs deep object verfication only on compacting GCs.
569     };
570     
571     int     GetHeapVerifyLevel()                  {LIMITED_METHOD_CONTRACT;  return iGCHeapVerify;  }
572
573     bool    IsHeapVerifyEnabled()           const {LIMITED_METHOD_CONTRACT;  return iGCHeapVerify != 0; }
574 #endif
575
576 #if defined(STRESS_HEAP) || defined(_DEBUG)
577     void    SetGCStressLevel(int val)             {LIMITED_METHOD_CONTRACT;  iGCStress = val;  }
578
579     enum  GCStressFlags {
580         GCSTRESS_NONE               = 0,
581         GCSTRESS_ALLOC              = 1,    // GC on all allocs and 'easy' places
582         GCSTRESS_TRANSITION         = 2,    // GC on transitions to preemtive GC
583         GCSTRESS_INSTR_JIT          = 4,    // GC on every allowable JITed instr
584         GCSTRESS_INSTR_NGEN         = 8,    // GC on every allowable NGEN instr
585         GCSTRESS_UNIQUE             = 16,   // GC only on a unique stack trace
586     };
587
588     GCStressFlags GetGCStressLevel()        const { WRAPPER_NO_CONTRACT; SUPPORTS_DAC; return GCStressFlags(iGCStress); }
589 #endif
590
591 #ifdef STRESS_HEAP
592
593     bool    IsGCStressMix  ()               const {LIMITED_METHOD_CONTRACT;  return iGCStressMix != 0;}
594     int     GetGCStressStep()               const {LIMITED_METHOD_CONTRACT;  return iGCStressStep; }
595 #endif
596
597     bool    IsGCBreakOnOOMEnabled()         const {LIMITED_METHOD_CONTRACT;  return fGCBreakOnOOM; }
598
599     size_t  GetGCgen0size  ()               const {LIMITED_METHOD_CONTRACT;  return iGCgen0size;   }
600     void    SetGCgen0size  (size_t iSize)   {LIMITED_METHOD_CONTRACT; iGCgen0size = iSize;   }
601     size_t  GetSegmentSize ()               const {LIMITED_METHOD_CONTRACT;  return iGCSegmentSize; }
602     void    SetSegmentSize (size_t iSize)   {LIMITED_METHOD_CONTRACT;  iGCSegmentSize = iSize; }
603
604     int     GetGCconcurrent()               const {LIMITED_METHOD_CONTRACT;  return iGCconcurrent; }
605     void    SetGCconcurrent(int val)              {LIMITED_METHOD_CONTRACT;  iGCconcurrent = val;  }
606 #ifdef _DEBUG
607     int     GetGCLatencyMode()              const {LIMITED_METHOD_CONTRACT;  return iGCLatencyMode; }
608 #endif //_DEBUG
609     int     GetGCForceCompact()             const {LIMITED_METHOD_CONTRACT; return iGCForceCompact; }
610     int     GetGCRetainVM ()                const {LIMITED_METHOD_CONTRACT; return iGCHoardVM;}
611     DWORD   GetGCLOHThreshold()             const {LIMITED_METHOD_CONTRACT; return iGCLOHThreshold;}
612     int     GetGCLOHCompactionMode()        const {LIMITED_METHOD_CONTRACT; return iGCLOHCompactionMode;}
613     int     GetGCHeapCount()                const {LIMITED_METHOD_CONTRACT; return iGCHeapCount;}
614     int     GetGCNoAffinitize ()            const {LIMITED_METHOD_CONTRACT; return iGCNoAffinitize;}
615     size_t  GetGCAffinityMask()             const {LIMITED_METHOD_CONTRACT; return iGCAffinityMask;}
616     size_t  GetGCHeapHardLimit()            const {LIMITED_METHOD_CONTRACT; return iGCHeapHardLimit;}
617     int     GetGCHeapHardLimitPercent()     const {LIMITED_METHOD_CONTRACT; return iGCHeapHardLimitPercent;}
618
619 #ifdef GCTRIMCOMMIT
620
621     int     GetGCTrimCommit()               const {LIMITED_METHOD_CONTRACT; return iGCTrimCommit;}
622
623 #endif
624
625 #ifdef FEATURE_CONSERVATIVE_GC
626     bool    GetGCConservative()             const {LIMITED_METHOD_CONTRACT; return iGCConservative;}
627 #endif
628 #ifdef _WIN64
629     bool    GetGCAllowVeryLargeObjects()    const {LIMITED_METHOD_CONTRACT; return iGCAllowVeryLargeObjects;}
630 #endif
631 #ifdef _DEBUG
632     bool    SkipGCCoverage(LPCUTF8 assemblyName) const {WRAPPER_NO_CONTRACT; return (pSkipGCCoverageList != NULL 
633                                                                                     && pSkipGCCoverageList->IsInList(assemblyName));}
634 #endif
635
636 #ifdef _DEBUG
637     inline DWORD FastGCStressLevel() const
638     {LIMITED_METHOD_CONTRACT;  return iFastGCStress;}
639
640     inline DWORD InjectFatalError() const
641     {
642         LIMITED_METHOD_CONTRACT;
643         return iInjectFatalError;
644     }
645
646     inline BOOL SaveThreadInfo() const
647     {
648         return fSaveThreadInfo;
649     }
650
651     inline DWORD SaveThreadInfoMask() const
652     {
653         return dwSaveThreadInfoMask;
654     }
655 #endif
656
657
658 #ifdef _DEBUG
659     // Interop config
660     IUnknown* GetTraceIUnknown()            const {LIMITED_METHOD_CONTRACT;  return m_pTraceIUnknown; }
661     int     GetTraceWrapper()               const {LIMITED_METHOD_CONTRACT;  return m_TraceWrapper;      }
662 #endif
663
664     // Loader
665
666     enum RequireZapsType
667     {
668         REQUIRE_ZAPS_NONE,      // Dont care if native image is used or not
669         REQUIRE_ZAPS_ALL,       // All assemblies must have native images
670         REQUIRE_ZAPS_ALL_JIT_OK,// All assemblies must have native images, but its OK if the JIT-compiler also gets used (if some function was not ngenned)
671         REQUIRE_ZAPS_SUPPORTED, // All assemblies must have native images, unless the loader does not support the scenario. Its OK if the JIT-compiler also gets used
672         
673         REQUIRE_ZAPS_COUNT
674     };
675     RequireZapsType RequireZaps()           const {LIMITED_METHOD_CONTRACT;  return iRequireZaps; }
676     bool    RequireZap(LPCUTF8 assemblyName) const;
677 #ifdef _DEBUG
678     bool    ForbidZap(LPCUTF8 assemblyName) const;
679 #endif
680     bool    ExcludeReadyToRun(LPCUTF8 assemblyName) const;
681     
682     LPCWSTR ZapSet()                        const { LIMITED_METHOD_CONTRACT; return pZapSet; }
683
684     bool    NgenBindOptimizeNonGac()        const { LIMITED_METHOD_CONTRACT; return fNgenBindOptimizeNonGac; }
685
686     LPUTF8  GetZapBBInstr()                 const { LIMITED_METHOD_CONTRACT; return szZapBBInstr; }
687     LPWSTR  GetZapBBInstrDir()              const { LIMITED_METHOD_CONTRACT; return szZapBBInstrDir; }
688     DWORD   DisableStackwalkCache()         const {LIMITED_METHOD_CONTRACT;  return dwDisableStackwalkCache; }
689
690     bool    StressLog()                     const { LIMITED_METHOD_CONTRACT; return fStressLog; }
691     bool    ForceEnc()                      const { LIMITED_METHOD_CONTRACT; return fForceEnc; }
692
693     // Optimizations to improve working set
694
695     HRESULT sync();    // check the registry again and update local state
696
697     // Helpers to read configuration
698     
699     // This function exposes the config file data to CLRConfig. A pointer to this function is passed into CLRConfig on EEConfig::init.
700     // We are using BOOLs instead of ConfigSearch for direction since CLRConfig isn't always linked to EEConfig.
701     static HRESULT GetConfigValueCallback(__in_z LPCWSTR pKey, __deref_out_opt LPCWSTR* value, BOOL systemOnly, BOOL applicationFirst);
702
703     //
704     // NOTE: The following function is deprecated; use the CLRConfig class instead. 
705     // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h.
706     // 
707     static HRESULT GetConfigString_DontUse_(__in_z LPCWSTR name, __deref_out_z LPWSTR*out, BOOL fPrependCOMPLUS = TRUE,
708                                   ConfigSearch direction = CONFIG_SYSTEM); // Note that you own the returned string!
709
710     //
711     // NOTE: The following function is deprecated; use the CLRConfig class instead. 
712     // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h.
713     // 
714     static DWORD GetConfigDWORD_DontUse_(__in_z LPCWSTR name, DWORD defValue,
715                                 DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL,
716                                 BOOL fPrependCOMPLUS = TRUE,
717                                 ConfigSearch direction = CONFIG_SYSTEM);
718
719     //
720     // NOTE: The following function is deprecated; use the CLRConfig class instead. 
721     // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h.
722     // 
723     static ULONGLONG GetConfigULONGLONG_DontUse_(__in_z LPCWSTR name, ULONGLONG defValue,
724                                              DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL,
725                                              BOOL fPrependCOMPLUS = TRUE,
726                                              ConfigSearch direction = CONFIG_SYSTEM);
727     //
728     // NOTE: The following function is deprecated; use the CLRConfig class instead. 
729     // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h.
730     // 
731     static DWORD GetConfigDWORDFavoringConfigFile_DontUse_(__in_z LPCWSTR name, DWORD defValue,
732                                                   DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL,
733                                                   BOOL fPrependCOMPLUS = TRUE,
734                                                   ConfigSearch direction = CONFIG_SYSTEM);
735
736     //
737     // NOTE: The following function is deprecated; use the CLRConfig class instead. 
738     // To access a configuration value through CLRConfig, add an entry in file:../inc/CLRConfigValues.h.
739     // 
740     static DWORD GetConfigFlag_DontUse_(__in_z LPCWSTR name, DWORD bitToSet, bool defValue = FALSE);
741
742 #ifdef _DEBUG
743     // GC alloc logging
744     bool ShouldLogAlloc(const char *pClass) const { LIMITED_METHOD_CONTRACT; return pPerfTypesToLog && pPerfTypesToLog->IsInList(pClass);}
745     int AllocSizeThreshold()                const {LIMITED_METHOD_CONTRACT;  return iPerfAllocsSizeThreshold; }
746     int AllocNumThreshold()                 const { LIMITED_METHOD_CONTRACT; return iPerfNumAllocsThreshold;  }
747
748 #endif // _DEBUG
749
750 #ifdef _DEBUG
751     DWORD  NgenForceFailureMask()     { LIMITED_METHOD_CONTRACT; return dwNgenForceFailureMask; }
752     DWORD  NgenForceFailureCount()    { LIMITED_METHOD_CONTRACT; return dwNgenForceFailureCount; }
753     DWORD  NgenForceFailureKind()     { LIMITED_METHOD_CONTRACT; return dwNgenForceFailureKind;  }
754 #endif
755     enum GCPollType
756     {
757         GCPOLL_TYPE_DEFAULT,    // Use the default gc poll for the platform
758         GCPOLL_TYPE_HIJACK,     // Depend on thread hijacking for gc suspension
759         GCPOLL_TYPE_POLL,       // Emit function calls to a helper for GC Poll
760         GCPOLL_TYPE_INLINE,     // Emit inlined tests to the helper for GC Poll
761         GCPOLL_TYPE_COUNT
762     };
763     GCPollType GetGCPollType() { LIMITED_METHOD_CONTRACT; return iGCPollType; }
764
765 #ifdef _DEBUG
766
767     DWORD GetHostTestThreadAbort() const {LIMITED_METHOD_CONTRACT; return testThreadAbort;}
768
769 #define INJECTFAULT_LOADERHEAP      0x1
770 #define INJECTFAULT_GCHEAP          0x2
771 #define INJECTFAULT_SO              0x4
772 #define INJECTFAULT_GMHEAP          0x8
773 #define INJECTFAULT_DYNAMICCODEHEAP 0x10
774 #define INJECTFAULT_MAPVIEWOFFILE   0x20
775 #define INJECTFAULT_JITHEAP         0x40
776
777     DWORD ShouldInjectFault(DWORD faultType) const {LIMITED_METHOD_CONTRACT; return fShouldInjectFault & faultType;}
778     
779 #endif
780
781 private: //----------------------------------------------------------------
782
783     bool fInited;                   // have we synced to the registry at least once?
784
785     // Jit-config
786
787     DWORD dwJitHostMaxSlabCache;       // max size for jit host slab cache
788     bool fTrackDynamicMethodDebugInfo; //  Enable/Disable tracking dynamic method debug info
789     bool fJitFramed;                   // Enable/Disable EBP based frames
790     bool fJitAlignLoops;               // Enable/Disable loop alignment
791     bool fAddRejitNops;                // Enable/Disable nop padding for rejit.          default is true
792     bool fJitMinOpts;                  // Enable MinOpts for all jitted methods
793
794     unsigned iJitOptimizeType; // 0=Blended,1=SmallCode,2=FastCode,              default is 0=Blended
795     
796     unsigned fPInvokeRestoreEsp;  // -1=Default, 0=Never, Else=Always
797
798     bool fLegacyNullReferenceExceptionPolicy; // Old AV's as NullRef behavior
799     bool fLegacyUnhandledExceptionPolicy;     // Old unhandled exception policy (many are swallowed)
800
801 #ifdef FEATURE_CORRUPTING_EXCEPTIONS
802     bool fLegacyCorruptedStateExceptionsPolicy;
803 #endif // FEATURE_CORRUPTING_EXCEPTIONS
804
805     LPUTF8 pszBreakOnClassLoad;         // Halt just before loading this class
806
807 #ifdef TEST_DATA_CONSISTENCY
808     bool fTestDataConsistency;         // true if we are testing locks for data consistency in the debugger--
809                                        // If a lock is held during inspection, we assume the data under the lock
810                                        // is inconsistent. We have a special code path for testing this
811                                        // which we will follow if this is set. The value is determined by
812                                        // the environment variable TestDataConsistency
813 #endif
814
815     bool   m_fInteropValidatePinnedObjects; // After returning from a M->U interop call, validate GC heap around objects pinned by IL stubs.
816     bool   m_fInteropLogArguments; // Log all pinned arguments passed to an interop call
817
818 #ifdef _DEBUG
819     static HRESULT ParseMethList(__in_z LPWSTR str, MethodNamesList* * out);
820     static void DestroyMethList(MethodNamesList* list);
821     static bool IsInMethList(MethodNamesList* list, MethodDesc* pMD);
822
823     bool fDebuggable;
824     bool fStressOn;
825     int apiThreadStressCount;
826
827     MethodNamesList* pPrestubHalt;      // list of methods on which to break when hit prestub
828     MethodNamesList* pPrestubGC;        // list of methods on which to cause a GC when hit prestub
829     MethodNamesList* pInvokeHalt;      // list of methods on which to break when hit prestub
830
831
832     LPUTF8 pszBreakOnClassBuild;         // Halt just before loading this class
833     LPUTF8 pszBreakOnInstantiation;      // Halt just before instantiating a non-canonical generic type
834     LPUTF8 pszBreakOnMethodName;         // Halt when doing something with this method in the class defined in ClassBuild
835     LPUTF8 pszDumpOnClassLoad;           // Dump the class to the log
836
837     LPUTF8 pszBreakOnInteropStubSetup;   // Halt before we set up the interop stub for a method
838     LPUTF8 pszBreakOnComToClrNativeInfoInit; // Halt before we init the native info for a COM to CLR call
839     LPUTF8 pszBreakOnStructMarshalSetup; // Halt before the field marshallers are set up for a struct
840
841     bool   m_fAssertOnBadImageFormat;   // If false, don't assert on invalid IL (for testing)
842     bool   m_fAssertOnFailFast;         // If false, don't assert if we detect a stack corruption
843
844     bool   fConditionalContracts;       // Conditional contracts (off inside asserts)
845     bool   fSuppressChecks;             // Disable checks (including contracts)
846
847     DWORD  iExposeExceptionsInCOM;      // Should we exposed exceptions that will be transformed into HRs?
848
849     unsigned m_SuspendThreadDeadlockTimeoutMs;  // Used in Thread::SuspendThread()
850     unsigned m_SuspendDeadlockTimeout; // Used in Thread::SuspendRuntime. 
851
852     bool fEnableFullDebug;
853 #endif // _DEBUG
854
855 #ifdef FEATURE_COMINTEROP
856     bool bLogCCWRefCountChange;           // Is CCW logging on 
857     LPCUTF8 pszLogCCWRefCountChange;      // OutputDebugString when AddRef/Release is called on a CCW
858                                           // for the specified type(s)
859     bool fEnableRCWCleanupOnSTAShutdown;  // Register our IInitializeSpy even in classic processes
860 #endif // FEATURE_COMINTEROP
861
862 #ifdef FEATURE_DOUBLE_ALIGNMENT_HINT
863     unsigned int DoubleArrayToLargeObjectHeapThreshold;  // double arrays of more than this number of elems go in large object heap
864 #endif
865
866 #ifdef _DEBUG
867     bool fExpandAllOnLoad;              // True if we want to load all types/jit all methods in an assembly
868                                         // at load time.
869     bool fJitVerificationDisable;       // Turn off jit verification (for testing purposes only)
870
871
872     // Verifier
873     bool fVerifierOff;
874
875 #ifdef WIN64EXCEPTIONS
876     bool fSuppressLockViolationsOnReentryFromOS;
877 #endif
878
879 #ifdef STUBLINKER_GENERATES_UNWIND_INFO
880     bool fStubLinkerUnwindInfoVerificationOn;
881 #endif
882 #endif // _DEBUG
883 #ifdef ENABLE_STARTUP_DELAY
884     int iStartupDelayMS; //Adds sleep to startup.
885 #endif
886
887     // Spinning heuristics
888     DWORD dwSpinInitialDuration;
889     DWORD dwSpinBackoffFactor;
890     DWORD dwSpinLimitProcCap;
891     DWORD dwSpinLimitProcFactor;
892     DWORD dwSpinLimitConstant;
893     DWORD dwSpinRetryCount;
894     DWORD dwMonitorSpinCount;
895
896 #ifdef VERIFY_HEAP
897     int  iGCHeapVerify;
898 #endif
899
900 #if defined(STRESS_HEAP) || defined(_DEBUG)
901     int  iGCStress;
902 #endif
903
904 #ifdef STRESS_HEAP
905     int  iGCStressMix;
906     int  iGCStressStep;
907 #endif
908
909 #define DEFAULT_GC_PRN_LVL 3
910     size_t iGCgen0size;
911     size_t iGCSegmentSize;
912     int  iGCconcurrent;
913 #ifdef _DEBUG
914     int  iGCLatencyMode;
915 #endif //_DEBUG
916     int  iGCForceCompact;
917     int  iGCHoardVM;
918     int  iGCLOHCompactionMode;
919     DWORD iGCLOHThreshold;
920     int  iGCHeapCount;
921     int  iGCNoAffinitize;
922     size_t  iGCAffinityMask;
923     size_t iGCHeapHardLimit;
924     int iGCHeapHardLimitPercent;
925
926 #ifdef GCTRIMCOMMIT
927
928     int  iGCTrimCommit;
929
930 #endif
931
932 #ifdef FEATURE_CONSERVATIVE_GC
933     bool iGCConservative;
934 #endif // FEATURE_CONSERVATIVE_GC
935 #ifdef _WIN64
936     bool iGCAllowVeryLargeObjects;
937 #endif // _WIN64
938
939     bool fGCBreakOnOOM;
940
941 #ifdef _DEBUG
942     DWORD iFastGCStress;
943     LPUTF8 pszGcCoverageOnMethod;
944
945     DWORD iInjectFatalError;
946
947     BOOL fSaveThreadInfo;
948     DWORD dwSaveThreadInfoMask;
949     
950     AssemblyNamesList *pSkipGCCoverageList;
951 #endif
952
953     RequireZapsType iRequireZaps;
954     // Assemblies which need to have native images. 
955     // This is only used if iRequireZaps!=REQUIRE_ZAPS_NONE
956     // This can be used to enforce that ngen images are used only selectively for some assemblies
957     AssemblyNamesList * pRequireZapsList;
958     // assemblies which need NOT have native images.
959     // This is only used if iRequireZaps!=REQUIRE_ZAPS_NONE
960     // This overrides pRequireZapsList.
961     AssemblyNamesList * pRequireZapsExcludeList;
962
963     // Assemblies which cannot use Ready to Run images.
964     AssemblyNamesList * pReadyToRunExcludeList;
965
966 #ifdef _DEBUG
967     // Exact opposite of require zaps
968     BOOL iForbidZaps;
969     AssemblyNamesList * pForbidZapsList;
970     AssemblyNamesList * pForbidZapsExcludeList;
971 #endif
972
973     LPCWSTR pZapSet;
974
975     bool fNgenBindOptimizeNonGac;
976
977     bool fStressLog;
978     bool fForceEnc;
979     bool fProbeForStackOverflow;
980     
981     // Stackwalk optimization flag
982     DWORD dwDisableStackwalkCache;
983     
984     LPUTF8 szZapBBInstr;
985     LPWSTR szZapBBInstrDir;
986
987 #ifdef _DEBUG
988     // interop logging
989     IUnknown* m_pTraceIUnknown;
990     int       m_TraceWrapper;
991 #endif
992
993     // Flag to keep track of memory
994     int     m_fFreepZapSet;
995
996 #ifdef _DEBUG
997     // GC Alloc perf flags
998     int iPerfNumAllocsThreshold;        // Start logging after this many allocations are made
999     int iPerfAllocsSizeThreshold;       // Log allocations of this size or above
1000     TypeNamesList* pPerfTypesToLog;     // List of types whose allocations are to be logged
1001
1002 #endif // _DEBUG
1003
1004     // New configuration
1005     ConfigList  m_Configuration;
1006
1007 #ifdef _DEBUG
1008     DWORD dwNgenForceFailureMask;
1009     DWORD dwNgenForceFailureCount;
1010     DWORD dwNgenForceFailureKind;
1011 #endif
1012
1013     GCPollType iGCPollType;
1014
1015 #ifdef _DEBUG
1016     DWORD fShouldInjectFault;
1017     DWORD testThreadAbort;
1018 #endif
1019
1020 #if defined(FEATURE_TIERED_COMPILATION)
1021     bool fTieredCompilation;
1022     bool fTieredCompilation_QuickJit;
1023     bool fTieredCompilation_QuickJitForLoops;
1024     bool fTieredCompilation_CallCounting;
1025     DWORD tieredCompilation_CallCountThreshold;
1026     DWORD tieredCompilation_CallCountingDelayMs;
1027 #endif
1028
1029 #ifndef CROSSGEN_COMPILE
1030     bool backpatchEntryPointSlots;
1031 #endif
1032
1033 #if defined(FEATURE_GDBJIT) && defined(_DEBUG)
1034     LPCUTF8 pszGDBJitElfDump;
1035 #endif // FEATURE_GDBJIT && _DEBUG
1036
1037 #if defined(FEATURE_GDBJIT_FRAME)
1038     bool fGDBJitEmitDebugFrame;
1039 #endif
1040 public:
1041
1042     HRESULT GetConfiguration_DontUse_(__in_z LPCWSTR pKey, ConfigSearch direction, __deref_out_opt LPCWSTR* value);
1043
1044     DWORD GetConfigDWORDInternal_DontUse_ (__in_z LPCWSTR name, DWORD defValue,    //for getting data in the constructor of EEConfig
1045                                     DWORD level=(DWORD) REGUTIL::COR_CONFIG_ALL,
1046                                     BOOL fPrependCOMPLUS = TRUE,
1047                                     ConfigSearch direction = CONFIG_SYSTEM);
1048
1049     enum BitForMask {
1050         CallSite_1 = 0x0001,
1051         CallSite_2 = 0x0002,
1052         CallSite_3 = 0x0004,
1053         CallSite_4 = 0x0008,
1054         CallSite_5 = 0x0010,
1055         CallSite_6 = 0x0020,
1056         CallSite_7 = 0x0040,
1057         CallSite_8 = 0x0080,
1058     };
1059
1060 #if defined(_DEBUG) && !defined(DACCESS_COMPILE)
1061     void DebugCheckAndForceIBCFailure(BitForMask bitForMask);
1062 #endif
1063
1064 #if defined(_DEBUG)
1065 #if defined(_TARGET_AMD64_)
1066 private:
1067
1068     // Defaults to 0, which means we will not generate long jump dispatch stubs.
1069     // But if this is set to a positive integer, then this
1070     // will be 1/x ration of stubs we generate as long jump. So if x is 4, then
1071     // every 1 in 4 dispatch stubs will be long jump stubs.
1072     size_t m_cGenerateLongJumpDispatchStubRatio;
1073
1074     // Total count of stubs generated, used with above variable to determine if
1075     // the next stub should be a long jump.
1076     size_t m_cDispatchStubsGenerated;
1077
1078 public:
1079     BOOL ShouldGenerateLongJumpDispatchStub()
1080     {
1081         return (m_cDispatchStubsGenerated++ % m_cGenerateLongJumpDispatchStubRatio) == 0;
1082     }
1083 #else
1084 public:
1085     // Just return false when we're in DEBUG but not on AMD64
1086     BOOL ShouldGenerateLongJumpDispatchStub()
1087     {
1088         return FALSE;
1089     }
1090 #endif // _TARGET_AMD64_
1091 #endif // _DEBUG
1092
1093 #if defined(_DEBUG)
1094 private:
1095     bool bDiagnosticSuspend;
1096
1097 public:
1098     bool GetDiagnosticSuspend()
1099     { return bDiagnosticSuspend; }
1100 #endif
1101
1102 private:
1103     DWORD dwSleepOnExit;
1104
1105 public:
1106     DWORD GetSleepOnExit()
1107     { return dwSleepOnExit; }
1108 };
1109
1110
1111
1112 #ifdef _DEBUG_IMPL
1113
1114     // We actually want our asserts for illegal IL, but testers need to test that
1115     // we fail gracefully under those conditions.  Thus we have to hide them for those runs.
1116 #define BAD_FORMAT_NOTHROW_ASSERT(str)                                  \
1117     do {                                                                \
1118         if (g_pConfig->fAssertOnBadImageFormat()) {                     \
1119             _ASSERTE(str);                                              \
1120         }                                                               \
1121         else if (!(str)) {                                              \
1122             if (IsDebuggerPresent()) DebugBreak();                      \
1123         }                                                               \
1124     } while(0)
1125
1126     // STRESS_ASSERT is meant to be temperary additions to the code base that stop the
1127     // runtime quickly when running stress
1128 #define STRESS_ASSERT(cond)   do { if (!(cond) && g_pConfig->IsStressOn())  DebugBreak();    } while(0)
1129
1130 #define FILE_FORMAT_CHECK_MSG(_condition, _message)                     \
1131     do {                                                                \
1132         if (g_pConfig != NULL && g_pConfig->fAssertOnBadImageFormat())  \
1133              ASSERT_CHECK(_condition, _message, "Bad file format");     \
1134         else if (!(_condition))                                         \
1135             DebugBreak();                                               \
1136     } while (0)
1137
1138 #define FILE_FORMAT_CHECK(_condition)  FILE_FORMAT_CHECK_MSG(_condition, "")
1139
1140 #else
1141
1142 #define STRESS_ASSERT(cond)
1143 #define BAD_FORMAT_NOTHROW_ASSERT(str)
1144
1145 #define FILE_FORMAT_CHECK_MSG(_condition, _message)
1146 #define FILE_FORMAT_CHECK(_condition)
1147
1148 #endif
1149
1150 // NGENImagesAllowed is the safe way to determine if NGEN Images are allowed to be loaded. (Defined as
1151 // a macro instead of an inlined function to avoid compilation errors due to dependent
1152 // definitions not being available to this header.)
1153 #ifdef PROFILING_SUPPORTED
1154 #define NGENImagesAllowed()                                                                                     \
1155     (g_fAllowNativeImages &&                /* No one disabled use of native images */                          \
1156     !(CORProfilerDisableAllNGenImages()))   /* Profiler didn't explicitly refuse NGEN images */
1157 #else
1158 #define NGENImagesAllowed()                                                                                     \
1159     (g_fAllowNativeImages)
1160 #endif
1161
1162 #endif // EECONFIG_H