Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Fix signature for 64-bit delegate profiling helper #74743

Merged
merged 3 commits into from
Aug 29, 2022
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
15 changes: 15 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3211,6 +3211,21 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
#endif
}

#ifdef TARGET_64BIT
opts.compCollect64BitCounts = JitConfig.JitCollect64BitCounts() != 0;

#ifdef DEBUG
if (JitConfig.JitRandomlyCollect64BitCounts() != 0)
{
CLRRandom rng;
rng.Init(info.compMethodHash() ^ JitConfig.JitRandomlyCollect64BitCounts() ^ 0x3485e20e);
opts.compCollect64BitCounts = rng.Next(2) == 0;
}
#endif
#else
opts.compCollect64BitCounts = false;
#endif

#ifdef DEBUG

// Now, set compMaxUncheckedOffsetForNullObject for STRESS_NULL_OBJECT_CHECK
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9291,6 +9291,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// Use early multi-dimensional array operator expansion (expand after loop optimizations; before lowering).
bool compJitEarlyExpandMDArrays;

// Collect 64 bit counts for PGO data.
bool compCollect64BitCounts;

} opts;

static bool s_pAltJitExcludeAssembliesListInitialized;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ void BlockCountInstrumentor::BuildSchemaElements(BasicBlock* block, Schema& sche
ICorJitInfo::PgoInstrumentationSchema schemaElem;
schemaElem.Count = 1;
schemaElem.Other = 0;
schemaElem.InstrumentationKind = JitConfig.JitCollect64BitCounts()
schemaElem.InstrumentationKind = m_comp->opts.compCollect64BitCounts
? ICorJitInfo::PgoInstrumentationKind::BasicBlockLongCount
: ICorJitInfo::PgoInstrumentationKind::BasicBlockIntCount;
schemaElem.ILOffset = offset;
Expand Down Expand Up @@ -1314,7 +1314,7 @@ void EfficientEdgeCountInstrumentor::BuildSchemaElements(BasicBlock* block, Sche
ICorJitInfo::PgoInstrumentationSchema schemaElem;
schemaElem.Count = 1;
schemaElem.Other = targetKey;
schemaElem.InstrumentationKind = JitConfig.JitCollect64BitCounts()
schemaElem.InstrumentationKind = m_comp->opts.compCollect64BitCounts
? ICorJitInfo::PgoInstrumentationKind::EdgeLongCount
: ICorJitInfo::PgoInstrumentationKind::EdgeIntCount;
schemaElem.ILOffset = sourceKey;
Expand Down Expand Up @@ -1503,7 +1503,7 @@ class BuildHandleHistogramProbeSchemaGen
schemaElem.Other |= ICorJitInfo::HandleHistogram32::DELEGATE_FLAG;
}

schemaElem.InstrumentationKind = JitConfig.JitCollect64BitCounts()
schemaElem.InstrumentationKind = compiler->opts.compCollect64BitCounts
? ICorJitInfo::PgoInstrumentationKind::HandleHistogramLongCount
: ICorJitInfo::PgoInstrumentationKind::HandleHistogramIntCount;
schemaElem.ILOffset = (int32_t)call->gtHandleHistogramProfileCandidateInfo->ilOffset;
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ CONFIG_STRING(JitEnablePgoRange, W("JitEnablePgoRange")) // Enable pgo d
CONFIG_INTEGER(JitRandomEdgeCounts, W("JitRandomEdgeCounts"), 0) // Substitute random values for edge counts
CONFIG_INTEGER(JitCrossCheckDevirtualizationAndPGO, W("JitCrossCheckDevirtualizationAndPGO"), 0)
CONFIG_INTEGER(JitNoteFailedExactDevirtualization, W("JitNoteFailedExactDevirtualization"), 0)
#endif // debug
CONFIG_INTEGER(JitRandomlyCollect64BitCounts, W("JitRandomlyCollect64BitCounts"), 0) // Collect 64-bit counts randomly
// for some methods.
#endif // debug

// Devirtualize virtual calls with getExactClasses (NativeAOT only for now)
CONFIG_INTEGER(JitEnableExactDevirtualization, W("JitEnableExactDevirtualization"), 1)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5571,7 +5571,7 @@ HCIMPL2(void, JIT_DelegateProfile32, Object *obj, ICorJitInfo::HandleHistogram32
HCIMPLEND

// Version of helper above used when the count is 64-bit
HCIMPL3(void, JIT_DelegateProfile64, Object *obj, CORINFO_METHOD_HANDLE baseMethod, ICorJitInfo::HandleHistogram64* methodProfile)
HCIMPL2(void, JIT_DelegateProfile64, Object *obj, ICorJitInfo::HandleHistogram64* methodProfile)
{
FCALL_CONTRACT;
FC_GC_POLL_NOT_NEEDED();
Expand Down
9 changes: 5 additions & 4 deletions src/tests/Common/testenvironment.proj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
COMPlus_JitRandomGuardedDevirtualization;
COMPlus_JitRandomEdgeCounts;
COMPlus_JitRandomOnStackReplacement;
COMPlus_JitRandomlyCollect64BitCounts;
COMPlus_JitForceControlFlowGuard;
COMPlus_JitCFGUseDispatcher;
RunningIlasmRoundTrip
Expand Down Expand Up @@ -209,10 +210,10 @@
<TestEnvironment Include="dynamicpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" />
<TestEnvironment Include="fullpgo" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0"/>
<TestEnvironment Include="fullpgo_methodprofiling" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitDelegateProfiling="1" JitVTableProfiling="1" />
<TestEnvironment Include="fullpgo_random_gdv" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1"/>
<TestEnvironment Include="fullpgo_random_gdv_methodprofiling_only" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitClassProfiling="0" JitDelegateProfiling="1" JitVTableProfiling="1" />
<TestEnvironment Include="fullpgo_random_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomEdgeCounts="1"/>
<TestEnvironment Include="fullpgo_random_gdv_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomEdgeCounts="1"/>
<TestEnvironment Include="fullpgo_random_gdv" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomlyCollect64BitCounts="1" />
<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" />
<TestEnvironment Include="fullpgo_random_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomEdgeCounts="1" JitRandomlyCollect64BitCounts="1" />
<TestEnvironment Include="fullpgo_random_gdv_edge" TieredPGO="1" TieredCompilation="1" TC_QuickJitForLoops="1" ReadyToRun="0" JitRandomGuardedDevirtualization="1" JitRandomEdgeCounts="1" JitRandomlyCollect64BitCounts="1" />
<TestEnvironment Include="gcstandalone" Condition="'$(TargetsWindows)' == 'true'" GCName="clrgc.dll"/>
<TestEnvironment Include="gcstandalone" Condition="'$(TargetsWindows)' != 'true'" GCName="libclrgc.so"/>
<TestEnvironment Include="gcstandaloneserver" Condition="'$(TargetsWindows)' == 'true'" gcServer="1" GCName="clrgc.dll"/>
Expand Down