| 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 | FuncPtrStubs::FuncPtrStubs() | 
|---|
| 239 | : m_hashTableCrst(CrstFuncPtrStubs, CRST_UNSAFE_ANYMODE) | 
|---|
| 240 | { | 
|---|
| 241 | } | 
|---|
| 242 |  | 
|---|
| 243 | PCODE MethodDesc::GetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags) | 
|---|
| 244 | { | 
|---|
| 245 | return 0x321; | 
|---|
| 246 | } | 
|---|
| 247 |  | 
|---|
| 248 | PCODE MethodDesc::TryGetMultiCallableAddrOfCode(CORINFO_ACCESS_FLAGS accessFlags) | 
|---|
| 249 | { | 
|---|
| 250 | return 0x321; | 
|---|
| 251 | } | 
|---|
| 252 |  | 
|---|
| 253 | #ifdef _TARGET_AMD64_ | 
|---|
| 254 | INT32 rel32UsingJumpStub(INT32 UNALIGNED * pRel32, PCODE target, MethodDesc *pMethod, | 
|---|
| 255 | LoaderAllocator *pLoaderAllocator /* = NULL */, bool throwOnOutOfMemoryWithinRange /*= true*/) | 
|---|
| 256 | { | 
|---|
| 257 | // crossgen does not have jump stubs | 
|---|
| 258 | return 0; | 
|---|
| 259 | } | 
|---|
| 260 |  | 
|---|
| 261 | INT32 rel32UsingPreallocatedJumpStub(INT32 UNALIGNED * pRel32, PCODE target, PCODE jumpStubAddr, bool emitJump) | 
|---|
| 262 | { | 
|---|
| 263 | // crossgen does not have jump stubs | 
|---|
| 264 | return 0; | 
|---|
| 265 | } | 
|---|
| 266 | #endif | 
|---|
| 267 |  | 
|---|
| 268 |  | 
|---|
| 269 | CORINFO_GENERIC_HANDLE JIT_GenericHandleWorker(MethodDesc *  pMD, MethodTable * pMT, LPVOID signature, DWORD dictionaryIndexAndSlot, Module* pModule) | 
|---|
| 270 | { | 
|---|
| 271 | UNREACHABLE(); | 
|---|
| 272 | } | 
|---|
| 273 |  | 
|---|
| 274 | void CrawlFrame::GetExactGenericInstantiations(Instantiation *pClassInst, Instantiation *pMethodInst) | 
|---|
| 275 | { | 
|---|
| 276 | UNREACHABLE(); | 
|---|
| 277 | } | 
|---|
| 278 |  | 
|---|
| 279 | BOOL Object::SupportsInterface(OBJECTREF pObj, MethodTable* pInterfaceMT) | 
|---|
| 280 | { | 
|---|
| 281 | UNREACHABLE(); | 
|---|
| 282 | } | 
|---|
| 283 |  | 
|---|
| 284 | GCFrame::GCFrame(OBJECTREF *pObjRefs, UINT numObjRefs, BOOL maybeInterior) | 
|---|
| 285 | { | 
|---|
| 286 | } | 
|---|
| 287 |  | 
|---|
| 288 | void GCFrame::GcScanRoots(promote_func *fn, ScanContext* sc) | 
|---|
| 289 | { | 
|---|
| 290 | UNREACHABLE(); | 
|---|
| 291 | } | 
|---|
| 292 |  | 
|---|
| 293 | void HijackFrame::GcScanRoots(promote_func *fn, ScanContext* sc) | 
|---|
| 294 | { | 
|---|
| 295 | UNREACHABLE(); | 
|---|
| 296 | } | 
|---|
| 297 |  | 
|---|
| 298 | VOID GCFrame::Pop() | 
|---|
| 299 | { | 
|---|
| 300 | } | 
|---|
| 301 |  | 
|---|
| 302 | void Frame::Push() | 
|---|
| 303 | { | 
|---|
| 304 | } | 
|---|
| 305 |  | 
|---|
| 306 | void Frame::Pop() | 
|---|
| 307 | { | 
|---|
| 308 | } | 
|---|
| 309 |  | 
|---|
| 310 | PCODE COMDelegate::GetSecureInvoke(MethodDesc* pMD) | 
|---|
| 311 | { | 
|---|
| 312 | return (PCODE)(0x12345); | 
|---|
| 313 | } | 
|---|
| 314 |  | 
|---|
| 315 | Assembly * SystemDomain::GetCallersAssembly(StackCrawlMark * stackMark, AppDomain ** ppAppDomain) | 
|---|
| 316 | { | 
|---|
| 317 | return NULL; | 
|---|
| 318 | } | 
|---|
| 319 |  | 
|---|
| 320 | void EnableStressHeapHelper() | 
|---|
| 321 | { | 
|---|
| 322 | UNREACHABLE(); | 
|---|
| 323 | } | 
|---|
| 324 |  | 
|---|
| 325 | void ReflectionModule::CaptureModuleMetaDataToMemory() | 
|---|
| 326 | { | 
|---|
| 327 | } | 
|---|
| 328 |  | 
|---|
| 329 | //--------------------------------------------------------------------------------------- | 
|---|
| 330 | // | 
|---|
| 331 | // Empty implementations of shutdown-related functions. We don't do any cleanup for shutdown during crossgen. | 
|---|
| 332 | // | 
|---|
| 333 |  | 
|---|
| 334 | Assembly::~Assembly() | 
|---|
| 335 | { | 
|---|
| 336 | } | 
|---|
| 337 |  | 
|---|
| 338 | void Assembly::StartUnload() | 
|---|
| 339 | { | 
|---|
| 340 | } | 
|---|
| 341 |  | 
|---|
| 342 | void Module::StartUnload() | 
|---|
| 343 | { | 
|---|
| 344 | } | 
|---|
| 345 |  | 
|---|
| 346 | void DynamicMethodTable::Destroy() | 
|---|
| 347 | { | 
|---|
| 348 | } | 
|---|
| 349 |  | 
|---|
| 350 | void SyncClean::AddEEHashTable(EEHashEntry** entry) | 
|---|
| 351 | { | 
|---|
| 352 | } | 
|---|
| 353 |  | 
|---|
| 354 | void SyncClean::AddHashMap(Bucket *bucket) | 
|---|
| 355 | { | 
|---|
| 356 | } | 
|---|
| 357 |  | 
|---|
| 358 | #ifdef FEATURE_COMINTEROP | 
|---|
| 359 | LONG ComCallWrapperTemplate::Release() | 
|---|
| 360 | { | 
|---|
| 361 | UNREACHABLE(); | 
|---|
| 362 | } | 
|---|
| 363 | #endif | 
|---|
| 364 |  | 
|---|
| 365 | extern "C"UINT_PTR STDCALL GetCurrentIP() | 
|---|
| 366 | { | 
|---|
| 367 | return 0; | 
|---|
| 368 | } | 
|---|
| 369 |  | 
|---|
| 370 | void EEPolicy::HandleFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMessage, PEXCEPTION_POINTERS pExceptionInfo, LPCWSTR errorSource, LPCWSTR argExceptionString) | 
|---|
| 371 | { | 
|---|
| 372 | fprintf(stderr, "Fatal error: %08x\n", exitCode); | 
|---|
| 373 | ExitProcess(exitCode); | 
|---|
| 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 | } | 
|---|
| 396 |  | 
|---|