Search in sources :

Example 1 with MethodListener

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

the class MethodSampleOrganizer method thresholdReached.

@Override
void thresholdReached() {
    AOSLogging.logger.organizerThresholdReached();
    int numSamples = ((MethodListener) listener).getNumSamples();
    int[] samples = ((MethodListener) listener).getSamples();
    // (1) Update the global (cumulative) sample data
    Controller.methodSamples.update(samples, numSamples);
    // (2) Remove duplicates from samples buffer.
    // NOTE: This is a dirty trick and may be ill-advised.
    // Rather than copying the unique samples into a different buffer
    // we treat samples as if it was a scratch buffer.
    // NOTE: This is worse case O(numSamples^2) but we expect a
    // significant number of duplicates, so it's probably better than
    // the other obvious alternative (sorting samples).
    int uniqueIdx = 1;
    outer: for (int i = 1; i < numSamples; i++) {
        int cur = samples[i];
        for (int j = 0; j < uniqueIdx; j++) {
            if (cur == samples[j])
                continue outer;
        }
        samples[uniqueIdx++] = cur;
    }
    // then report it to the controller.
    for (int i = 0; i < uniqueIdx; i++) {
        int cmid = samples[i];
        double ns = Controller.methodSamples.getData(cmid);
        CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
        if (cm != null) {
            // not already obsoleted
            int compilerType = cm.getCompilerType();
            // compiled at filterOptLevel or higher.
            if (!(compilerType == CompiledMethod.TRAP || (compilerType == CompiledMethod.OPT && (((OptCompiledMethod) cm).getOptLevel() >= filterOptLevel)))) {
                HotMethodRecompilationEvent event = new HotMethodRecompilationEvent(cm, ns);
                Controller.controllerInputQueue.insert(ns, event);
                AOSLogging.logger.controllerNotifiedForHotness(cm, ns);
            }
        }
    }
}
Also used : HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) MethodListener(org.jikesrvm.adaptive.measurements.listeners.MethodListener) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 2 with MethodListener

use of org.jikesrvm.adaptive.measurements.listeners.MethodListener 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 3 with MethodListener

use of org.jikesrvm.adaptive.measurements.listeners.MethodListener 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 4 with MethodListener

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

the class MethodSampleOrganizer method initialize.

/**
 * Initialization: set up data structures and sampling objects.
 * <p>
 * Uses either timer based sampling or counter based sampling,
 * depending on {@link Controller#options}.
 */
@Override
public void initialize() {
    int numSamples = Controller.options.METHOD_SAMPLE_SIZE * RVMThread.availableProcessors;
    if (Controller.options.mlCBS()) {
        numSamples *= VM.CBSMethodSamplesPerTick;
    }
    MethodListener methodListener = new MethodListener(numSamples);
    listener = methodListener;
    listener.setOrganizer(this);
    if (Controller.options.mlTimer()) {
        RuntimeMeasurements.installTimerMethodListener(methodListener);
    } else if (Controller.options.mlCBS()) {
        RuntimeMeasurements.installCBSMethodListener(methodListener);
    } else {
        if (VM.VerifyAssertions)
            VM._assert(VM.NOT_REACHED, "Unexpected value of method_listener_trigger");
    }
}
Also used : MethodListener(org.jikesrvm.adaptive.measurements.listeners.MethodListener)

Example 5 with MethodListener

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

the class AccumulatingMethodSampleOrganizer method initialize.

/**
 * Initialization: set up data structures and sampling objects.
 * <p>
 * Uses either timer based sampling or counter based sampling,
 * depending on {@link Controller#options}.
 */
@Override
public void initialize() {
    data = new MethodCountData();
    new AsyncReporter().start();
    int numSamples = Controller.options.METHOD_SAMPLE_SIZE * RVMThread.availableProcessors;
    if (Controller.options.mlCBS()) {
        numSamples *= VM.CBSMethodSamplesPerTick;
    }
    MethodListener methodListener = new MethodListener(numSamples);
    listener = methodListener;
    listener.setOrganizer(this);
    if (Controller.options.mlTimer()) {
        RuntimeMeasurements.installTimerMethodListener(methodListener);
    } else if (Controller.options.mlCBS()) {
        RuntimeMeasurements.installCBSMethodListener(methodListener);
    } else {
        if (VM.VerifyAssertions)
            VM._assert(VM.NOT_REACHED, "Unexpected value of method_listener_trigger");
    }
}
Also used : MethodCountData(org.jikesrvm.adaptive.database.methodsamples.MethodCountData) MethodListener(org.jikesrvm.adaptive.measurements.listeners.MethodListener)

Aggregations

MethodListener (org.jikesrvm.adaptive.measurements.listeners.MethodListener)5 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)3 Uninterruptible (org.vmmagic.pragma.Uninterruptible)2 Address (org.vmmagic.unboxed.Address)2 HotMethodRecompilationEvent (org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent)1 MethodCountData (org.jikesrvm.adaptive.database.methodsamples.MethodCountData)1 ContextListener (org.jikesrvm.adaptive.measurements.listeners.ContextListener)1 NullListener (org.jikesrvm.adaptive.measurements.listeners.NullListener)1 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)1