use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class OSRListener method checkForOSRPromotion.
public static boolean checkForOSRPromotion(int whereFrom, Address yieldpointServiceMethodFP) {
if (RVMThread.getCurrentThread().isSystemThread())
return false;
if (whereFrom != RVMThread.BACKEDGE)
return false;
// See if we are at a loop backedge in an outdated baseline compiled method
Address fp = yieldpointServiceMethodFP;
fp = Magic.getCallerFramePointer(fp);
int ypTakenInCMID = Magic.getCompiledMethodID(fp);
CompiledMethod ypTakenInCM = CompiledMethods.getCompiledMethod(ypTakenInCMID);
if (ypTakenInCM.isOutdated() && ypTakenInCM.getCompilerType() == CompiledMethod.BASELINE) {
Address tsFromFP = yieldpointServiceMethodFP;
Address realFP = Magic.getCallerFramePointer(tsFromFP);
Address stackbeg = Magic.objectAsAddress(RVMThread.getCurrentThread().getStack());
Offset tsFromFPoff = tsFromFP.diff(stackbeg);
Offset realFPoff = realFP.diff(stackbeg);
OnStackReplacementTrigger.trigger(ypTakenInCMID, tsFromFPoff, realFPoff, whereFrom);
return true;
}
return false;
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class ControllerPlan method doRecompile.
/**
* This method will recompile the method designated by the controller plan
* {@link #getCompPlan}. It also
* <ol>
* <li>credits the samples associated with the old compiled method
* ID to the new method ID and clears the old value.
* <li>clears inlining information
* <li>updates the status of the controller plan
* </ol>
*
* @return {@code null} if the compilation was aborted, the new compiled
* method otherwise
*/
public CompiledMethod doRecompile() {
CompilationPlan cp = getCompPlan();
setTimeInitiated(Controller.controllerClock);
AOSLogging.logger.recompilationStarted(cp);
if (cp.options.PRINT_METHOD) {
VM.sysWriteln("-oc:O" + cp.options.getOptLevel());
}
// Compile the method.
int newCMID = RuntimeCompiler.recompileWithOpt(cp);
int prevCMID = getPrevCMID();
if (Controller.options.sampling()) {
// transfer the samples from the old CMID to the new CMID.
// scale the number of samples down by the expected speedup
// in the newly compiled method.
double expectedSpeedup = getExpectedSpeedup();
double oldNumSamples = Controller.methodSamples.getData(prevCMID);
double newNumSamples = oldNumSamples / expectedSpeedup;
Controller.methodSamples.reset(prevCMID);
if (newCMID > -1) {
Controller.methodSamples.augmentData(newCMID, newNumSamples);
}
}
// set the status of the plan accordingly
if (newCMID != -1) {
setStatus(ControllerPlan.COMPLETED);
} else {
setStatus(ControllerPlan.ABORTED_COMPILATION_ERROR);
}
setCMID(newCMID);
setTimeCompleted(Controller.controllerClock);
CompiledMethod cm = newCMID == -1 ? null : CompiledMethods.getCompiledMethod(newCMID);
if (newCMID == -1) {
AOSLogging.logger.recompilationAborted(cp);
} else {
AOSLogging.logger.recompilationCompleted(cp);
AOSLogging.logger.recordCompileTime(cm, getExpectedCompilationTime());
}
if (Controller.options.ENABLE_ADVICE_GENERATION && (newCMID != -1)) {
AOSGenerator.reCompilationWithOpt(cp);
}
return cm;
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class RuntimeMeasurements method takeTimerSample.
/**
* Called from Thread.yieldpoint every time it is invoked due to
* a timer interrupt.
*
* @param whereFrom source of the yieldpoint (e.g. backedge)
* @param yieldpointServiceMethodFP the frame pointer of the service
* method that is responsible for handling the yieldpoint
*/
@Uninterruptible
public static void takeTimerSample(int whereFrom, Address yieldpointServiceMethodFP) {
// We use timer ticks as a rough approximation of time.
// TODO: kill controller clock in favor of reportedTimerTicks
// PNT: huh?
Controller.controllerClock++;
// method that took yieldpoint
Address ypTakenInFP = Magic.getCallerFramePointer(yieldpointServiceMethodFP);
// Get the cmid for the method in which the yieldpoint was taken.
int ypTakenInCMID = Magic.getCompiledMethodID(ypTakenInFP);
// Get the cmid for that method's caller.
Address ypTakenInCallerFP = Magic.getCallerFramePointer(ypTakenInFP);
int ypTakenInCallerCMID = Magic.getCompiledMethodID(ypTakenInCallerFP);
// Determine if ypTakenInCallerCMID corresponds to a real Java stackframe.
// If one of the following conditions is detected, set ypTakenInCallerCMID to -1
// Caller is out-of-line assembly (no RVMMethod object) or top-of-stack psuedo-frame
// Caller is a native method
CompiledMethod ypTakenInCM = CompiledMethods.getCompiledMethod(ypTakenInCMID);
if (ypTakenInCallerCMID == StackFrameLayout.getInvisibleMethodID() || ypTakenInCM.getMethod().getDeclaringClass().hasBridgeFromNativeAnnotation()) {
ypTakenInCallerCMID = -1;
}
// Notify all registered listeners
for (NullListener aNl : timerNullListeners) {
if (aNl.isActive()) {
aNl.update(whereFrom);
}
}
for (MethodListener aMl : timerMethodListeners) {
if (aMl.isActive()) {
aMl.update(ypTakenInCMID, ypTakenInCallerCMID, whereFrom);
}
}
if (ypTakenInCallerCMID != -1) {
for (ContextListener aCl : timerContextListeners) {
if (aCl.isActive()) {
aCl.update(ypTakenInFP, whereFrom);
}
}
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class RuntimeMeasurements method takeCBSMethodSample.
/**
* Called from Thread.yieldpoint when it is time to take a CBS method sample.
*
* @param whereFrom source of the yieldpoint (e.g. backedge)
* @param yieldpointServiceMethodFP the frame pointer of the service
* method that is responsible for handling the yieldpoint
*/
@Uninterruptible
public static void takeCBSMethodSample(int whereFrom, Address yieldpointServiceMethodFP) {
// method that took yieldpoint
Address ypTakenInFP = Magic.getCallerFramePointer(yieldpointServiceMethodFP);
// Get the cmid for the method in which the yieldpoint was taken.
int ypTakenInCMID = Magic.getCompiledMethodID(ypTakenInFP);
// Get the cmid for that method's caller.
Address ypTakenInCallerFP = Magic.getCallerFramePointer(ypTakenInFP);
int ypTakenInCallerCMID = Magic.getCompiledMethodID(ypTakenInCallerFP);
// Determine if ypTakenInCallerCMID corresponds to a real Java stackframe.
// If one of the following conditions is detected, set ypTakenInCallerCMID to -1
// Caller is out-of-line assembly (no RVMMethod object) or top-of-stack psuedo-frame
// Caller is a native method
CompiledMethod ypTakenInCM = CompiledMethods.getCompiledMethod(ypTakenInCMID);
if (ypTakenInCallerCMID == StackFrameLayout.getInvisibleMethodID() || ypTakenInCM.getMethod().getDeclaringClass().hasBridgeFromNativeAnnotation()) {
ypTakenInCallerCMID = -1;
}
// Notify all registered listeners
for (MethodListener methodListener : cbsMethodListeners) {
if (methodListener.isActive()) {
methodListener.update(ypTakenInCMID, ypTakenInCallerCMID, whereFrom);
}
}
}
use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.
the class InvocationCounts method counterTripped.
/**
* Called from baseline compiled code when a method's invocation counter
* becomes negative and thus must be handled
*
* @param id the compiled method id
*/
@Entrypoint
static synchronized void counterTripped(int id) {
// set counter to max int to avoid lots of redundant calls.
counts[id] = 0x7fffffff;
if (processed[id])
return;
processed[id] = true;
CompiledMethod cm = CompiledMethods.getCompiledMethod(id);
if (cm == null)
return;
if (VM.VerifyAssertions)
VM._assert(cm.getCompilerType() == CompiledMethod.BASELINE);
NormalMethod m = (NormalMethod) cm.getMethod();
CompilationPlan compPlan = new CompilationPlan(m, _optPlan, null, _options);
ControllerPlan cp = // 2.0 is a bogus number....
new ControllerPlan(compPlan, Controller.controllerClock, id, 2.0, 2.0, 2.0);
cp.execute();
}
Aggregations