Search in sources :

Example 1 with ContextListener

use of org.jikesrvm.adaptive.measurements.listeners.ContextListener in project JikesRVM by JikesRVM.

the class RuntimeMeasurements method takeCBSCallSample.

/**
 * Called from Thread.yieldpoint when it is time to take a CBS call 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 takeCBSCallSample(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()) {
    // drop sample
    } else {
        // Notify all registered listeners
        for (ContextListener listener : cbsContextListeners) {
            if (listener.isActive()) {
                listener.update(ypTakenInFP, whereFrom);
            }
        }
    }
}
Also used : ContextListener(org.jikesrvm.adaptive.measurements.listeners.ContextListener) Address(org.vmmagic.unboxed.Address) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Uninterruptible(org.vmmagic.pragma.Uninterruptible)

Example 2 with ContextListener

use of org.jikesrvm.adaptive.measurements.listeners.ContextListener 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)2 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)2 Uninterruptible (org.vmmagic.pragma.Uninterruptible)2 Address (org.vmmagic.unboxed.Address)2 MethodListener (org.jikesrvm.adaptive.measurements.listeners.MethodListener)1 NullListener (org.jikesrvm.adaptive.measurements.listeners.NullListener)1