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.
5 // vars.cpp - Global Var definitions
12 #include "cordbpriv.h"
13 #include "eeprofinterfaces.h"
16 #ifndef DACCESS_COMPILE
18 // Allow use of native images?
20 bool g_fAllowNativeImages = true;
23 // Default install library
25 const WCHAR g_pwBaseLibrary[] = CoreLibName_IL_W;
26 const WCHAR g_pwBaseLibraryName[] = CoreLibName_W;
27 const char g_psBaseLibrary[] = CoreLibName_IL_A;
28 const char g_psBaseLibraryName[] = CoreLibName_A;
29 const char g_psBaseLibrarySatelliteAssemblyName[] = CoreLibSatelliteName_A;
31 Volatile<LONG> g_TrapReturningThreads;
37 // next two variables are used to enforce an ASSERT in Thread::DbgFindThread
38 // that does not allow g_TrapReturningThreads to creep up unchecked.
39 Volatile<LONG> g_trtChgStamp = 0;
40 Volatile<LONG> g_trtChgInFlight = 0;
42 const char * g_ExceptionFile; // Source of the last thrown exception (COMPLUSThrow())
43 DWORD g_ExceptionLine; // ... ditto ...
44 void * g_ExceptionEIP; // Managed EIP of the last guy to call JITThrow.
46 void * g_LastAccessViolationEIP; // The EIP of the place we last threw an AV. Used to diagnose stress issues.
48 #endif // #ifndef DACCESS_COMPILE
49 GPTR_IMPL(IdDispenser, g_pThinLockThreadIdDispenser);
51 GPTR_IMPL(IdDispenser, g_pModuleIndexDispenser);
53 IBCLogger g_IBCLogger;
55 // For [<I1, etc. up to and including [Object
56 GARY_IMPL(PTR_ArrayTypeDesc, g_pPredefinedArrayTypes, ELEMENT_TYPE_MAX);
58 GPTR_IMPL(EEConfig, g_pConfig); // configuration data (from the registry)
60 GPTR_IMPL(MethodTable, g_pObjectClass);
61 GPTR_IMPL(MethodTable, g_pRuntimeTypeClass);
62 GPTR_IMPL(MethodTable, g_pCanonMethodTableClass); // System.__Canon
63 GPTR_IMPL(MethodTable, g_pStringClass);
64 #ifdef FEATURE_UTF8STRING
65 GPTR_IMPL(MethodTable, g_pUtf8StringClass);
66 #endif // FEATURE_UTF8STRING
67 GPTR_IMPL(MethodTable, g_pArrayClass);
68 GPTR_IMPL(MethodTable, g_pSZArrayHelperClass);
69 GPTR_IMPL(MethodTable, g_pNullableClass);
70 GPTR_IMPL(MethodTable, g_pByReferenceClass);
71 GPTR_IMPL(MethodTable, g_pExceptionClass);
72 GPTR_IMPL(MethodTable, g_pThreadAbortExceptionClass);
73 GPTR_IMPL(MethodTable, g_pOutOfMemoryExceptionClass);
74 GPTR_IMPL(MethodTable, g_pStackOverflowExceptionClass);
75 GPTR_IMPL(MethodTable, g_pExecutionEngineExceptionClass);
76 GPTR_IMPL(MethodTable, g_pDelegateClass);
77 GPTR_IMPL(MethodTable, g_pMulticastDelegateClass);
78 GPTR_IMPL(MethodTable, g_pValueTypeClass);
79 GPTR_IMPL(MethodTable, g_pEnumClass);
80 GPTR_IMPL(MethodTable, g_pThreadClass);
81 GPTR_IMPL(MethodTable, g_pFreeObjectMethodTable);
82 GPTR_IMPL(MethodTable, g_pOverlappedDataClass);
84 GPTR_IMPL(MethodTable, g_TypedReferenceMT);
86 GPTR_IMPL(MethodTable, g_pByteArrayMT);
88 #ifdef FEATURE_COMINTEROP
89 GPTR_IMPL(MethodTable, g_pBaseCOMObject);
90 GPTR_IMPL(MethodTable, g_pBaseRuntimeClass);
93 #ifdef FEATURE_ICASTABLE
94 GPTR_IMPL(MethodTable, g_pICastableInterface);
95 #endif // FEATURE_ICASTABLE
98 GPTR_IMPL(MethodDesc, g_pExecuteBackoutCodeHelperMethod);
100 GPTR_IMPL(MethodDesc, g_pObjectFinalizerMD);
102 GPTR_IMPL(Thread,g_pFinalizerThread);
103 GPTR_IMPL(Thread,g_pSuspensionThread);
105 // Global SyncBlock cache
106 GPTR_IMPL(SyncTableEntry,g_pSyncTable);
109 GPTR_IMPL_INIT(StressLog, g_pStressLog, &StressLog::theLog);
112 #ifdef FEATURE_COMINTEROP
113 // Global RCW cleanup list
114 GPTR_IMPL(RCWCleanupList,g_pRCWCleanupList);
115 #endif // FEATURE_COMINTEROP
117 #ifdef FEATURE_INTEROP_DEBUGGING
118 GVAL_IMPL_INIT(DWORD, g_debuggerWordTLSIndex, TLS_OUT_OF_INDEXES);
120 GVAL_IMPL_INIT(DWORD, g_TlsIndex, TLS_OUT_OF_INDEXES);
122 #ifndef DACCESS_COMPILE
124 // <TODO> @TODO - PROMOTE. </TODO>
125 OBJECTHANDLE g_pPreallocatedOutOfMemoryException;
126 OBJECTHANDLE g_pPreallocatedStackOverflowException;
127 OBJECTHANDLE g_pPreallocatedExecutionEngineException;
128 OBJECTHANDLE g_pPreallocatedRudeThreadAbortException;
129 OBJECTHANDLE g_pPreallocatedThreadAbortException;
130 OBJECTHANDLE g_pPreallocatedSentinelObject;
131 OBJECTHANDLE g_pPreallocatedBaseException;
135 // Global System Info
137 SYSTEM_INFO g_SystemInfo;
139 // Configurable constants used across our spin locks
140 // Initialization here is necessary so that we have meaningful values before the runtime is started
141 // These initial values were selected to match the defaults, but anything reasonable is close enough
142 SpinConstants g_SpinConstants = {
143 50, // dwInitialDuration
144 40000, // dwMaximumDuration - ideally (20000 * max(2, numProc))
145 3, // dwBackoffFactor
147 0 // dwMonitorSpinCount
150 // support for Event Tracing for Windows (ETW)
151 ETW::CEtwTracer * g_pEtwTracer = NULL;
153 #endif // #ifndef DACCESS_COMPILE
156 // Support for the COM+ Debugger.
158 GPTR_IMPL(DebugInterface, g_pDebugInterface);
159 // A managed debugger may set this flag to high from out of process.
160 GVAL_IMPL_INIT(DWORD, g_CORDebuggerControlFlags, DBCF_NORMAL_OPERATION);
162 #ifdef DEBUGGING_SUPPORTED
163 GPTR_IMPL(EEDbgInterfaceImpl, g_pEEDbgInterfaceImpl);
164 #endif // DEBUGGING_SUPPORTED
166 #if defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPPORTED)
168 HINSTANCE g_pDebuggerDll = NULL;
170 GVAL_IMPL(ProfControlBlock, g_profControlBlock);
171 #endif // defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPPORTED)
173 #ifndef DACCESS_COMPILE
175 // Global default for Concurrent GC. The default is value is 1
176 int g_IGCconcurrent = 1;
178 int g_IGCHoardVM = 0;
182 int g_IGCTrimCommit = 0;
186 BOOL g_fEnableETW = FALSE;
189 // Global state variable indicating if the EE is in its init phase.
191 bool g_fEEInit = false;
194 // Global state variables indicating which stage of shutdown we are in
197 #endif // #ifndef DACCESS_COMPILE
199 // See comments at code:EEShutDown for details on how and why this gets set. Use
200 // code:IsAtProcessExit to read this.
201 GVAL_IMPL(bool, g_fProcessDetach);
203 GVAL_IMPL_INIT(DWORD, g_fEEShutDown, 0);
206 GVAL_IMPL(SIZE_T, g_runtimeLoadedBaseAddress);
207 GVAL_IMPL(SIZE_T, g_runtimeVirtualSize);
208 #endif // !FEATURE_PAL
210 #ifndef DACCESS_COMPILE
212 Volatile<LONG> g_fForbidEnterEE = false;
213 bool g_fManagedAttach = false;
214 bool g_fNoExceptions = false;
215 #ifdef FEATURE_COMINTEROP
216 bool g_fShutDownCOM = false;
217 #endif //FEATURE_COMINTEROP
219 DWORD g_FinalizerWaiterStatus = 0;
222 // Do we own the lifetime of the process, ie. is it an EXE?
224 bool g_fWeControlLifetime = false;
227 // The following should only be used for assertions. (Famous last words).
228 bool dbg_fDrasticShutdown = false;
230 bool g_fInControlC = false;
234 // IJW needs the shim HINSTANCE
236 HINSTANCE g_hInstShim = NULL;
238 #endif // #ifndef DACCESS_COMPILE
240 #ifdef DACCESS_COMPILE
242 void OBJECTHANDLE_EnumMemoryRegions(OBJECTHANDLE handle)
245 PTR_TADDR ref = PTR_TADDR(handle);
250 PTR_Object obj = PTR_Object(*ref);
253 obj->EnumMemoryRegions();
258 void OBJECTREF_EnumMemoryRegions(OBJECTREF ref)
262 ref->EnumMemoryRegions();
266 #endif // #ifdef DACCESS_COMPILE
268 #ifndef DACCESS_COMPILE
270 // We need the following to be the compiler's notion of volatile.
272 extern "C" RAW_KEYWORD(volatile) const GSCookie s_gsCookie = 0;
275 __GlobalVal< GSCookie > s_gsCookie(&g_dacGlobals.dac__s_gsCookie);
276 #endif //!DACCESS_COMPILE
278 //==============================================================================