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 void UpdateGCSettingFromHost()
120 HRESULT GetExceptionHResult(OBJECTREF throwable)
125 //---------------------------------------------------------------------------------------
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.
131 UINT_PTR EEToProfInterfaceImpl::EEFunctionIDMapper(FunctionID funcId, BOOL * pbHookFunction)
136 HRESULT EEToProfInterfaceImpl::JITInlining(
137 /* [in] */ FunctionID callerId,
138 /* [in] */ FunctionID calleeId,
139 /* [out] */ BOOL * pfShouldInline)
144 HRESULT EEToProfInterfaceImpl::ModuleLoadStarted(ModuleID moduleId)
149 HRESULT EEToProfInterfaceImpl::ModuleLoadFinished(
156 HRESULT EEToProfInterfaceImpl::ModuleUnloadStarted(
162 HRESULT EEToProfInterfaceImpl::ModuleUnloadFinished(
169 HRESULT EEToProfInterfaceImpl::ModuleAttachedToAssembly(
171 AssemblyID AssemblyId)
176 HRESULT EEToProfInterfaceImpl::ClassLoadStarted(
182 HRESULT EEToProfInterfaceImpl::ClassLoadFinished(
189 HRESULT EEToProfInterfaceImpl::AppDomainCreationFinished(
190 AppDomainID appDomainId,
196 HRESULT EEToProfInterfaceImpl::AppDomainCreationStarted(
197 AppDomainID appDomainId)
202 HRESULT EEToProfInterfaceImpl::AppDomainShutdownFinished(
203 AppDomainID appDomainId,
209 HRESULT EEToProfInterfaceImpl::AppDomainShutdownStarted(
210 AppDomainID appDomainId)
215 HRESULT EEToProfInterfaceImpl::AssemblyLoadStarted(
216 AssemblyID assemblyId)
221 HRESULT EEToProfInterfaceImpl::AssemblyLoadFinished(
222 AssemblyID assemblyId,
228 ClassID TypeHandleToClassID(TypeHandle th)
233 //---------------------------------------------------------------------------------------
235 // Stubed-out implementations of functions that can do anything useful only when we are actually running managed code
238 MethodTable *Object::GetTrueMethodTable()
243 FuncPtrStubs::FuncPtrStubs()
244 : m_hashTableCrst(CrstFuncPtrStubs, CRST_UNSAFE_ANYMODE)
248 PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
253 PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags)
259 BOOL Runtime_Test_For_SSE2()
265 #ifdef _TARGET_AMD64_
266 INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMethod,
267 LoaderAllocator *pLoaderAllocator /* = NULL */, bool throwOnOutOfMemoryWithinRange /*= true*/)
269 // crossgen does not have jump stubs
273 INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddr)
275 // crossgen does not have jump stubs
281 CORINFO_GENERIC_HANDLE JIT_GenericHandleWorker(MethodDesc * pMD, MethodTable * pMT, LPVOID signature, DWORD dictionaryIndexAndSlot, Module* pModule)
286 void CrawlFrame::GetExactGenericInstantiations(Instantiation *pClassInst, Instantiation *pMethodInst)
291 OBJECTREF AppDomain::GetExposedObject()
296 BOOL Object::SupportsInterface(OBJECTREF pObj, MethodTable* pInterfaceMT)
301 GCFrame::GCFrame(OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior)
305 void GCFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
310 void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc)
327 PCODE COMDelegate::GetSecureInvoke(MethodDesc* pMD)
329 return (PCODE)(0x12345);
332 Assembly * SystemDomain::GetCallersAssembly(StackCrawlMark * stackMark, AppDomain ** ppAppDomain)
337 void EnableStressHeapHelper()
342 void ReflectionModule::CaptureModuleMetaDataToMemory()
346 //---------------------------------------------------------------------------------------
348 // Empty implementations of shutdown-related functions. We don't do any cleanup for shutdown during crossgen.
351 Assembly::~Assembly()
355 void Assembly::StartUnload()
359 void Module::StartUnload()
363 void DynamicMethodTable::Destroy()
367 void SyncClean::AddEEHashTable(EEHashEntry** entry)
371 void SyncClean::AddHashMap(Bucket *bucket)
375 #ifdef FEATURE_COMINTEROP
376 LONG ComCallWrapperTemplate::Release()
382 extern "C" UINT_PTR STDCALL GetCurrentIP()
387 void EEPolicy::HandleFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMessage, PEXCEPTION_POINTERS pExceptionInfo, LPCWSTR errorSource, const WCHAR * argExceptionString)
389 fprintf(stderr, "Fatal error: %08x\n", exitCode);
390 ExitProcess(exitCode);
393 //---------------------------------------------------------------------------------------
395 Assembly * AppDomain::RaiseAssemblyResolveEvent(AssemblySpec * pSpec, BOOL fIntrospection, BOOL fPreBind)
400 Assembly * AppDomain::RaiseResourceResolveEvent(DomainAssembly* pAssembly, LPCSTR szName)
405 DomainAssembly * AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef)
410 void AppDomain::RaiseLoadingAssemblyEvent(DomainAssembly *pAssembly)
414 BOOL AppDomain::BindingByManifestFile()