Skip to content

Commit 6fa754e

Browse files
[release/7.0] Fix signature for 64-bit delegate profiling helper (#74743)
* 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. Co-authored-by: Jakob Botsch Nielsen <[email protected]>
1 parent dff9c90 commit 6fa754e

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
@@ -3211,6 +3211,21 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
32113211
#endif
32123212
}
32133213

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

32163231
// 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
@@ -9291,6 +9291,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
92919291
// Use early multi-dimensional array operator expansion (expand after loop optimizations; before lowering).
92929292
bool compJitEarlyExpandMDArrays;
92939293

9294+
// Collect 64 bit counts for PGO data.
9295+
bool compCollect64BitCounts;
9296+
92949297
} opts;
92959298

92969299
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
@@ -564,7 +564,9 @@ CONFIG_STRING(JitEnablePgoRange, W("JitEnablePgoRange")) // Enable pgo d
564564
CONFIG_INTEGER(JitRandomEdgeCounts, W("JitRandomEdgeCounts"), 0) // Substitute random values for edge counts
565565
CONFIG_INTEGER(JitCrossCheckDevirtualizationAndPGO, W("JitCrossCheckDevirtualizationAndPGO"), 0)
566566
CONFIG_INTEGER(JitNoteFailedExactDevirtualization, W("JitNoteFailedExactDevirtualization"), 0)
567-
#endif // debug
567+
CONFIG_INTEGER(JitRandomlyCollect64BitCounts, W("JitRandomlyCollect64BitCounts"), 0) // Collect 64-bit counts randomly
568+
// for some methods.
569+
#endif // debug
568570

569571
// Devirtualize virtual calls with getExactClasses (NativeAOT only for now)
570572
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
@@ -209,10 +210,10 @@
209210
<TestEnvironment Include="dynamicpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" />
210211
<TestEnvironment Include="fullpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0"/>
211212
<TestEnvironment Include="fullpgo_methodprofiling" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitDelegateProfiling="1" JitVTableProfiling="1" />
212-
<TestEnvironment Include="fullpgo_random_gdv" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1"/>
213-
<TestEnvironment Include="fullpgo_random_gdv_methodprofiling_only" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitClassProfiling="0" JitDelegateProfiling="1" JitVTableProfiling="1" />
214-
<TestEnvironment Include="fullpgo_random_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomEdgeCounts="1"/>
215-
<TestEnvironment Include="fullpgo_random_gdv_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomEdgeCounts="1"/>
213+
<TestEnvironment Include="fullpgo_random_gdv" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomlyCollect64BitCounts="1" />
214+
<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" />
215+
<TestEnvironment Include="fullpgo_random_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomEdgeCounts="1" JitRandomlyCollect64BitCounts="1" />
216+
<TestEnvironment Include="fullpgo_random_gdv_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomEdgeCounts="1" JitRandomlyCollect64BitCounts="1" />
216217
<TestEnvironment Include="gcstandalone" Condition="'$(TargetsWindows)' == 'true'" GCName="clrgc.dll"/>
217218
<TestEnvironment Include="gcstandalone" Condition="'$(TargetsWindows)' != 'true'" GCName="libclrgc.so"/>
218219
<TestEnvironment Include="gcstandaloneserver" Condition="'$(TargetsWindows)' == 'true'" gcServer="1" GCName="clrgc.dll"/>

0 commit comments

Comments
 (0)