Search in sources :

Example 11 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class OptGenericGCMapIterator method setupIterator.

/**
 * Initialize the iterator for another stack frame scan
 * @param cm                The compiled method we are interested in
 * @param instructionOffset The place in the method where we currently are
 * @param framePtr          The current frame pointer
 */
@Override
public final void setupIterator(CompiledMethod cm, Offset instructionOffset, Address framePtr) {
    if (DEBUG) {
        VM.sysWriteln();
        VM.sysWrite("\t   ==========================");
        VM.sysWriteln();
        VM.sysWrite("Reference map request made");
        VM.sysWrite(" for machine code offset: ");
        VM.sysWrite(instructionOffset);
        VM.sysWriteln();
        VM.sysWrite("\tframePtr: ");
        VM.sysWrite(framePtr);
        VM.sysWriteln();
    }
    reset();
    // retrieve and save the corresponding OptMachineCodeMap for
    // this method and instructionOffset
    compiledMethod = (OptCompiledMethod) cm;
    map = compiledMethod.getMCMap();
    mapIndex = map.findGCMapIndex(instructionOffset);
    if (mapIndex == OptGCMap.ERROR) {
        if (instructionOffset.sLT(Offset.zero())) {
            VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with negative instructionOffset", instructionOffset);
        } else {
            Offset possibleLen = Offset.fromIntZeroExtend(cm.numberOfInstructions() << ArchConstants.getLogInstructionWidth());
            if (possibleLen.sLT(instructionOffset)) {
                VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with too big of an instructionOffset");
                VM.sysWriteln("offset is", instructionOffset);
                VM.sysWriteln(" bytes of machine code for method ", possibleLen);
            } else {
                VM.sysWriteln("OptGenericGCMapIterator.setupIterator called with apparently valid offset, but no GC map found!");
                VM.sysWrite("Method: ");
                VM.sysWrite(compiledMethod.getMethod());
                VM.sysWrite(", Machine Code (MC) Offset: ");
                VM.sysWriteln(instructionOffset);
                VM.sysFail("OptGenericMapIterator: findGCMapIndex failed\n");
            }
        }
        VM.sysWrite("Supposed method: ");
        VM.sysWrite(compiledMethod.getMethod());
        VM.sysWriteln();
        VM.sysWriteln("Base of its code array", Magic.objectAsAddress(cm.getEntryCodeArray()));
        Address ra = cm.getInstructionAddress(instructionOffset);
        VM.sysWriteln("Calculated actual return address is ", ra);
        CompiledMethod realCM = CompiledMethods.findMethodForInstruction(ra);
        if (realCM == null) {
            VM.sysWriteln("Unable to find compiled method corresponding to this return address");
        } else {
            VM.sysWrite("Found compiled method ");
            VM.sysWrite(realCM.getMethod());
            VM.sysWriteln(" whose code contains this return address");
        }
        VM.sysFail("OptGenericMapIterator: setupIterator failed\n");
    }
    // save the frame pointer
    this.framePtr = framePtr;
    if (DEBUG) {
        VM.sysWrite("\tMethod: ");
        VM.sysWrite(compiledMethod.getMethod());
        VM.sysWriteln();
        if (mapIndex == OptGCMap.NO_MAP_ENTRY) {
            VM.sysWriteln("... empty map found");
        } else {
            VM.sysWriteln("... found a map");
        }
        if (lookForMissedReferencesInSpills) {
            VM.sysWrite("FramePtr: ");
            VM.sysWrite(framePtr);
            VM.sysWrite("\tFirst Spill: ");
            VM.sysWrite(getFirstSpillLoc());
            VM.sysWrite("\tLast Spill: ");
            VM.sysWrite(getLastSpillLoc());
            VM.sysWriteln();
        }
    }
}
Also used : Address(org.vmmagic.unboxed.Address) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Offset(org.vmmagic.unboxed.Offset)

Example 12 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class MethodCountData method collectHotOptMethodsInternal.

/**
 * Recursive implementation of collectHotOptNMethods.
 * Exploit heap property.
 * Constraint: threshold has been converted into a count value by my caller!
 *
 * @param index count array index
 * @param collect vector used to collect output.
 * @param threshold hotness value above which the method is considered
 *                  to be hot. (0.0 to 1.0)
 * @param optLevel target opt level to look for.
 */
private void collectHotOptMethodsInternal(int index, List<HotMethodRecompilationEvent> collect, double threshold, int optLevel) {
    if (index < nextIndex) {
        if (counts[index] > threshold) {
            int cmid = cmids[index];
            CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
            if (cm == null) {
                // obsolete and deleted
                // free up this slot
                reset(cmid);
                // Visit new one in the slot
                collectHotOptMethodsInternal(index, collect, threshold, optLevel);
            } else {
                int compilerType = cm.getCompilerType();
                if (compilerType == CompiledMethod.OPT && ((OptCompiledMethod) cm).getOptLevel() == optLevel) {
                    double ns = counts[index];
                    collect.add(new HotMethodRecompilationEvent(cm, ns));
                }
                // Since I was hot enough, also consider my children.
                collectHotOptMethodsInternal(index * 2, collect, threshold, optLevel);
                collectHotOptMethodsInternal(index * 2 + 1, collect, threshold, optLevel);
            }
        }
    }
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 13 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class MethodCountData method report.

/**
 *  Print the counted (nonzero) methods.
 *  To get a sorted list, pipe the output through sort -n -r.
 */
@Override
public synchronized void report() {
    RVMThread.dumpLock.lockNoHandshake();
    VM.sysWriteln("Method counts: A total of " + totalCountsTaken + " samples");
    for (int i = 1; i < nextIndex; i++) {
        double percent = 100 * countsToHotness(counts[i]);
        CompiledMethod cm = CompiledMethods.getCompiledMethod(cmids[i]);
        VM.sysWrite(counts[i] + " (" + percent + "%) ");
        if (cm == null) {
            // Compiled Method Obsolete
            VM.sysWriteln("OBSOLETE");
        } else {
            if (cm.getCompilerType() == CompiledMethod.TRAP) {
                VM.sysWriteln("<Hardware Trap Frame>");
            } else {
                RVMMethod m = cm.getMethod();
                VM.sysWrite(m);
                if (m.getDeclaringClass().isInBootImage()) {
                    VM.sysWrite("\tBOOT");
                }
            }
            VM.sysWriteln();
        }
    }
    RVMThread.dumpLock.unlock();
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 14 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class MethodCountData method collectHotMethods.

/**
 * Collect the hot methods that have been compiled at the given opt level.
 *
 * @param optLevel  target opt level
 * @param threshold hotness value above which the method is considered to
 *                  be hot. (0.0 to 1.0)
 * @return a MethodCountSet containing an
 *            array of compiled methods and an array of their counts.
 */
public synchronized MethodCountSet collectHotMethods(int optLevel, double threshold) {
    if (DEBUG)
        validityCheck();
    ArrayList<HotMethodRecompilationEvent> collect = new ArrayList<HotMethodRecompilationEvent>();
    collectHotOptMethodsInternal(1, collect, hotnessToCounts(threshold), optLevel);
    // now package the data into the form the caller expects.
    int numHotMethods = collect.size();
    double[] numCounts = new double[numHotMethods];
    CompiledMethod[] hotMethods = new CompiledMethod[numHotMethods];
    for (int i = 0; i < numHotMethods; i++) {
        HotMethodEvent event = collect.get(i);
        hotMethods[i] = event.getCompiledMethod();
        numCounts[i] = event.getNumSamples();
    }
    return new MethodCountSet(hotMethods, numCounts);
}
Also used : HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) HotMethodEvent(org.jikesrvm.adaptive.controller.HotMethodEvent) ArrayList(java.util.ArrayList) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 15 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class MethodCountData method insertHotMethodsInternal.

/**
 * Recursive implementation of insertHotMethods. Exploit heap property.
 * Note threshold has been converted into a count value by my caller!
 *
 * @param index count array index
 * @param filterOptLevel filter out all methods already compiled at
 *                       this opt level (or higher)
 * @param threshold hotness value above which the method is considered
 *                  to be hot. (0.0 to 1.0)
 */
private void insertHotMethodsInternal(int index, int filterOptLevel, double threshold) {
    if (index < nextIndex) {
        if (counts[index] > threshold) {
            int cmid = cmids[index];
            CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
            if (cm == null) {
                // obsolete and deleted
                // free up this slot
                reset(cmid);
                // Visit new one in the slot
                insertHotMethodsInternal(index, filterOptLevel, threshold);
            } else {
                int compilerType = cm.getCompilerType();
                // opt compiled at filterOptLevel or higher.
                if (!(compilerType == CompiledMethod.TRAP || (compilerType == CompiledMethod.OPT && (((OptCompiledMethod) cm).getOptLevel() >= filterOptLevel)))) {
                    double ns = counts[index];
                    HotMethodRecompilationEvent event = new HotMethodRecompilationEvent(cm, ns);
                    Controller.controllerInputQueue.insert(ns, event);
                    AOSLogging.logger.controllerNotifiedForHotness(cm, ns);
                }
                // Since I was hot enough, also consider my children.
                insertHotMethodsInternal(index * 2, filterOptLevel, threshold);
                insertHotMethodsInternal(index * 2 + 1, filterOptLevel, threshold);
            }
        }
    }
}
Also used : HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

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