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 // ===========================================================================
8 // ===========================================================================
9 // This file contains stubbed out implementations for cross-platform NGen.
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 // ===========================================================================
17 #include "comdelegate.h"
19 #include "invokeutil.h"
20 #include "comcallablewrapper.h"
22 //---------------------------------------------------------------------------------------
24 // Pull in some implementation files from other places in the tree
27 #include "../../dlls/mscoree/mscoree.cpp"
29 //---------------------------------------------------------------------------------------
31 // Helper function for features unsupported under crossgen
36 void CrossGenNotSupported(const char * message)
38 _ASSERTE(!"CrossGenNotSupported");
39 fprintf(stderr, "Fatal error: %s\n", message);
40 ExitProcess(CORSECATTR_E_BAD_ACTION);
43 //---------------------------------------------------------------------------------------
45 // There is always only one thread and one appdomain in crossgen.
48 extern CompilationDomain * theDomain;
50 AppDomain * GetAppDomain()
59 return (Thread*)&theThread;
62 Thread * GetThreadNULLOk()
68 BOOL Debug_IsLockedViaThreadSuspension()
70 LIMITED_METHOD_CONTRACT;
75 //---------------------------------------------------------------------------------------
77 // All locks are nops because of there is always only one thread.
80 void CrstBase::InitWorker(INDEBUG_COMMA(CrstType crstType) CrstFlags flags)
85 void CrstBase::Destroy()
89 void CrstBase::Enter(INDEBUG(enum CrstBase::NoLevelCheckFlag))
93 void CrstBase::Leave()
97 BOOL __SwitchToThread(DWORD, DWORD)
102 //---------------------------------------------------------------------------------------
104 // Globals and misc other
107 GPTR_IMPL(IGCHeap,g_pGCHeap);
109 BOOL g_fEEOtherStartup=FALSE;
110 BOOL g_fEEComActivatedStartup=FALSE;
112 GVAL_IMPL_INIT(DWORD, g_fHostConfig, 0);
114 GVAL_IMPL_INIT(GCHeapType, g_heap_type, GC_HEAP_WKS);
116 HRESULT GetExceptionHResult(OBJECTREF throwable)
121 //---------------------------------------------------------------------------------------
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.
127 UINT_PTR EEToProfInterfaceImpl::EEFunctionIDMapper(FunctionID funcId, BOOL * pbHookFunction)
132 HRESULT EEToProfInterfaceImpl::JITInlining(
133 /* [in] */ FunctionID callerId,
134 /* [in] */ FunctionID calleeId,
135 /* [out] */ BOOL * pfShouldInline)
140 HRESULT EEToProfInterfaceImpl::ModuleLoadStarted(ModuleID moduleId)
145 HRESULT EEToProfInterfaceImpl::ModuleLoadFinished(
152 HRESULT EEToProfInterfaceImpl::ModuleUnloadStarted(
158 HRESULT EEToProfInterfaceImpl::ModuleUnloadFinished(
165 HRESULT EEToProfInterfaceImpl::ModuleAttachedToAssembly(
167 AssemblyID AssemblyId)
172 HRESULT EEToProfInterfaceImpl::ClassLoadStarted(
178 HRESULT EEToProfInterfaceImpl::ClassLoadFinished(
185 HRESULT EEToProfInterfaceImpl::AppDomainCreationFinished(
186 AppDomainID appDomainId,
192 HRESULT EEToProfInterfaceImpl::AppDomainCreationStarted(
193 AppDomainID appDomainId)
198 HRESULT EEToProfInterfaceImpl::AppDomainShutdownFinished(
199 AppDomainID appDomainId,
205 HRESULT EEToProfInterfaceImpl::AppDomainShutdownStarted(
206 AppDomainID appDomainId)
211 HRESULT EEToProfInterfaceImpl::AssemblyLoadStarted(
212 AssemblyID assemblyId)
217 HRESULT EEToProfInterfaceImpl::AssemblyLoadFinished(
218 AssemblyID assemblyId,
224 ClassID TypeHandleToClassID(TypeHandle th)
229 //---------------------------------------------------------------------------------------
231 // Stubed-out implementations of functions that can do anything useful only when we are actually running managed code
234 FuncPtrStubs::FuncPtrStubs()
235 : m_hashTableCrst(CrstFuncPtrStubs, CRST_UNSAFE_ANYMODE)
239 PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
244 PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
249 #ifdef _TARGET_AMD64_
250 INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMethod,
251 LoaderAllocator *pLoaderAllocator /* = NULL */, bool throwOnOutOfMemoryWithinRange /*= true*/)
253 // crossgen does not have jump stubs
257 INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddr, bool emitJump)
259 // crossgen does not have jump stubs
265 CORINFO_GENERIC_HANDLE JIT_GenericHandleWorker(MethodDesc * pMD, MethodTable * pMT, LPVOID signature, DWORD dictionaryIndexAndSlot, Module* pModule)
270 void CrawlFrame::GetExactGenericInstantiations(Instantiation *pClassInst, Instantiation *pMethodInst)
275 BOOL Object::SupportsInterface(OBJECTREF pObj, MethodTable* pInterfaceMT)
280 GCFrame::GCFrame(OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior)
284 void GCFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
289 void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
306 PCODE COMDelegate::GetWrapperInvoke(MethodDesc* pMD)
308 return (PCODE)(0x12345);
311 Assembly * SystemDomain::GetCallersAssembly(StackCrawlMark * stackMark, AppDomain ** ppAppDomain)
316 void EnableStressHeapHelper()
321 void ReflectionModule::CaptureModuleMetaDataToMemory()
325 //---------------------------------------------------------------------------------------
327 // Empty implementations of shutdown-related functions. We don't do any cleanup for shutdown during crossgen.
330 Assembly::~Assembly()
334 void Assembly::StartUnload()
338 void Module::StartUnload()
342 void DynamicMethodTable::Destroy()
346 void SyncClean::AddEEHashTable(EEHashEntry** entry)
350 void SyncClean::AddHashMap(Bucket *bucket)
354 #ifdef FEATURE_COMINTEROP
355 LONG ComCallWrapperTemplate::Release()
361 extern "C" UINT_PTR STDCALL GetCurrentIP()
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)
371 fprintf(stderr, "Fatal error: %08x\n", exitCode);
372 ExitProcess(exitCode);
376 //---------------------------------------------------------------------------------------
378 Assembly * AppDomain::RaiseAssemblyResolveEvent(AssemblySpec * pSpec)
383 Assembly * AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName)
388 DomainAssembly * AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef)
393 void AppDomain::RaiseLoadingAssemblyEvent(DomainAssembly *pAssembly)