Skip to content
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
3 changes: 1 addition & 2 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,7 @@ void DacDbiInterfaceImpl::GetCompilerFlags (

// Get the underlying module - none of this is AppDomain specific
Module * pModule = pDomainAssembly->GetAssembly()->GetModule();
DWORD dwBits = pModule->GetDebuggerInfoBits();
*pfAllowJITOpts = !CORDisableJITOptimizations(dwBits);
*pfAllowJITOpts = !pModule->AreJITOptimizationsDisabled();
*pfEnableEnC = pModule->IsEditAndContinueEnabled();


Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3301,7 +3301,7 @@ void Debugger::getBoundaries(MethodDesc * md,
// lives in, then don't grab specific boundaries from the symbol
// store since any boundaries we give the JIT will be pretty much
// ignored anyway.
if (!CORDisableJITOptimizations(md->GetModule()->GetDebuggerInfoBits()))
if (!md->GetModule()->AreJITOptimizationsDisabled())
{
*implicitBoundaries = ICorDebugInfo::BoundaryTypes(ICorDebugInfo::STACK_EMPTY_BOUNDARIES |
ICorDebugInfo::CALL_SITE_BOUNDARIES);
Expand Down Expand Up @@ -3379,13 +3379,10 @@ void Debugger::getVars(MethodDesc * md, ULONG32 *cVars, ICorDebugInfo::ILVarInfo
// free to ignore *extendOthers
*extendOthers = true;

DWORD bits = md->GetModule()->GetDebuggerInfoBits();

if (CORDBUnrecoverableError(this))
goto Exit;

if (CORDisableJITOptimizations(bits))
// if (!CORDebuggerAllowJITOpts(bits))
if (md->GetModule()->AreJITOptimizationsDisabled())
{
//
// @TODO: Do we really need this code since *extendOthers==true?
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/debug/ee/debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,6 @@ class DebuggerModule
PTR_Module m_pRuntimeModule;
PTR_DomainAssembly m_pRuntimeDomainAssembly;

bool m_fHasOptimizedCode;

// Can we change jit flags on the module?
// This is true during the Module creation
bool m_fCanChangeJitFlags;
Expand Down
7 changes: 1 addition & 6 deletions src/coreclr/debug/ee/debugger.inl
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ inline DebuggerModule::DebuggerModule(Module * pRuntimeModule,
LOG((LF_CORDB,LL_INFO10000, "DM::DM this:0x%x Module:0x%x DF:0x%x\n",
this, pRuntimeModule, pDomainAssembly));

// Do we have any optimized code?
DWORD dwDebugBits = pRuntimeModule->GetDebuggerInfoBits();
m_fHasOptimizedCode = CORDebuggerAllowJITOpts(dwDebugBits);

// Dynamic modules must receive ClassLoad callbacks in order to receive metadata updates as the module
// evolves. So we force this on here and refuse to change it for all dynamic modules.
if (pRuntimeModule->IsReflectionEmit())
Expand All @@ -83,8 +79,7 @@ inline bool DebuggerModule::HasAnyOptimizedCode()
{
LIMITED_METHOD_CONTRACT;
Module * pModule = GetRuntimeModule();
DWORD dwDebugBits = pModule->GetDebuggerInfoBits();
return CORDebuggerAllowJITOpts(dwDebugBits);
return !pModule->AreJITOptimizationsDisabled();
}

//-----------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/corprof.idl
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ typedef enum
COR_PRF_MONITOR_CLASS_LOADS |
COR_PRF_MONITOR_EXCEPTIONS |
COR_PRF_MONITOR_JIT_COMPILATION |
COR_PRF_DISABLE_INLINING |
COR_PRF_DISABLE_OPTIMIZATIONS |
COR_PRF_ENABLE_REJIT,

COR_PRF_ALLOWABLE_NOTIFICATION_PROFILER
Expand Down Expand Up @@ -625,8 +627,6 @@ typedef enum
COR_PRF_MONITOR_REMOTING_ASYNC |
COR_PRF_ENABLE_INPROC_DEBUGGING |
COR_PRF_ENABLE_JIT_MAPS |
COR_PRF_DISABLE_OPTIMIZATIONS |
COR_PRF_DISABLE_INLINING |
COR_PRF_ENABLE_OBJECT_ALLOCATED |
COR_PRF_ENABLE_FUNCTION_ARGS |
COR_PRF_ENABLE_FUNCTION_RETVAL |
Expand Down Expand Up @@ -4292,10 +4292,10 @@ interface ICorProfilerInfo14 : ICorProfilerInfo13
[out, size_is(cObjectRanges), length_is(*pcObjectRanges)] COR_PRF_NONGC_HEAP_RANGE ranges[]);


// EventPipeCreateProvider2 allows you to pass in a callback which will be called whenever a
// EventPipeCreateProvider2 allows you to pass in a callback which will be called whenever a
// session enables your provider. The behavior of the callback matches the ETW behavior which
// can be counter intuitive. You will get a callback any time a session changes with the updated
// global keywords enabled for your session. The is_enabled parameter will be true if any
// can be counter intuitive. You will get a callback any time a session changes with the updated
// global keywords enabled for your session. The is_enabled parameter will be true if any
// session has your provider enabled. The source_id parameter will be a valid id if the callback
// was triggered due to a session enabling and it will be NULL if it was triggered due to a session
// disabling.
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/pal/prebuilt/inc/corprof.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ enum __MIDL___MIDL_itf_corprof_0000_0000_0005
COR_PRF_DISABLE_ALL_NGEN_IMAGES = 0x80000000,
COR_PRF_ALL = 0x8fffffff,
COR_PRF_REQUIRE_PROFILE_IMAGE = ( ( COR_PRF_USE_PROFILE_IMAGES | COR_PRF_MONITOR_CODE_TRANSITIONS ) | COR_PRF_MONITOR_ENTERLEAVE ) ,
COR_PRF_ALLOWABLE_AFTER_ATTACH = ( ( ( ( ( ( ( ( ( ( COR_PRF_MONITOR_THREADS | COR_PRF_MONITOR_MODULE_LOADS ) | COR_PRF_MONITOR_ASSEMBLY_LOADS ) | COR_PRF_MONITOR_APPDOMAIN_LOADS ) | COR_PRF_ENABLE_STACK_SNAPSHOT ) | COR_PRF_MONITOR_GC ) | COR_PRF_MONITOR_SUSPENDS ) | COR_PRF_MONITOR_CLASS_LOADS ) | COR_PRF_MONITOR_EXCEPTIONS ) | COR_PRF_MONITOR_JIT_COMPILATION ) | COR_PRF_ENABLE_REJIT ) ,
COR_PRF_ALLOWABLE_AFTER_ATTACH = ( ( ( ( ( ( ( ( ( ( ( ( COR_PRF_MONITOR_THREADS | COR_PRF_MONITOR_MODULE_LOADS ) | COR_PRF_MONITOR_ASSEMBLY_LOADS ) | COR_PRF_MONITOR_APPDOMAIN_LOADS ) | COR_PRF_ENABLE_STACK_SNAPSHOT ) | COR_PRF_MONITOR_GC ) | COR_PRF_MONITOR_SUSPENDS ) | COR_PRF_MONITOR_CLASS_LOADS ) | COR_PRF_MONITOR_EXCEPTIONS ) | COR_PRF_MONITOR_JIT_COMPILATION ) | COR_PRF_DISABLE_INLINING ) | COR_PRF_DISABLE_OPTIMIZATIONS ) | COR_PRF_ENABLE_REJIT ) ,
COR_PRF_ALLOWABLE_NOTIFICATION_PROFILER = ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( COR_PRF_MONITOR_FUNCTION_UNLOADS | COR_PRF_MONITOR_CLASS_LOADS ) | COR_PRF_MONITOR_MODULE_LOADS ) | COR_PRF_MONITOR_ASSEMBLY_LOADS ) | COR_PRF_MONITOR_APPDOMAIN_LOADS ) | COR_PRF_MONITOR_JIT_COMPILATION ) | COR_PRF_MONITOR_EXCEPTIONS ) | COR_PRF_MONITOR_OBJECT_ALLOCATED ) | COR_PRF_MONITOR_THREADS ) | COR_PRF_MONITOR_CODE_TRANSITIONS ) | COR_PRF_MONITOR_CCW ) | COR_PRF_MONITOR_SUSPENDS ) | COR_PRF_MONITOR_CACHE_SEARCHES ) | COR_PRF_DISABLE_INLINING ) | COR_PRF_DISABLE_OPTIMIZATIONS ) | COR_PRF_ENABLE_OBJECT_ALLOCATED ) | COR_PRF_MONITOR_CLR_EXCEPTIONS ) | COR_PRF_ENABLE_STACK_SNAPSHOT ) | COR_PRF_USE_PROFILE_IMAGES ) | COR_PRF_DISABLE_ALL_NGEN_IMAGES ) ,
COR_PRF_MONITOR_IMMUTABLE = ( ( ( ( ( ( ( ( ( ( ( ( ( ( COR_PRF_MONITOR_CODE_TRANSITIONS | COR_PRF_MONITOR_REMOTING ) | COR_PRF_MONITOR_REMOTING_COOKIE ) | COR_PRF_MONITOR_REMOTING_ASYNC ) | COR_PRF_ENABLE_INPROC_DEBUGGING ) | COR_PRF_ENABLE_JIT_MAPS ) | COR_PRF_DISABLE_OPTIMIZATIONS ) | COR_PRF_DISABLE_INLINING ) | COR_PRF_ENABLE_OBJECT_ALLOCATED ) | COR_PRF_ENABLE_FUNCTION_ARGS ) | COR_PRF_ENABLE_FUNCTION_RETVAL ) | COR_PRF_ENABLE_FRAME_INFO ) | COR_PRF_USE_PROFILE_IMAGES ) | COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST ) | COR_PRF_DISABLE_ALL_NGEN_IMAGES )
COR_PRF_MONITOR_IMMUTABLE = ( ( ( ( ( ( ( ( ( ( ( ( COR_PRF_MONITOR_CODE_TRANSITIONS | COR_PRF_MONITOR_REMOTING ) | COR_PRF_MONITOR_REMOTING_COOKIE ) | COR_PRF_MONITOR_REMOTING_ASYNC ) | COR_PRF_ENABLE_INPROC_DEBUGGING ) | COR_PRF_ENABLE_JIT_MAPS ) | COR_PRF_ENABLE_OBJECT_ALLOCATED ) | COR_PRF_ENABLE_FUNCTION_ARGS ) | COR_PRF_ENABLE_FUNCTION_RETVAL ) | COR_PRF_ENABLE_FRAME_INFO ) | COR_PRF_USE_PROFILE_IMAGES ) | COR_PRF_DISABLE_TRANSPARENCY_CHECKS_UNDER_FULL_TRUST ) | COR_PRF_DISABLE_ALL_NGEN_IMAGES )
} COR_PRF_MONITOR;

typedef /* [public] */
Expand Down
17 changes: 14 additions & 3 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,25 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
m_dwTypeCount = 0;
m_dwExportedTypeCount = 0;
m_dwCustomAttributeCount = 0;
#ifdef PROFILING_SUPPORTED
// set profiler related JIT flags
if (CORProfilerDisableInlining())
{
m_dwTransientFlags |= PROF_DISABLE_INLINING;
}
if (CORProfilerDisableOptimizations())
{
m_dwTransientFlags |= PROF_DISABLE_OPTIMIZATIONS;
}

#if defined(PROFILING_SUPPORTED) && !defined(DACCESS_COMPILE)
#if !defined(DACCESS_COMPILE)
m_pJitInlinerTrackingMap = NULL;
if (ReJitManager::IsReJITInlineTrackingEnabled())
{
m_pJitInlinerTrackingMap = new JITInlineTrackingMap(GetLoaderAllocator());
}
#endif // defined (PROFILING_SUPPORTED) &&!defined(DACCESS_COMPILE)
#endif // !defined(DACCESS_COMPILE)
#endif // PROFILING_SUPPORTED

LOG((LF_CLASSLOADER, LL_INFO10, "Loaded pModule: \"%s\".\n", GetDebugName()));
}
Expand All @@ -507,7 +518,7 @@ void Module::SetDebuggerInfoBits(DebuggerAssemblyControlFlags newBits)
#ifdef DEBUGGING_SUPPORTED
if (IsEditAndContinueCapable())
{
BOOL setEnC = (newBits & DACF_ENC_ENABLED) != 0 || g_pConfig->ForceEnc() || (g_pConfig->DebugAssembliesModifiable() && CORDisableJITOptimizations(GetDebuggerInfoBits()));
BOOL setEnC = (newBits & DACF_ENC_ENABLED) != 0 || g_pConfig->ForceEnc() || (g_pConfig->DebugAssembliesModifiable() && AreJITOptimizationsDisabled());
if (setEnC)
{
EnableEditAndContinue();
Expand Down
37 changes: 36 additions & 1 deletion src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ class Module : public ModuleBase
IS_ETW_NOTIFIED = 0x00000020,

IS_REFLECTION_EMIT = 0x00000040,
PROF_DISABLE_OPTIMIZATIONS = 0x00000080, // indicates if Profiler disabled JIT optimization event mask was set when loaded
PROF_DISABLE_INLINING = 0x00000100, // indicates if Profiler disabled JIT Inlining event mask was set when loaded

//
// Note: The values below must match the ones defined in
Expand Down Expand Up @@ -915,6 +917,39 @@ class Module : public ModuleBase
return (m_dwTransientFlags & IS_EDIT_AND_CONTINUE) != 0;
}

BOOL IsInliningDisabledByProfiler() const
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;

return (m_dwTransientFlags & PROF_DISABLE_INLINING) != 0;
}

BOOL AreJITOptimizationsDisabled() const
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;

#ifdef DEBUGGING_SUPPORTED
// check if debugger has disallowed JIT optimizations
auto dwDebuggerBits = GetDebuggerInfoBits();
if (!CORDebuggerAllowJITOpts(dwDebuggerBits))
{
return TRUE;
}
#endif // DEBUGGING_SUPPORTED

#if defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA)
// check if profiler had disabled JIT optimizations when module was loaded
if (m_dwTransientFlags & PROF_DISABLE_OPTIMIZATIONS)
{
return TRUE;
}
#endif // defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA)

return FALSE;
}

#ifdef FEATURE_METADATA_UPDATER
// Holds a table of EnCEEClassData object for classes in this module that have been modified
CUnorderedArray<EnCEEClassData*, 5> m_ClassList;
Expand Down Expand Up @@ -1339,7 +1374,7 @@ class Module : public ModuleBase

void SetDebuggerInfoBits(DebuggerAssemblyControlFlags newBits);

DebuggerAssemblyControlFlags GetDebuggerInfoBits(void)
DebuggerAssemblyControlFlags GetDebuggerInfoBits(void) const
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
Expand Down
20 changes: 9 additions & 11 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7891,6 +7891,13 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
}

#ifdef PROFILING_SUPPORTED
if (pOrigCallerModule->IsInliningDisabledByProfiler())
{
result = INLINE_FAIL;
szFailReason = "Inlining is disabled in the compiled method's module by a profiler";
goto exit;
}

if (CORProfilerPresent())
{
// #rejit
Expand All @@ -7905,15 +7912,6 @@ CorInfoInline CEEInfo::canInline (CORINFO_METHOD_HANDLE hCaller,
goto exit;
}

// If the profiler has set a mask preventing inlining, always return
// false to the jit.
if (CORProfilerDisableInlining())
{
result = INLINE_FAIL;
szFailReason = "Profiler disabled inlining globally";
goto exit;
}

#if defined(FEATURE_REJIT) && !defined(DACCESS_COMPILE)
if (CORProfilerEnableRejit())
{
Expand Down Expand Up @@ -9569,7 +9567,7 @@ CorInfoTypeWithMod CEEInfo::getArgType (

case ELEMENT_TYPE_PTR:
// Load the type eagerly under debugger to make the eval work
if (CORDisableJITOptimizations(pModule->GetDebuggerInfoBits()))
if (pModule->AreJITOptimizationsDisabled())
{
// NOTE: in some IJW cases, when the type pointed at is unmanaged,
// the GetTypeHandle may fail, because there is no TypeDef for such type.
Expand Down Expand Up @@ -12898,7 +12896,7 @@ CORJIT_FLAGS GetDebuggerCompileFlags(Module* pModule, CORJIT_FLAGS flags)
flags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_INFO);
#endif // DEBUGGING_SUPPORTED

if (CORDisableJITOptimizations(pModule->GetDebuggerInfoBits()))
if (pModule->AreJITOptimizationsDisabled())
{
flags.Set(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2888,7 +2888,7 @@ bool MethodDesc::IsJitOptimizationDisabledForAllMethodsInChunk()
return
g_pConfig->JitMinOpts() ||
g_pConfig->GenDebuggableCode() ||
CORDisableJITOptimizations(GetModule()->GetDebuggerInfoBits());
GetModule()->AreJITOptimizationsDisabled();
}

#ifndef DACCESS_COMPILE
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4329,7 +4329,7 @@ void MethodTable::DoFullyLoad(Generics::RecursionGraph * const pVisited, const
}

if ((level == CLASS_LOADED) &&
CORDisableJITOptimizations(this->GetModule()->GetDebuggerInfoBits()) &&
this->GetModule()->AreJITOptimizationsDisabled() &&
!HasInstantiation() &&
!GetModule()->GetAssembly()->IsLoading()) // Do not do this during the vtable fixup stage of C++/CLI assembly loading. See https://github.com/dotnet/runtime/issues/110365
{
Expand Down
42 changes: 3 additions & 39 deletions src/coreclr/vm/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,9 @@ inline bool CORDebuggerAttached()
return (g_CORDebuggerControlFlags & DBCF_ATTACHED) && !IsAtProcessExit();
}

// This only check debugger bits. However JIT optimizations can be disabled by other ways on a module
// In most cases Module::AreJITOptimizationsDisabled() should be the prefered for checking if JIT optimizations
// are disabled for a module (it does check both debugger bits and profiler jit deoptimization flag)
#define CORDebuggerAllowJITOpts(dwDebuggerBits) \
(((dwDebuggerBits) & DACF_ALLOW_JIT_OPTS) \
|| \
Expand All @@ -544,45 +547,6 @@ inline bool CORDebuggerAttached()
#define CORDebuggerTraceCall() \
(CORDebuggerAttached() && GetThread()->IsTraceCall())



//
// Define stuff for precedence between profiling and debugging
// flags that can both be set.
//

#if defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA)

#ifdef DEBUGGING_SUPPORTED

#define CORDisableJITOptimizations(dwDebuggerBits) \
(CORProfilerDisableOptimizations() || \
!CORDebuggerAllowJITOpts(dwDebuggerBits))

#else // !DEBUGGING_SUPPORTED

#define CORDisableJITOptimizations(dwDebuggerBits) \
CORProfilerDisableOptimizations()

#endif// DEBUGGING_SUPPORTED

#else // !defined(PROFILING_SUPPORTED) && !defined(PROFILING_SUPPORTED_DATA)

#ifdef DEBUGGING_SUPPORTED

#define CORDisableJITOptimizations(dwDebuggerBits) \
!CORDebuggerAllowJITOpts(dwDebuggerBits)

#else // DEBUGGING_SUPPORTED

#define CORDisableJITOptimizations(dwDebuggerBits) FALSE

#endif// DEBUGGING_SUPPORTED

#endif// defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA)



#ifndef TARGET_UNIX
GVAL_DECL(SIZE_T, g_runtimeLoadedBaseAddress);
GVAL_DECL(SIZE_T, g_runtimeVirtualSize);
Expand Down
Loading
Loading