use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class OptGenericGCMapIterator method setupIterator.
/**
* Initialize the iterator for another stack frame scan
* @param cm The compiled method we are interested in
* @param instructionOffset The place in the method where we currently are
* @param framePtr The current frame pointer
*/
@Override
public final void setupIterator(CompiledMethod cm, Offset instructionOffset, Address framePtr) {
if (DEBUG) {
VM.sysWriteln();
VM.sysWrite("\t ==========================");
VM.sysWriteln();
VM.sysWrite("Reference map request made");
VM.sysWrite(" for machine code offset: ");
VM.sysWrite(instructionOffset);
VM.sysWriteln();
VM.sysWrite("\tframePtr: ");
VM.sysWrite(framePtr);
VM.sysWriteln();
}
reset();
// retrieve and save the corresponding OptMachineCodeMap for
// this method and instructionOffset
compiledMethod = (OptCompiledMethod) cm;
map = compiledMethod.getMCMap();
mapIndex = map.findGCMapIndex(instructionOffset);
if (mapIndex == OptGCMap.ERROR) {
if (instructionOffset.sLT(Offset.zero())) {
VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with negative instructionOffset", instructionOffset);
} else {
Offset possibleLen = Offset.fromIntZeroExtend(cm.numberOfInstructions() << ArchConstants.getLogInstructionWidth());
if (possibleLen.sLT(instructionOffset)) {
VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with too big of an instructionOffset");
VM.sysWriteln("offset is", instructionOffset);
VM.sysWriteln(" bytes of machine code for method ", possibleLen);
} else {
VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with apparently valid offset, but no GC map found!");
VM.sysWrite("Method: ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWrite(", Machine Code (MC) Offset: ");
VM.sysWriteln(instructionOffset);
VM.sysFail("OptGenericMapIterator: findGCMapIndex failed\n");
}
}
VM.sysWrite("Supposed method: ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWriteln();
VM.sysWriteln("Base of its code array", Magic.objectAsAddress(cm.getEntryCodeArray()));
Address ra = cm.getInstructionAddress(instructionOffset);
VM.sysWriteln("Calculated actual return address is ", ra);
CompiledMethod realCM = CompiledMethods.findMethodForInstruction(ra);
if (realCM == null) {
VM.sysWriteln("Unable to find compiled method corresponding to this return address");
} else {
VM.sysWrite("Found compiled method ");
VM.sysWrite(realCM.getMethod());
VM.sysWriteln(" whose code contains this return address");
}
VM.sysFail("OptGenericMapIterator: setupIterator failed\n");
}
// save the frame pointer
this.framePtr = framePtr;
if (DEBUG) {
VM.sysWrite("\tMethod: ");
VM.sysWrite(compiledMethod.getMethod());
VM.sysWriteln();
if (mapIndex == OptGCMap.NO_MAP_ENTRY) {
VM.sysWriteln("... empty map found");
} else {
VM.sysWriteln("... found a map");
}
if (lookForMissedReferencesInSpills) {
VM.sysWrite("FramePtr: ");
VM.sysWrite(framePtr);
VM.sysWrite("\tFirst Spill: ");
VM.sysWrite(getFirstSpillLoc());
VM.sysWrite("\tLast Spill: ");
VM.sysWrite(getLastSpillLoc());
VM.sysWriteln();
}
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class MethodCountData method collectHotOptMethodsInternal.
/**
* Recursive implementation of collectHotOptNMethods.
* Exploit heap property.
* Constraint: threshold has been converted into a count value by my caller!
*
* @param index count array index
* @param collect vector used to collect output.
* @param threshold hotness value above which the method is considered
* to be hot. (0.0 to 1.0)
* @param optLevel target opt level to look for.
*/
private void collectHotOptMethodsInternal(int index, List<HotMethodRecompilationEvent> collect, double threshold, int optLevel) {
if (index < nextIndex) {
if (counts[index] > threshold) {
int cmid = cmids[index];
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
if (cm == null) {
// obsolete and deleted
// free up this slot
reset(cmid);
// Visit new one in the slot
collectHotOptMethodsInternal(index, collect, threshold, optLevel);
} else {
int compilerType = cm.getCompilerType();
if (compilerType == CompiledMethod.OPT && ((OptCompiledMethod) cm).getOptLevel() == optLevel) {
double ns = counts[index];
collect.add(new HotMethodRecompilationEvent(cm, ns));
}
// Since I was hot enough, also consider my children.
collectHotOptMethodsInternal(index * 2, collect, threshold, optLevel);
collectHotOptMethodsInternal(index * 2 + 1, collect, threshold, optLevel);
}
}
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class MethodCountData method report.
/**
* Print the counted (nonzero) methods.
* To get a sorted list, pipe the output through sort -n -r.
*/
@Override
public synchronized void report() {
RVMThread.dumpLock.lockNoHandshake();
VM.sysWriteln("Method counts: A total of " + totalCountsTaken + " samples");
for (int i = 1; i < nextIndex; i++) {
double percent = 100 * countsToHotness(counts[i]);
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmids[i]);
VM.sysWrite(counts[i] + " (" + percent + "%) ");
if (cm == null) {
// Compiled Method Obsolete
VM.sysWriteln("OBSOLETE");
} else {
if (cm.getCompilerType() == CompiledMethod.TRAP) {
VM.sysWriteln("<Hardware Trap Frame>");
} else {
RVMMethod m = cm.getMethod();
VM.sysWrite(m);
if (m.getDeclaringClass().isInBootImage()) {
VM.sysWrite("\tBOOT");
}
}
VM.sysWriteln();
}
}
RVMThread.dumpLock.unlock();
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class MethodCountData method collectHotMethods.
/**
* Collect the hot methods that have been compiled at the given opt level.
*
* @param optLevel target opt level
* @param threshold hotness value above which the method is considered to
* be hot. (0.0 to 1.0)
* @return a MethodCountSet containing an
* array of compiled methods and an array of their counts.
*/
public synchronized MethodCountSet collectHotMethods(int optLevel, double threshold) {
if (DEBUG)
validityCheck();
ArrayList<HotMethodRecompilationEvent> collect = new ArrayList<HotMethodRecompilationEvent>();
collectHotOptMethodsInternal(1, collect, hotnessToCounts(threshold), optLevel);
// now package the data into the form the caller expects.
int numHotMethods = collect.size();
double[] numCounts = new double[numHotMethods];
CompiledMethod[] hotMethods = new CompiledMethod[numHotMethods];
for (int i = 0; i < numHotMethods; i++) {
HotMethodEvent event = collect.get(i);
hotMethods[i] = event.getCompiledMethod();
numCounts[i] = event.getNumSamples();
}
return new MethodCountSet(hotMethods, numCounts);
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class MethodCountData method insertHotMethodsInternal.
/**
* Recursive implementation of insertHotMethods. Exploit heap property.
* Note threshold has been converted into a count value by my caller!
*
* @param index count array index
* @param filterOptLevel filter out all methods already compiled at
* this opt level (or higher)
* @param threshold hotness value above which the method is considered
* to be hot. (0.0 to 1.0)
*/
private void insertHotMethodsInternal(int index, int filterOptLevel, double threshold) {
if (index < nextIndex) {
if (counts[index] > threshold) {
int cmid = cmids[index];
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
if (cm == null) {
// obsolete and deleted
// free up this slot
reset(cmid);
// Visit new one in the slot
insertHotMethodsInternal(index, filterOptLevel, threshold);
} else {
int compilerType = cm.getCompilerType();
// opt compiled at filterOptLevel or higher.
if (!(compilerType == CompiledMethod.TRAP || (compilerType == CompiledMethod.OPT && (((OptCompiledMethod) cm).getOptLevel() >= filterOptLevel)))) {
double ns = counts[index];
HotMethodRecompilationEvent event = new HotMethodRecompilationEvent(cm, ns);
Controller.controllerInputQueue.insert(ns, event);
AOSLogging.logger.controllerNotifiedForHotness(cm, ns);
}
// Since I was hot enough, also consider my children.
insertHotMethodsInternal(index * 2, filterOptLevel, threshold);
insertHotMethodsInternal(index * 2 + 1, filterOptLevel, threshold);
}
}
}
}
Aggregations