@@ -38,7 +38,10 @@ struct LikelyClassMethodHistogramEntry
3838//
3939struct LikelyClassMethodHistogram
4040{
41- LikelyClassMethodHistogram (INT_PTR* histogramEntries, unsigned entryCount);
41+ LikelyClassMethodHistogram (INT_PTR* histogramEntries, unsigned entryCount, bool int32Data = false );
42+
43+ template <typename ElemType>
44+ void LikelyClassMethodHistogramInner (ElemType* histogramEntries, unsigned entryCount);
4245
4346 // Sum of counts from all entries in the histogram. This includes "unknown" entries which are not captured in
4447 // m_histogram
@@ -61,8 +64,22 @@ struct LikelyClassMethodHistogram
6164// Arguments:
6265// histogramEntries - pointer to the table portion of a ClassProfile* object (see corjit.h)
6366// entryCount - number of entries in the table to examine
67+ // int32Data - true if table entries are 32 bits
6468//
65- LikelyClassMethodHistogram::LikelyClassMethodHistogram (INT_PTR* histogramEntries, unsigned entryCount)
69+ LikelyClassMethodHistogram::LikelyClassMethodHistogram (INT_PTR* histogramEntries, unsigned entryCount, bool int32Data)
70+ {
71+ if (int32Data)
72+ {
73+ LikelyClassMethodHistogramInner<int >((int *)histogramEntries, entryCount);
74+ }
75+ else
76+ {
77+ LikelyClassMethodHistogramInner<INT_PTR>(histogramEntries, entryCount);
78+ }
79+ }
80+
81+ template <typename ElemType>
82+ void LikelyClassMethodHistogram::LikelyClassMethodHistogramInner (ElemType* histogramEntries, unsigned entryCount)
6683{
6784 m_unknownHandles = 0 ;
6885 m_totalCount = 0 ;
@@ -76,8 +93,7 @@ LikelyClassMethodHistogram::LikelyClassMethodHistogram(INT_PTR* histogramEntries
7693 }
7794
7895 m_totalCount++;
79-
80- INT_PTR currentEntry = histogramEntries[k];
96+ INT_PTR currentEntry = (INT_PTR)histogramEntries[k];
8197
8298 bool found = false ;
8399 unsigned h = 0 ;
@@ -385,15 +401,18 @@ extern "C" DLLEXPORT UINT32 WINAPI getLikelyValues(LikelyValueRecord*
385401 continue ;
386402
387403 // We currently re-use existing infrastructure for type handles for simplicity.
388-
389- const bool isHistogramCount =
390- (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount) ||
404+ //
405+ const bool isIntHistogramCount =
406+ (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount);
407+ const bool isLongHistogramCount =
391408 (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogramLongCount);
409+ const bool isHistogramCount = isIntHistogramCount || isLongHistogramCount;
392410
393411 if (isHistogramCount && (schema[i].Count == 1 ) && ((i + 1 ) < countSchemaItems) &&
394412 (schema[i + 1 ].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::ValueHistogram))
395413 {
396- LikelyClassMethodHistogram h ((INT_PTR*)(pInstrumentationData + schema[i + 1 ].Offset ), schema[i + 1 ].Count );
414+ LikelyClassMethodHistogram h ((INT_PTR*)(pInstrumentationData + schema[i + 1 ].Offset ), schema[i + 1 ].Count ,
415+ isIntHistogramCount);
397416 LikelyClassMethodHistogramEntry sortedEntries[HISTOGRAM_MAX_SIZE_COUNT];
398417
399418 if (h.countHistogramElements == 0 )
0 commit comments