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

Fix for #12609 - add option to disable tiered compilation for profilers #14643

Merged
merged 4 commits into from
Oct 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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