Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Fix for #12609 - add option to disable tiered compilation for profile…
Browse files Browse the repository at this point in the history
…rs (#14643)

add option to disable tiered compilation for profilers
  • Loading branch information
davmason authored Oct 23, 2017
1 parent 3315923 commit 67a6615
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/inc/corprof.idl
Original file line number Diff line number Diff line change
Expand Up @@ -623,14 +623,16 @@ typedef enum

COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS = 0x00000004,

COR_PRF_HIGH_DISABLE_TIERED_COMPILATION = 0x00000008,

COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,

COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED | COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS,

// MONITOR_IMMUTABLE represents all flags that may only be set during initialization.
// Trying to change any of these flags elsewhere will result in a
// failed HRESULT.
COR_PRF_HIGH_MONITOR_IMMUTABLE = 0,
COR_PRF_HIGH_MONITOR_IMMUTABLE = COR_PRF_HIGH_DISABLE_TIERED_COMPILATION,

} COR_PRF_HIGH_MONITOR;

Expand Down
16 changes: 16 additions & 0 deletions src/inc/profilepriv.inl
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,22 @@ inline BOOL CORProfilerIsMonitoringDynamicFunctionUnloads()
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS));
}

inline BOOL CORProfilerDisableTieredCompilation()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
SO_NOT_MAINLINE;
}
CONTRACTL_END;


return (CORProfilerPresent() &&
((&g_profControlBlock)->dwEventMaskHigh & COR_PRF_HIGH_DISABLE_TIERED_COMPILATION));
}

#if defined(PROFILING_SUPPORTED) && !defined(CROSSGEN_COMPILE)

#if defined(FEATURE_PROFAPI_ATTACH_DETACH)
Expand Down
3 changes: 2 additions & 1 deletion src/pal/prebuilt/inc/corprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,10 @@ enum __MIDL___MIDL_itf_corprof_0000_0000_0006
COR_PRF_HIGH_ADD_ASSEMBLY_REFERENCES = 0x1,
COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED = 0x2,
COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS = 0x4,
COR_PRF_HIGH_DISABLE_TIERED_COMPILATION = 0x8,
COR_PRF_HIGH_REQUIRE_PROFILE_IMAGE = 0,
COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH = ( COR_PRF_HIGH_IN_MEMORY_SYMBOLS_UPDATED | COR_PRF_HIGH_MONITOR_DYNAMIC_FUNCTION_UNLOADS ) ,
COR_PRF_HIGH_MONITOR_IMMUTABLE = 0
COR_PRF_HIGH_MONITOR_IMMUTABLE = ( COR_PRF_HIGH_DISABLE_TIERED_COMPILATION )
} COR_PRF_HIGH_MONITOR;

typedef /* [public] */
Expand Down
18 changes: 11 additions & 7 deletions src/vm/eetoprofinterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,8 @@ HRESULT EEToProfInterfaceImpl::EnsureProfilerDetachable()
{
LIMITED_METHOD_CONTRACT;

if ((g_profControlBlock.dwEventMask & COR_PRF_MONITOR_IMMUTABLE) != 0)
if (((g_profControlBlock.dwEventMask & COR_PRF_MONITOR_IMMUTABLE) != 0) ||
((g_profControlBlock.dwEventMaskHigh & COR_PRF_HIGH_MONITOR_IMMUTABLE) != 0))
{
LOG((
LF_CORPROF,
Expand Down Expand Up @@ -2268,12 +2269,14 @@ HRESULT EEToProfInterfaceImpl::SetEventMask(DWORD dwEventMask, DWORD dwEventMask
if (g_profControlBlock.curProfStatus.Get() != kProfStatusInitializingForStartupLoad)
{
#ifdef _DEBUG
if ((dwEventMask & dwImmutableEventFlags) !=
(g_profControlBlock.dwEventMask & dwImmutableEventFlags))
if (((dwEventMask & dwImmutableEventFlags) !=
(g_profControlBlock.dwEventMask & dwImmutableEventFlags)) ||
#else //!_DEBUG
if ((dwEventMask & COR_PRF_MONITOR_IMMUTABLE) !=
(g_profControlBlock.dwEventMask & COR_PRF_MONITOR_IMMUTABLE))
if (((dwEventMask & COR_PRF_MONITOR_IMMUTABLE) !=
(g_profControlBlock.dwEventMask & COR_PRF_MONITOR_IMMUTABLE)) ||
#endif //_DEBUG
((dwEventMaskHigh & COR_PRF_HIGH_MONITOR_IMMUTABLE) !=
(g_profControlBlock.dwEventMaskHigh & COR_PRF_HIGH_MONITOR_IMMUTABLE)))
{
// FUTURE: Should we have a dedicated HRESULT for setting immutable flag?
return E_FAIL;
Expand All @@ -2284,10 +2287,11 @@ HRESULT EEToProfInterfaceImpl::SetEventMask(DWORD dwEventMask, DWORD dwEventMask
// allowable after an attach
if (m_fLoadedViaAttach &&
#ifdef _DEBUG
((dwEventMask & (~dwAllowableAfterAttachEventFlags)) != 0))
(((dwEventMask & (~dwAllowableAfterAttachEventFlags)) != 0) ||
#else //!_DEBUG
((dwEventMask & (~COR_PRF_ALLOWABLE_AFTER_ATTACH)) != 0))
(((dwEventMask & (~COR_PRF_ALLOWABLE_AFTER_ATTACH)) != 0) ||
#endif //_DEBUG
(dwEventMaskHigh & (~COR_PRF_HIGH_ALLOWABLE_AFTER_ATTACH))))
{
return CORPROF_E_UNSUPPORTED_FOR_ATTACHING_PROFILER;
}
Expand Down
3 changes: 2 additions & 1 deletion src/vm/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,8 @@ class MethodDesc
!IsUnboxingStub() &&
!IsInstantiatingStub() &&
!IsDynamicMethod() &&
!CORDisableJITOptimizations(GetModule()->GetDebuggerInfoBits());
!CORDisableJITOptimizations(GetModule()->GetDebuggerInfoBits()) &&
!CORProfilerDisableTieredCompilation();
}
#endif

Expand Down

0 comments on commit 67a6615

Please sign in to comment.