Skip to content

Commit beba097

Browse files
Fix profiler-disabled runtime state
Co-authored-by: Copilot <[email protected]> Copilot-Session: da72e163-376d-48aa-988d-c52f3150a614
1 parent ef6ca45 commit beba097

7 files changed

Lines changed: 22 additions & 21 deletions

File tree

‎src/coreclr/clrdefinitions.cmake‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if (FEATURE_PROFAPI_ATTACH_DETACH)
4646
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:FEATURE_PROFAPI_ATTACH_DETACH>)
4747
endif()
4848

49-
add_compile_definitions($<$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>:PROFILING_SUPPORTED_DATA>)
49+
add_compile_definitions(PROFILING_SUPPORTED_DATA)
5050

5151
if(CLR_CMAKE_HOST_WIN32)
5252
add_definitions(-DWIN32)

‎src/coreclr/vm/assembly.cpp‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,6 @@ void Assembly::BeforeTypeLoad()
21022102
}
21032103
CONTRACTL_END;
21042104

2105-
#ifdef PROFILING_SUPPORTED
21062105
// After this point, it is possible to load types.
21072106
// We need to notify the profiler now because the profiler may need to inject methods into
21082107
// the module, and to do so reliably, it must have the chance to do so before
@@ -2120,11 +2119,12 @@ void Assembly::BeforeTypeLoad()
21202119
// FILE_LOAD_DELIVER_EVENTS.
21212120
if (!IsProfilerNotified())
21222121
{
2122+
// This flag also marks the assembly as available to code versioning enumerators.
21232123
SetProfilerNotified();
2124+
#ifdef PROFILING_SUPPORTED
21242125
GetModule()->NotifyProfilerLoadFinished(S_OK);
2126+
#endif // PROFILING_SUPPORTED
21252127
}
2126-
2127-
#endif
21282128
}
21292129

21302130
void Assembly::EagerFixups()
@@ -2279,13 +2279,14 @@ void Assembly::DeliverSyncEvents()
22792279

22802280
GetModule()->NotifyEtwLoadFinished(S_OK);
22812281

2282-
#ifdef PROFILING_SUPPORTED
22832282
if (!IsProfilerNotified())
22842283
{
2284+
// This flag also marks the assembly as available to code versioning enumerators.
22852285
SetProfilerNotified();
2286+
#ifdef PROFILING_SUPPORTED
22862287
GetModule()->NotifyProfilerLoadFinished(S_OK);
2288+
#endif // PROFILING_SUPPORTED
22872289
}
2288-
#endif
22892290

22902291
#ifdef DEBUGGING_SUPPORTED
22912292
GCX_COOP();

‎src/coreclr/vm/ceeload.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,9 @@ void Module::UpdateNewlyAddedTypes()
257257

258258
m_typeCounts = currTypeCounts;
259259
}
260+
#endif // PROFILING_SUPPORTED || FEATURE_METADATA_UPDATER
260261

262+
#if defined(PROFILING_SUPPORTED) || defined(FEATURE_METADATA_UPDATER)
261263
Module::TypeCounts Module::GetCurrentTypeCounts()
262264
{
263265
WRAPPER_NO_CONTRACT;
@@ -503,12 +505,11 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
503505
}
504506

505507
#if defined(PROFILING_SUPPORTED_DATA) || defined(FEATURE_METADATA_UPDATER)
506-
#if defined(PROFILING_SUPPORTED)
507-
// These will be updated in NotifyProfilerLoadFinished for profiling scenarios.
508508
m_typeCounts = {};
509-
#else
509+
510+
#if defined(FEATURE_METADATA_UPDATER) && !defined(PROFILING_SUPPORTED)
510511
m_typeCounts = GetCurrentTypeCounts();
511-
#endif // PROFILING_SUPPORTED
512+
#endif // FEATURE_METADATA_UPDATER && !PROFILING_SUPPORTED
512513
#endif // PROFILING_SUPPORTED_DATA || FEATURE_METADATA_UPDATER
513514

514515
#ifdef PROFILING_SUPPORTED

‎src/coreclr/vm/peassembly.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,10 +648,10 @@ PEAssembly::PEAssembly(
648648
m_PEImage{NULL}
649649
, m_MDImportIsRW_Debugger_Use_Only{FALSE}
650650
, m_pMDImport{NULL}
651-
#if defined(PROFILING_SUPPORTED) || defined(FEATURE_METADATA_UPDATER)
651+
#if defined(PROFILING_SUPPORTED_DATA) || defined(FEATURE_METADATA_UPDATER)
652652
, m_pImporter{NULL}
653653
, m_pEmitter{NULL}
654-
#endif // PROFILING_SUPPORTED || FEATURE_METADATA_UPDATER
654+
#endif // PROFILING_SUPPORTED_DATA || FEATURE_METADATA_UPDATER
655655
, m_pMDInternalEmit{NULL}
656656
, m_refCount{1}
657657
, m_pHostAssembly{nullptr}

‎src/coreclr/vm/rejit.inl‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ static BOOL RejitOnAttachEnabled()
2424
{
2525
LIMITED_METHOD_DAC_CONTRACT;
2626

27-
#ifdef PROFILING_SUPPORTED
27+
#if defined(PROFILING_SUPPORTED) || defined(DACCESS_COMPILE)
2828
return (&g_profControlBlock)->fRejitOnAttachEnabled;
2929
#else
3030
return FALSE;
31-
#endif // PROFILING_SUPPORTED
31+
#endif // PROFILING_SUPPORTED || DACCESS_COMPILE
3232
}
3333

3434
// static
3535
inline BOOL ReJitManager::IsReJITEnabled()
3636
{
3737
LIMITED_METHOD_DAC_CONTRACT;
3838

39-
#ifdef PROFILING_SUPPORTED
39+
#if defined(PROFILING_SUPPORTED) || defined(DACCESS_COMPILE)
4040
static bool profilerStartupRejit = CORProfilerEnableRejit() != FALSE;
4141
return profilerStartupRejit || RejitOnAttachEnabled();
4242
#else
4343
return FALSE;
44-
#endif // PROFILING_SUPPORTED
44+
#endif // PROFILING_SUPPORTED || DACCESS_COMPILE
4545
}
4646

4747
inline BOOL ReJitManager::IsReJITInlineTrackingEnabled()

‎src/coreclr/vm/threads.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ Thread::Thread()
13851385
m_debuggerFilterContext = NULL;
13861386
m_fInteropDebuggingHijacked = FALSE;
13871387

1388-
#if defined(PROFILING_SUPPORTED)
1388+
#if defined(PROFILING_SUPPORTED) || defined(PROFILING_SUPPORTED_DATA)
13891389
m_profilerCallbackState = 0;
13901390

13911391
for (int i = 0; i < MAX_NOTIFICATION_PROFILERS + 1; ++i)
@@ -1394,7 +1394,7 @@ Thread::Thread()
13941394
}
13951395

13961396
m_pProfilerFilterContext = NULL;
1397-
#endif // PROFILING_SUPPORTED
1397+
#endif // PROFILING_SUPPORTED || PROFILING_SUPPORTED_DATA
13981398

13991399
m_CacheStackBase = 0;
14001400
m_CacheStackLimit = 0;

‎src/coreclr/vm/vars.cpp‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ GVAL_IMPL_INIT(DWORD, g_externalMethodFixupTraceActiveCount, 0);
168168

169169
#endif // DEBUGGING_SUPPORTED
170170

171-
#if defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPPORTED)
171+
#ifdef PROFILING_SUPPORTED_DATA
172172
GVAL_IMPL(ProfControlBlock, g_profControlBlock);
173-
#endif // defined(PROFILING_SUPPORTED_DATA) || defined(PROFILING_SUPPPORTED)
173+
#endif // PROFILING_SUPPORTED_DATA
174174

175175
#ifndef DACCESS_COMPILE
176176

@@ -263,4 +263,3 @@ __GlobalVal< GSCookie > s_gsCookie(&DacGlobals::dac__s_gsCookie);
263263
#endif //!DACCESS_COMPILE
264264

265265
//==============================================================================
266-

0 commit comments

Comments
 (0)