}
template<typename T>
-FORCEINLINE static bool CheckSample(T index, size_t* sampleIndex)
+FORCEINLINE static bool CheckSample(T* pIndex, size_t* sampleIndex)
{
const unsigned S = ICorJitInfo::HandleHistogram32::SIZE;
const unsigned N = ICorJitInfo::HandleHistogram32::SAMPLE_INTERVAL;
static_assert_no_msg(N >= S);
static_assert_no_msg((std::is_same<T, uint32_t>::value || std::is_same<T, uint64_t>::value));
- // If table is not yet full, just add entries in.
+ // If table is not yet full, just add entries in
+ // and increment the table index.
//
+ T const index = *pIndex;
+
if (index < S)
{
*sampleIndex = static_cast<size_t>(index);
+ *pIndex = index + 1;
return true;
}
- unsigned x = HandleHistogramProfileRand();
+ unsigned const x = HandleHistogramProfileRand();
+
// N is the sampling window size,
// it should be larger than the table size.
//
VALIDATEOBJECTREF(objRef);
size_t sampleIndex;
- if (!CheckSample(classProfile->Count++, &sampleIndex) || objRef == NULL)
+ if (!CheckSample(&classProfile->Count, &sampleIndex) || objRef == NULL)
{
return;
}
VALIDATEOBJECTREF(objRef);
size_t sampleIndex;
- if (!CheckSample(classProfile->Count++, &sampleIndex) || objRef == NULL)
+ if (!CheckSample(&classProfile->Count, &sampleIndex) || objRef == NULL)
{
return;
}
VALIDATEOBJECTREF(objRef);
size_t methodSampleIndex;
- if (!CheckSample(methodProfile->Count++, &methodSampleIndex) || objRef == NULL)
+ if (!CheckSample(&methodProfile->Count, &methodSampleIndex) || objRef == NULL)
{
return;
}
VALIDATEOBJECTREF(objRef);
size_t methodSampleIndex;
- if (!CheckSample(methodProfile->Count++, &methodSampleIndex) || objRef == NULL)
+ if (!CheckSample(&methodProfile->Count, &methodSampleIndex) || objRef == NULL)
{
return;
}
VALIDATEOBJECTREF(objRef);
size_t methodSampleIndex;
- if (!CheckSample(methodProfile->Count++, &methodSampleIndex) || objRef == NULL)
+ if (!CheckSample(&methodProfile->Count, &methodSampleIndex) || objRef == NULL)
{
return;
}
VALIDATEOBJECTREF(objRef);
size_t methodSampleIndex;
- if (!CheckSample(methodProfile->Count++, &methodSampleIndex) || objRef == NULL)
+ if (!CheckSample(&methodProfile->Count, &methodSampleIndex) || objRef == NULL)
{
return;
}