Search in sources :

Example 51 with CompiledMethod

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;
}
Also used : Address(org.vmmagic.unboxed.Address) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Offset(org.vmmagic.unboxed.Offset)

Example 52 with CompiledMethod

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;
}
Also used : CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 53 with CompiledMethod

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);
            }
        }
    }
}
Also used : ContextListener(org.jikesrvm.adaptive.measurements.listeners.ContextListener) Address(org.vmmagic.unboxed.Address) NullListener(org.jikesrvm.adaptive.measurements.listeners.NullListener) MethodListener(org.jikesrvm.adaptive.measurements.listeners.MethodListener) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 54 with CompiledMethod

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);
        }
    }
}
Also used : Address(org.vmmagic.unboxed.Address) MethodListener(org.jikesrvm.adaptive.measurements.listeners.MethodListener) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 55 with CompiledMethod

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();
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) ControllerPlan(org.jikesrvm.adaptive.controller.ControllerPlan) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Entrypoint(org.vmmagic.pragma.Entrypoint)

Aggregations

CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)97 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)56 NormalMethod (org.jikesrvm.classloader.NormalMethod)41 Test (org.junit.Test)33 OptOptions (org.jikesrvm.compilers.opt.OptOptions)32 Address (org.vmmagic.unboxed.Address)30 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)20 Offset (org.vmmagic.unboxed.Offset)20 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)19 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 RVMMethod (org.jikesrvm.classloader.RVMMethod)14 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)14 TypeReference (org.jikesrvm.classloader.TypeReference)13 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)13 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)13 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)10 RVMClass (org.jikesrvm.classloader.RVMClass)7