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: REJIT.INL
6//
7
8//
9// Inline definitions of various items declared in REJIT.H\
10// ===========================================================================
11#ifndef _REJIT_INL_
12#define _REJIT_INL_
13
14#ifdef FEATURE_REJIT
15
16// static
17inline void ReJitManager::InitStatic()
18{
19 STANDARD_VM_CONTRACT;
20
21 s_csGlobalRequest.Init(CrstReJITGlobalRequest);
22}
23
24// static
25inline BOOL ReJitManager::IsReJITEnabled()
26{
27 LIMITED_METHOD_CONTRACT;
28
29 static bool profilerStartupRejit = CORProfilerEnableRejit() != FALSE;
30 static ConfigDWORD rejitOnAttachEnabled;
31
32 return profilerStartupRejit || (rejitOnAttachEnabled.val(CLRConfig::EXTERNAL_ProfAPI_RejitOnAttach) != 0);
33}
34
35#ifndef DACCESS_COMPILE
36//static
37inline void ReJitManager::ReportReJITError(CodeVersionManager::CodePublishError* pErrorRecord)
38{
39 CONTRACTL
40 {
41 NOTHROW;
42 GC_TRIGGERS;
43 CAN_TAKE_LOCK;
44 MODE_ANY;
45 }
46 CONTRACTL_END;
47 ReportReJITError(pErrorRecord->pModule, pErrorRecord->methodDef, pErrorRecord->pMethodDesc, pErrorRecord->hrStatus);
48}
49
50// static
51inline void ReJitManager::ReportReJITError(Module* pModule, mdMethodDef methodDef, MethodDesc* pMD, HRESULT hrStatus)
52{
53#ifdef PROFILING_SUPPORTED
54 CONTRACTL
55 {
56 NOTHROW;
57 GC_TRIGGERS;
58 CAN_TAKE_LOCK;
59 MODE_ANY;
60 }
61 CONTRACTL_END;
62
63 {
64 BEGIN_PIN_PROFILER(CORProfilerPresent());
65 _ASSERTE(CORProfilerEnableRejit());
66 {
67 GCX_PREEMP();
68 g_profControlBlock.pProfInterface->ReJITError(
69 reinterpret_cast< ModuleID > (pModule),
70 methodDef,
71 reinterpret_cast< FunctionID > (pMD),
72 hrStatus);
73 }
74 END_PIN_PROFILER();
75 }
76#endif // PROFILING_SUPPORTED
77}
78#endif // DACCESS_COMPILE
79
80#else // FEATURE_REJIT
81
82// On architectures that don't support rejit, just keep around some do-nothing
83// stubs so the rest of the VM doesn't have to be littered with #ifdef FEATURE_REJIT
84
85// static
86inline BOOL ReJitManager::IsReJITEnabled()
87{
88 return FALSE;
89}
90
91// static
92inline void ReJitManager::InitStatic()
93{
94}
95
96#endif // FEATURE_REJIT
97
98
99#endif // _REJIT_INL_
100