Merge pull request #16822 from sdmaclea/PR-ARM64-BASE-INTRINSICS
[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 void UpdateGCSettingFromHost()
117 {
118 }
119
120 HRESULT GetExceptionHResult(OBJECTREF throwable)
121 {
122     return E_FAIL;
123 }
124
125 //---------------------------------------------------------------------------------------
126 //
127 // Dynamically unreachable implementation of profiler callbacks. Note that we can't just 
128 // disable PROFILING_SUPPORTED for crossgen because of it affects data layout and FCall tables.
129 //
130
131 UINT_PTR EEToProfInterfaceImpl::EEFunctionIDMapper(FunctionID funcId, BOOL * pbHookFunction)
132 {
133     UNREACHABLE();
134 }
135
136 HRESULT EEToProfInterfaceImpl::JITInlining(
137     /* [in] */  FunctionID    callerId,
138     /* [in] */  FunctionID    calleeId,
139     /* [out] */ BOOL *        pfShouldInline)
140 {
141     UNREACHABLE();
142 }
143
144 HRESULT EEToProfInterfaceImpl::ModuleLoadStarted(ModuleID moduleId)
145 {
146     UNREACHABLE();
147 }
148
149 HRESULT EEToProfInterfaceImpl::ModuleLoadFinished(
150     ModuleID    moduleId,
151     HRESULT        hrStatus)
152 {
153     UNREACHABLE();
154 }
155
156 HRESULT EEToProfInterfaceImpl::ModuleUnloadStarted(
157     ModuleID    moduleId)
158 {
159     UNREACHABLE();
160 }
161
162 HRESULT EEToProfInterfaceImpl::ModuleUnloadFinished(
163     ModuleID    moduleId,
164     HRESULT        hrStatus)
165 {
166     UNREACHABLE();
167 }
168
169 HRESULT EEToProfInterfaceImpl::ModuleAttachedToAssembly(
170     ModuleID    moduleId,
171     AssemblyID  AssemblyId)
172 {
173     UNREACHABLE();
174 }
175
176 HRESULT EEToProfInterfaceImpl::ClassLoadStarted(
177     ClassID     classId)
178 {
179     UNREACHABLE();
180 }
181
182 HRESULT EEToProfInterfaceImpl::ClassLoadFinished(
183     ClassID     classId,
184     HRESULT     hrStatus)
185 {
186     UNREACHABLE();
187 }
188
189 HRESULT EEToProfInterfaceImpl::AppDomainCreationFinished(
190     AppDomainID appDomainId,
191     HRESULT     hrStatus)
192 {
193     UNREACHABLE();
194 }
195
196 HRESULT EEToProfInterfaceImpl::AppDomainCreationStarted(
197     AppDomainID appDomainId)
198 {
199     UNREACHABLE();
200 }
201
202 HRESULT EEToProfInterfaceImpl::AppDomainShutdownFinished(
203     AppDomainID appDomainId,
204     HRESULT     hrStatus)
205 {
206     UNREACHABLE();
207 }
208
209 HRESULT EEToProfInterfaceImpl::AppDomainShutdownStarted(
210     AppDomainID appDomainId)
211 {
212     UNREACHABLE();
213 }
214
215 HRESULT EEToProfInterfaceImpl::AssemblyLoadStarted(
216     AssemblyID  assemblyId)
217 {
218     UNREACHABLE();
219 }
220
221 HRESULT EEToProfInterfaceImpl::AssemblyLoadFinished(
222     AssemblyID  assemblyId,
223     HRESULT     hrStatus)
224 {
225     UNREACHABLE();
226 }
227
228 ClassID TypeHandleToClassID(TypeHandle th)
229 {
230     UNREACHABLE();
231 }
232
233 //---------------------------------------------------------------------------------------
234 //
235 // Stubed-out implementations of functions that can do anything useful only when we are actually running managed code
236 //
237
238 MethodTable *Object::GetTrueMethodTable()
239 {
240     UNREACHABLE();
241 }
242
243 FuncPtrStubs::FuncPtrStubs()
244     : m_hashTableCrst(CrstFuncPtrStubs, CRST_UNSAFE_ANYMODE)
245 {
246 }
247
248 PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
249 {
250     return 0x321;
251 }
252
253 PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
254 {
255     return 0x321;
256 }
257
258 #ifdef _TARGET_X86_
259 BOOL Runtime_Test_For_SSE2()
260 {
261     return TRUE;
262 }
263 #endif
264
265 #ifdef _TARGET_AMD64_
266 INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMethod,
267     LoaderAllocator *pLoaderAllocator /* = NULL */, bool throwOnOutOfMemoryWithinRange /*= true*/)
268 {
269     // crossgen does not have jump stubs
270     return 0;
271 }
272
273 INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddr)
274 {
275     // crossgen does not have jump stubs
276     return 0;
277 }
278 #endif
279
280
281 CORINFO_GENERIC_HANDLE JIT_GenericHandleWorker(MethodDesc *  pMD, MethodTable * pMT, LPVOID signature, DWORD dictionaryIndexAndSlot, Module* pModule)
282 {
283     UNREACHABLE();
284 }
285
286 void CrawlFrame::GetExactGenericInstantiations(Instantiation *pClassInst, Instantiation *pMethodInst)
287 {
288     UNREACHABLE();
289 }
290
291 OBJECTREF AppDomain::GetExposedObject()
292 {
293     UNREACHABLE();
294 }
295
296 BOOL Object::SupportsInterface(OBJECTREF pObj, MethodTable* pInterfaceMT)
297 {
298     UNREACHABLE();
299 }
300
301 GCFrame::GCFrame(OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior)
302 {
303 }
304
305 void GCFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
306 {
307     UNREACHABLE();
308 }
309
310 void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
311 {
312     UNREACHABLE();
313 }
314
315 VOID GCFrame::Pop()
316 {
317 }
318
319 void Frame::Push()
320 {
321 }
322
323 void Frame::Pop()
324 {
325 }
326
327 PCODE COMDelegate::GetSecureInvoke(MethodDesc* pMD)
328 {
329     return (PCODE)(0x12345);
330 }
331
332 Assembly * SystemDomain::GetCallersAssembly(StackCrawlMark * stackMark, AppDomain ** ppAppDomain)
333 {
334     return NULL;
335 }
336
337 void EnableStressHeapHelper()
338
339     UNREACHABLE();
340 }
341
342 void ReflectionModule::CaptureModuleMetaDataToMemory()
343 {
344 }
345
346 //---------------------------------------------------------------------------------------
347 //
348 // Empty implementations of shutdown-related functions. We don't do any cleanup for shutdown during crossgen.
349 //
350
351 Assembly::~Assembly()
352 {
353 }
354
355 void Assembly::StartUnload()
356 {
357 }
358
359 void Module::StartUnload()
360 {
361 }
362
363 void DynamicMethodTable::Destroy()
364 {
365 }
366
367 void SyncClean::AddEEHashTable(EEHashEntry** entry)
368
369 }
370
371 void SyncClean::AddHashMap(Bucket *bucket)
372
373 }
374
375 #ifdef FEATURE_COMINTEROP
376 LONG ComCallWrapperTemplate::Release()
377 {
378     UNREACHABLE();
379 }
380 #endif
381
382 extern "C" UINT_PTR STDCALL GetCurrentIP()
383
384     return 0;
385 }
386
387 void EEPolicy::HandleFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMessage, PEXCEPTION_POINTERS pExceptionInfo, LPCWSTR errorSource, const WCHAR * argExceptionString)
388
389     fprintf(stderr, "Fatal error: %08x\n", exitCode);
390     ExitProcess(exitCode);
391 }
392
393 //---------------------------------------------------------------------------------------
394
395 Assembly * AppDomain::RaiseAssemblyResolveEvent(AssemblySpec * pSpec, BOOL fIntrospection, BOOL fPreBind)
396 {
397     return NULL;
398 }
399
400 Assembly * AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName)
401 {
402     return NULL;
403 }
404
405 DomainAssembly * AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef)
406 {
407     return NULL;
408 }
409
410 void AppDomain::RaiseLoadingAssemblyEvent(DomainAssembly *pAssembly)
411 {
412 }
413
414 BOOL AppDomain::BindingByManifestFile()
415 {
416     return FALSE;
417 }