Skip to content

Commit f21cf52

Browse files
authored
Fix signature for 64-bit delegate profiling helper (#74500)
* Fix signature for 64-bit delegate profiling helper I missed updating the signature of the 64-bit variant here when the vtable and delegate profiling helpers were originally split up. Fix #74295 * JIT: Randomly collect 64-bit counts Add some testing. * Disable collecting 64 bit counters on 32-bit This needs some work so disable it for now.
1 parent edb7d7e commit f21cf52

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3208,6 +3208,21 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
32083208
#endif
32093209
}
32103210

3211+
#ifdef TARGET_64BIT
3212+
opts.compCollect64BitCounts = JitConfig.JitCollect64BitCounts() != 0;
3213+
3214+
#ifdef DEBUG
3215+
if (JitConfig.JitRandomlyCollect64BitCounts() != 0)
3216+
{
3217+
CLRRandom rng;
3218+
rng.Init(info.compMethodHash() ^ JitConfig.JitRandomlyCollect64BitCounts() ^ 0x3485e20e);
3219+
opts.compCollect64BitCounts = rng.Next(2) == 0;
3220+
}
3221+
#endif
3222+
#else
3223+
opts.compCollect64BitCounts = false;
3224+
#endif
3225+
32113226
#ifdef DEBUG
32123227

32133228
// Now, set compMaxUncheckedOffsetForNullObject for STRESS_NULL_OBJECT_CHECK

src/coreclr/jit/compiler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9335,6 +9335,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
93359335
// Use early multi-dimensional array operator expansion (expand after loop optimizations; before lowering).
93369336
bool compJitEarlyExpandMDArrays;
93379337

9338+
// Collect 64 bit counts for PGO data.
9339+
bool compCollect64BitCounts;
9340+
93389341
} opts;
93399342

93409343
static bool s_pAltJitExcludeAssembliesListInitialized;

src/coreclr/jit/fgprofile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ void BlockCountInstrumentor::BuildSchemaElements(BasicBlock* block, Schema& sche
570570
ICorJitInfo::PgoInstrumentationSchema schemaElem;
571571
schemaElem.Count = 1;
572572
schemaElem.Other = 0;
573-
schemaElem.InstrumentationKind = JitConfig.JitCollect64BitCounts()
573+
schemaElem.InstrumentationKind = m_comp->opts.compCollect64BitCounts
574574
? ICorJitInfo::PgoInstrumentationKind::BasicBlockLongCount
575575
: ICorJitInfo::PgoInstrumentationKind::BasicBlockIntCount;
576576
schemaElem.ILOffset = offset;
@@ -1314,7 +1314,7 @@ void EfficientEdgeCountInstrumentor::BuildSchemaElements(BasicBlock* block, Sche
13141314
ICorJitInfo::PgoInstrumentationSchema schemaElem;
13151315
schemaElem.Count = 1;
13161316
schemaElem.Other = targetKey;
1317-
schemaElem.InstrumentationKind = JitConfig.JitCollect64BitCounts()
1317+
schemaElem.InstrumentationKind = m_comp->opts.compCollect64BitCounts
13181318
? ICorJitInfo::PgoInstrumentationKind::EdgeLongCount
13191319
: ICorJitInfo::PgoInstrumentationKind::EdgeIntCount;
13201320
schemaElem.ILOffset = sourceKey;
@@ -1503,7 +1503,7 @@ class BuildHandleHistogramProbeSchemaGen
15031503
schemaElem.Other |= ICorJitInfo::HandleHistogram32::DELEGATE_FLAG;
15041504
}
15051505

1506-
schemaElem.InstrumentationKind = JitConfig.JitCollect64BitCounts()
1506+
schemaElem.InstrumentationKind = compiler->opts.compCollect64BitCounts
15071507
? ICorJitInfo::PgoInstrumentationKind::HandleHistogramLongCount
15081508
: ICorJitInfo::PgoInstrumentationKind::HandleHistogramIntCount;
15091509
schemaElem.ILOffset = (int32_t)call->gtHandleHistogramProfileCandidateInfo->ilOffset;

src/coreclr/jit/jitconfigvalues.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,9 @@ CONFIG_STRING(JitEnablePgoRange, W("JitEnablePgoRange")) // Enable pgo d
561561
CONFIG_INTEGER(JitRandomEdgeCounts, W("JitRandomEdgeCounts"), 0) // Substitute random values for edge counts
562562
CONFIG_INTEGER(JitCrossCheckDevirtualizationAndPGO, W("JitCrossCheckDevirtualizationAndPGO"), 0)
563563
CONFIG_INTEGER(JitNoteFailedExactDevirtualization, W("JitNoteFailedExactDevirtualization"), 0)
564-
#endif // debug
564+
CONFIG_INTEGER(JitRandomlyCollect64BitCounts, W("JitRandomlyCollect64BitCounts"), 0) // Collect 64-bit counts randomly
565+
// for some methods.
566+
#endif // debug
565567

566568
// Devirtualize virtual calls with getExactClasses (NativeAOT only for now)
567569
CONFIG_INTEGER(JitEnableExactDevirtualization, W("JitEnableExactDevirtualization"), 1)

src/coreclr/vm/jithelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5571,7 +5571,7 @@ HCIMPL2(void, JIT_DelegateProfile32, Object *obj, ICorJitInfo::HandleHistogram32
55715571
HCIMPLEND
55725572

55735573
// Version of helper above used when the count is 64-bit
5574-
HCIMPL3(void, JIT_DelegateProfile64, Object *obj, CORINFO_METHOD_HANDLE baseMethod, ICorJitInfo::HandleHistogram64* methodProfile)
5574+
HCIMPL2(void, JIT_DelegateProfile64, Object *obj, ICorJitInfo::HandleHistogram64* methodProfile)
55755575
{
55765576
FCALL_CONTRACT;
55775577
FC_GC_POLL_NOT_NEEDED();

src/tests/Common/testenvironment.proj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
COMPlus_JitRandomGuardedDevirtualization;
6767
COMPlus_JitRandomEdgeCounts;
6868
COMPlus_JitRandomOnStackReplacement;
69+
COMPlus_JitRandomlyCollect64BitCounts;
6970
COMPlus_JitForceControlFlowGuard;
7071
COMPlus_JitCFGUseDispatcher;
7172
RunningIlasmRoundTrip
@@ -214,10 +215,10 @@
214215
<TestEnvironment Include="dynamicpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" />
215216
<TestEnvironment Include="fullpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0"/>
216217
<TestEnvironment Include="fullpgo_methodprofiling" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitDelegateProfiling="1" JitVTableProfiling="1" />
217-
<TestEnvironment Include="fullpgo_random_gdv" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1"/>
218-
<TestEnvironment Include="fullpgo_random_gdv_methodprofiling_only" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitClassProfiling="0" JitDelegateProfiling="1" JitVTableProfiling="1" />
219-
<TestEnvironment Include="fullpgo_random_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomEdgeCounts="1"/>
220-
<TestEnvironment Include="fullpgo_random_gdv_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomEdgeCounts="1"/>
218+
<TestEnvironment Include="fullpgo_random_gdv" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomlyCollect64BitCounts="1" />
219+
<TestEnvironment Include="fullpgo_random_gdv_methodprofiling_only" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitClassProfiling="0" JitDelegateProfiling="1" JitVTableProfiling="1" JitRandomlyCollect64BitCounts="1" />
220+
<TestEnvironment Include="fullpgo_random_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomEdgeCounts="1" JitRandomlyCollect64BitCounts="1" />
221+
<TestEnvironment Include="fullpgo_random_gdv_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomEdgeCounts="1" JitRandomlyCollect64BitCounts="1" />
221222
<TestEnvironment Include="gcstandalone" Condition="'$(TargetsWindows)' == 'true'" GCName="clrgc.dll"/>
222223
<TestEnvironment Include="gcstandalone" Condition="'$(TargetsWindows)' != 'true'" GCName="libclrgc.so"/>
223224
<TestEnvironment Include="gcstandaloneserver" Condition="'$(TargetsWindows)' == 'true'" gcServer="1" GCName="clrgc.dll"/>

0 commit comments

Comments
 (0)