public final class MethodListener extends Listener
Samples are collected in a buffer. When sampleSize samples have been collected the listener's organizer is activated to process them.
Defines update's interface to be a compiled method identifier, CMID.
Modifier and Type | Field and Description |
---|---|
(package private) int |
numSamples
Number of samples taken so far
|
(package private) int[] |
samples
The sample buffer.
|
(package private) int |
sampleSize
Number of samples to be gathered before they are processed
|
Constructor and Description |
---|
MethodListener(int sampleSize) |
Modifier and Type | Method and Description |
---|---|
int |
getNumSamples() |
int[] |
getSamples() |
private void |
recordSample(int CMID)
This method records a sample containing the
CMID (compiled method ID)
passed. |
void |
report()
Entry point to dump what has been collected.
|
void |
reset()
Reset the listeners data structures in preparation of a new sampling
window.
|
void |
update(int cmid,
int callerCmid,
int whereFrom)
This method is called when a sample is taken.
|
activate, activateOrganizer, isActive, passivate, setOrganizer
int sampleSize
int numSamples
int[] samples
samples.length >= sampleSize
public MethodListener(int sampleSize)
sampleSize
- the initial sampleSize for the listenerpublic void update(int cmid, int callerCmid, int whereFrom)
cmid
represents the compiled method ID of the method
which was executing at the time of the sample. This method
bumps the counter and checks whether a threshold is reached.
NOTE: There can be multiple threads executing this method at the same time. We attempt to ensure that the resulting race conditions are safely handled, but make no guarentee that every sample is actually recorded.
cmid
- the compiled method ID to updatecallerCmid
- a compiled method id for the caller, -1 if nonewhereFrom
- Was this a yieldpoint in a PROLOGUE, BACKEDGE, or
EPILOGUE?private void recordSample(int CMID)
CMID
(compiled method ID)
passed. Since multiple threads may be taking samples concurrently,
we use fetchAndAdd to distribute indices into the buffer AND to record
when a sample is taken. (Thread 1 may get an earlier index, but complete
the insertion after Thread 2.)CMID
- compiled method ID to recordpublic void report()
Listener
public void reset()
Listener
public int[] getSamples()
public int getNumSamples()