3c42bcea009516d7e860c7979c9e410dc71be41d
[platform/upstream/coreclr.git] / src / vm / rejit.inl
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
17 inline void ReJitManager::InitStatic()
18 {
19     STANDARD_VM_CONTRACT;
20
21     s_csGlobalRequest.Init(CrstReJITGlobalRequest);
22 }
23
24 // static
25 inline BOOL ReJitManager::IsReJITEnabled()
26 {
27     LIMITED_METHOD_CONTRACT;
28
29     return CORProfilerEnableRejit();
30 }
31
32 #ifndef DACCESS_COMPILE
33 //static
34 inline void ReJitManager::ReportReJITError(CodeVersionManager::CodePublishError* pErrorRecord)
35 {
36     CONTRACTL
37     {
38         NOTHROW;
39         GC_TRIGGERS;
40         CAN_TAKE_LOCK;
41         MODE_ANY;
42     }
43     CONTRACTL_END;
44     ReportReJITError(pErrorRecord->pModule, pErrorRecord->methodDef, pErrorRecord->pMethodDesc, pErrorRecord->hrStatus);
45 }
46
47 // static
48 inline void ReJitManager::ReportReJITError(Module* pModule, mdMethodDef methodDef, MethodDesc* pMD, HRESULT hrStatus)
49 {
50 #ifdef PROFILING_SUPPORTED
51     CONTRACTL
52     {
53         NOTHROW;
54         GC_TRIGGERS;
55         CAN_TAKE_LOCK;
56         MODE_ANY;
57     }
58     CONTRACTL_END;
59
60     {
61         BEGIN_PIN_PROFILER(CORProfilerPresent());
62         _ASSERTE(CORProfilerEnableRejit());
63         {
64             GCX_PREEMP();
65             g_profControlBlock.pProfInterface->ReJITError(
66                 reinterpret_cast< ModuleID > (pModule),
67                 methodDef,
68                 reinterpret_cast< FunctionID > (pMD),
69                 hrStatus);
70         }
71         END_PIN_PROFILER();
72     }
73 #endif // PROFILING_SUPPORTED
74 }
75 #endif // DACCESS_COMPILE
76
77 #else // FEATURE_REJIT
78
79 // On architectures that don't support rejit, just keep around some do-nothing
80 // stubs so the rest of the VM doesn't have to be littered with #ifdef FEATURE_REJIT
81
82 // static
83 inline BOOL ReJitManager::IsReJITEnabled()
84 {
85     return FALSE;
86 }
87
88 // static 
89 inline void ReJitManager::InitStatic()
90 {
91 }
92
93 #endif // FEATURE_REJIT
94
95
96 #endif // _REJIT_INL_