public final class MethodCountData extends Object implements Reportable
| Modifier and Type | Field and Description |
|---|---|
private int[] |
cmids
Maps count array index to compiled method id.
|
private double[] |
counts
Count array: counts how many times a method is executed.
|
private static boolean |
DEBUG |
private int[] |
map
Maps compiled method id to count array index
|
private int |
nextIndex
Next available count array entry.
|
private double |
totalCountsTaken
Sum of values in count array.
|
| Constructor and Description |
|---|
MethodCountData()
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
augmentData(int cmid,
double addVal)
Augment the data associated with a given cmid by the specified number of samples
|
MethodCountSet |
collectHotMethods(int optLevel,
double threshold)
Collect the hot methods that have been compiled at the given opt level.
|
private void |
collectHotOptMethodsInternal(int index,
List<HotMethodRecompilationEvent> collect,
double threshold,
int optLevel)
Recursive implementation of collectHotOptNMethods.
|
private double |
countsToHotness(double numCounts)
Convert a value to a [0.0...1.0] fractional hotness value
|
private int |
findHeapIdx(int cmid)
Finds the index that is already being used to hold the counts for cmid.
|
private int |
findOrCreateHeapIdx(int cmid)
Either find the index that is already being used to hold the counts
for cmid or allocate a new entry in the heap for cmid.
|
double |
getData(int cmid) |
double |
getTotalNumberOfSamples() |
private void |
growHeap()
Increase the size of the count's backing arrays
|
private void |
growHeapMap(int cmid)
Grow the map to be at least as large as would be required to map cmid
|
private void |
heapifyDown(int index)
Restore the heap property after decreasing a count array entry's value
|
private void |
heapifyUp(int index)
Restore the heap property after increasing a count array entry's value
|
private double |
hotnessToCounts(double hotness)
Convert from a [0.0...1.0] hotness value to the number of counts
that represents that fraction of hotness
|
private void |
initialize()
Reset fields.
|
void |
insertHotMethods(int filterOptLevel,
double threshold)
Enqueue events describing the "hot" methods on the organizer's event queue.
|
private void |
insertHotMethodsInternal(int index,
int filterOptLevel,
double threshold)
Recursive implementation of insertHotMethods.
|
void |
report()
Print the counted (nonzero) methods.
|
void |
reset()
Reset (clear) the method counts
|
void |
reset(int cmid)
Reset (set to 0.0) the count for a given compiled method id.
|
private void |
swap(int i,
int j)
Swap the heap entries at i and j.
|
void |
update(int[] countBuffer,
int numCounts)
Drain a buffer of compiled method id's and update the count array.
|
void |
update(int cmid,
double numCounts)
Increment the count for a compiled method id.
|
private void |
validityCheck()
Validate that internal fields are consistent.
|
private static final boolean DEBUG
private double totalCountsTaken
private double[] counts
private int[] cmids
private int[] map
private int nextIndex
public MethodCountData()
private void initialize()
public void update(int[] countBuffer, int numCounts)
countBuffer - a buffer of compiled method id'snumCounts - the number of valid entries in the bufferpublic void update(int cmid, double numCounts)
cmid - compiled method idnumCounts - number of countspublic void report()
report in interface Reportablepublic double getTotalNumberOfSamples()
public void reset()
reset in interface Reportablepublic double getData(int cmid)
cmid - compiled method idpublic void reset(int cmid)
cmid - compiled method idpublic void augmentData(int cmid, double addVal)
cmid - compiled method idaddVal - samples to addpublic void insertHotMethods(int filterOptLevel, double threshold)
filterOptLevel - filter out all methods already compiled at
this opt level (or higher)threshold - hotness value above which the method is considered
to be hot. (0.0 to 1.0)public MethodCountSet collectHotMethods(int optLevel, double threshold)
optLevel - target opt levelthreshold - hotness value above which the method is considered to
be hot. (0.0 to 1.0)private double hotnessToCounts(double hotness)
hotness - a value [0.0...1.0]private double countsToHotness(double numCounts)
numCounts - number of countsprivate void insertHotMethodsInternal(int index, int filterOptLevel, double threshold)
index - count array indexfilterOptLevel - filter out all methods already compiled at
this opt level (or higher)threshold - hotness value above which the method is considered
to be hot. (0.0 to 1.0)private void collectHotOptMethodsInternal(int index, List<HotMethodRecompilationEvent> collect, double threshold, int optLevel)
index - count array indexcollect - vector used to collect output.threshold - hotness value above which the method is considered
to be hot. (0.0 to 1.0)optLevel - target opt level to look for.private int findOrCreateHeapIdx(int cmid)
cmid - compiled method idprivate int findHeapIdx(int cmid)
cmid - compiled method idprivate void growHeapMap(int cmid)
cmid - compiled method idprivate void growHeap()
private void heapifyUp(int index)
index - of count array entryprivate void heapifyDown(int index)
index - of count array entryprivate void swap(int i, int j)
i - count array indexj - count array indexprivate void validityCheck()