Search in sources :

Example 1 with NullListener

use of org.jikesrvm.adaptive.measurements.listeners.NullListener 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)

Aggregations

ContextListener (org.jikesrvm.adaptive.measurements.listeners.ContextListener)1 MethodListener (org.jikesrvm.adaptive.measurements.listeners.MethodListener)1 NullListener (org.jikesrvm.adaptive.measurements.listeners.NullListener)1 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)1 Uninterruptible (org.vmmagic.pragma.Uninterruptible)1 Address (org.vmmagic.unboxed.Address)1