[Tizen] Unify dnetmemoryenumlib terms to match the codebase (#291)
[platform/upstream/coreclr.git] / src / vm / crossgencompile.cpp
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 // File: crosscomp.cpp
6 //
7
8 // ===========================================================================
9 // This file contains stubbed out implementations for cross-platform NGen.
10 //
11 // The stubbed out implementations are concentrated in this file to reduce number
12 // of ifdefs that has to be sprinkled through the code.
13 // ===========================================================================
14
15 #include "common.h"
16
17 #include "comdelegate.h"
18 #include "compile.h"
19 #include "invokeutil.h"
20 #include "comcallablewrapper.h"
21
22 //---------------------------------------------------------------------------------------
23 //
24 // Pull in some implementation files from other places in the tree
25 //
26
27 #include "../../dlls/mscoree/mscoree.cpp"
28
29 //---------------------------------------------------------------------------------------
30 //
31 // Helper function for features unsupported under crossgen
32 //
33
34 #undef ExitProcess
35
36 void CrossGenNotSupported(const char * message)
37 {
38     _ASSERTE(!"CrossGenNotSupported");
39     fprintf(stderr, "Fatal error: %s\n", message);
40     ExitProcess(CORSECATTR_E_BAD_ACTION);
41 }
42
43 //---------------------------------------------------------------------------------------
44 //
45 // There is always only one thread and one appdomain in crossgen.
46 //
47
48 extern CompilationDomain * theDomain;
49
50 AppDomain * GetAppDomain()
51 {
52     return theDomain;
53 }
54
55 Thread theThread;
56
57 Thread * GetThread()
58 {
59     return (Thread*)&theThread;
60 }
61
62 Thread * GetThreadNULLOk()
63 {
64     return GetThread();
65 }
66
67 #ifdef _DEBUG
68 BOOL Debug_IsLockedViaThreadSuspension()
69 {
70     LIMITED_METHOD_CONTRACT;
71     return FALSE;
72 }
73 #endif // _DEBUG
74
75 //---------------------------------------------------------------------------------------
76 //
77 // All locks are nops because of there is always only one thread.
78 //
79
80 void CrstBase::InitWorker(INDEBUG_COMMA(CrstType crstType) CrstFlags flags)
81 {
82     m_dwFlags = flags;
83 }
84
85 void CrstBase::Destroy()
86 {
87 }
88
89 void CrstBase::Enter(INDEBUG(enum CrstBase::NoLevelCheckFlag))
90 {
91 }
92
93 void CrstBase::Leave()
94 {
95 }
96
97 BOOL __SwitchToThread(DWORD, DWORD)
98 {
99     return TRUE;
100 }
101
102 //---------------------------------------------------------------------------------------
103 //
104 // Globals and misc other
105 //
106
107 GPTR_IMPL(IGCHeap,g_pGCHeap);
108
109 BOOL g_fEEOtherStartup=FALSE;
110 BOOL g_fEEComActivatedStartup=FALSE;
111
112 GVAL_IMPL_INIT(DWORD, g_fHostConfig, 0);
113
114 GVAL_IMPL_INIT(GCHeapType, g_heap_type, GC_HEAP_WKS);
115
116 HRESULT GetExceptionHResult(OBJECTREF throwable)
117 {
118     return E_FAIL;
119 }
120
121 //---------------------------------------------------------------------------------------
122 //
123 // Dynamically unreachable implementation of profiler callbacks. Note that we can't just 
124 // disable PROFILING_SUPPORTED for crossgen because of it affects data layout and FCall tables.
125 //
126
127 UINT_PTR EEToProfInterfaceImpl::EEFunctionIDMapper(FunctionID funcId, BOOL * pbHookFunction)
128 {
129     UNREACHABLE();
130 }
131
132 HRESULT EEToProfInterfaceImpl::JITInlining(
133     /* [in] */  FunctionID    callerId,
134     /* [in] */  FunctionID    calleeId,
135     /* [out] */ BOOL *        pfShouldInline)
136 {
137     UNREACHABLE();
138 }
139
140 HRESULT EEToProfInterfaceImpl::ModuleLoadStarted(ModuleID moduleId)
141 {
142     UNREACHABLE();
143 }
144
145 HRESULT EEToProfInterfaceImpl::ModuleLoadFinished(
146     ModuleID    moduleId,
147     HRESULT        hrStatus)
148 {
149     UNREACHABLE();
150 }
151
152 HRESULT EEToProfInterfaceImpl::ModuleUnloadStarted(
153     ModuleID    moduleId)
154 {
155     UNREACHABLE();
156 }
157
158 HRESULT EEToProfInterfaceImpl::ModuleUnloadFinished(
159     ModuleID    moduleId,
160     HRESULT        hrStatus)
161 {
162     UNREACHABLE();
163 }
164
165 HRESULT EEToProfInterfaceImpl::ModuleAttachedToAssembly(
166     ModuleID    moduleId,
167     AssemblyID  AssemblyId)
168 {
169     UNREACHABLE();
170 }
171
172 HRESULT EEToProfInterfaceImpl::ClassLoadStarted(
173     ClassID     classId)
174 {
175     UNREACHABLE();
176 }
177
178 HRESULT EEToProfInterfaceImpl::ClassLoadFinished(
179     ClassID     classId,
180     HRESULT     hrStatus)
181 {
182     UNREACHABLE();
183 }
184
185 HRESULT EEToProfInterfaceImpl::AppDomainCreationFinished(
186     AppDomainID appDomainId,
187     HRESULT     hrStatus)
188 {
189     UNREACHABLE();
190 }
191
192 HRESULT EEToProfInterfaceImpl::AppDomainCreationStarted(
193     AppDomainID appDomainId)
194 {
195     UNREACHABLE();
196 }
197
198 HRESULT EEToProfInterfaceImpl::AppDomainShutdownFinished(
199     AppDomainID appDomainId,
200     HRESULT     hrStatus)
201 {
202     UNREACHABLE();
203 }
204
205 HRESULT EEToProfInterfaceImpl::AppDomainShutdownStarted(
206     AppDomainID appDomainId)
207 {
208     UNREACHABLE();
209 }
210
211 HRESULT EEToProfInterfaceImpl::AssemblyLoadStarted(
212     AssemblyID  assemblyId)
213 {
214     UNREACHABLE();
215 }
216
217 HRESULT EEToProfInterfaceImpl::AssemblyLoadFinished(
218     AssemblyID  assemblyId,
219     HRESULT     hrStatus)
220 {
221     UNREACHABLE();
222 }
223
224 ClassID TypeHandleToClassID(TypeHandle th)
225 {
226     UNREACHABLE();
227 }
228
229 //---------------------------------------------------------------------------------------
230 //
231 // Stubed-out implementations of functions that can do anything useful only when we are actually running managed code
232 //
233
234 FuncPtrStubs::FuncPtrStubs()
235     : m_hashTableCrst(CrstFuncPtrStubs, CRST_UNSAFE_ANYMODE)
236 {
237 }
238
239 PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
240 {
241     return 0x321;
242 }
243
244 PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
245 {
246     return 0x321;
247 }
248
249 #ifdef _TARGET_AMD64_
250 INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMethod,
251     LoaderAllocator *pLoaderAllocator /* = NULL */, bool throwOnOutOfMemoryWithinRange /*= true*/)
252 {
253     // crossgen does not have jump stubs
254     return 0;
255 }
256
257 INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddr, bool emitJump)
258 {
259     // crossgen does not have jump stubs
260     return 0;
261 }
262 #endif
263
264
265 CORINFO_GENERIC_HANDLE JIT_GenericHandleWorker(MethodDesc *  pMD, MethodTable * pMT, LPVOID signature, DWORD dictionaryIndexAndSlot, Module* pModule)
266 {
267     UNREACHABLE();
268 }
269
270 void CrawlFrame::GetExactGenericInstantiations(Instantiation *pClassInst, Instantiation *pMethodInst)
271 {
272     UNREACHABLE();
273 }
274
275 BOOL Object::SupportsInterface(OBJECTREF pObj, MethodTable* pInterfaceMT)
276 {
277     UNREACHABLE();
278 }
279
280 GCFrame::GCFrame(OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior)
281 {
282 }
283
284 void GCFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
285 {
286     UNREACHABLE();
287 }
288
289 void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
290 {
291     UNREACHABLE();
292 }
293
294 VOID GCFrame::Pop()
295 {
296 }
297
298 void Frame::Push()
299 {
300 }
301
302 void Frame::Pop()
303 {
304 }
305
306 PCODE COMDelegate::GetWrapperInvoke(MethodDesc* pMD)
307 {
308     return (PCODE)(0x12345);
309 }
310
311 Assembly * SystemDomain::GetCallersAssembly(StackCrawlMark * stackMark, AppDomain ** ppAppDomain)
312 {
313     return NULL;
314 }
315
316 void EnableStressHeapHelper()
317
318     UNREACHABLE();
319 }
320
321 void ReflectionModule::CaptureModuleMetaDataToMemory()
322 {
323 }
324
325 //---------------------------------------------------------------------------------------
326 //
327 // Empty implementations of shutdown-related functions. We don't do any cleanup for shutdown during crossgen.
328 //
329
330 Assembly::~Assembly()
331 {
332 }
333
334 void Assembly::StartUnload()
335 {
336 }
337
338 void Module::StartUnload()
339 {
340 }
341
342 void DynamicMethodTable::Destroy()
343 {
344 }
345
346 void SyncClean::AddEEHashTable(EEHashEntry** entry)
347
348 }
349
350 void SyncClean::AddHashMap(Bucket *bucket)
351
352 }
353
354 #ifdef FEATURE_COMINTEROP
355 LONG ComCallWrapperTemplate::Release()
356 {
357     UNREACHABLE();
358 }
359 #endif
360
361 extern "C" UINT_PTR STDCALL GetCurrentIP()
362
363     return 0;
364 }
365
366 // This method must return a value to avoid getting non-actionable dumps on x86.
367 // If this method were a DECLSPEC_NORETURN then dumps would not provide the necessary
368 // context at the point of the failure
369 int NOINLINE EEPolicy::HandleFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMessage, PEXCEPTION_POINTERS pExceptionInfo, LPCWSTR errorSource, LPCWSTR argExceptionString)
370
371     fprintf(stderr, "Fatal error: %08x\n", exitCode);
372     ExitProcess(exitCode);
373     return -1;
374 }
375
376 //---------------------------------------------------------------------------------------
377
378 Assembly * AppDomain::RaiseAssemblyResolveEvent(AssemblySpec * pSpec)
379 {
380     return NULL;
381 }
382
383 Assembly * AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName)
384 {
385     return NULL;
386 }
387
388 DomainAssembly * AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef)
389 {
390     return NULL;
391 }
392
393 void AppDomain::RaiseLoadingAssemblyEvent(DomainAssembly *pAssembly)
394 {
395 }