Search in sources :

Example 1 with YieldpointCounterData

use of org.jikesrvm.adaptive.measurements.instrumentation.YieldpointCounterData in project JikesRVM by JikesRVM.

the class InsertYieldpointCounters method perform.

/**
 * counters after all yieldpoint instructions
 *
 * @param ir the governing IR
 */
@Override
public final void perform(IR ir) {
    // the boot image, or when instrumentation is disabled
    if (!ir.method.isInterruptible() || ir.method.getDeclaringClass().isInBootImage() || !Instrumentation.instrumentationEnabled()) {
        return;
    }
    YieldpointCounterData data = AOSDatabase.yieldpointCounterData;
    if (InsertYieldpointCounters.DEBUG) {
        VM.sysWriteln("InsertYieldpointCounters.perform() " + ir.method);
    }
    // For each yieldpoint, insert a counter.
    for (Enumeration<BasicBlock> bbe = ir.getBasicBlocks(); bbe.hasMoreElements(); ) {
        BasicBlock bb = bbe.nextElement();
        if (InsertYieldpointCounters.DEBUG) {
            VM.sysWriteln("Considering basic block " + bb.toString());
            bb.printExtended();
        }
        Instruction i = bb.firstInstruction();
        while (i != null && i != bb.lastInstruction()) {
            if (i.operator() == YIELDPOINT_PROLOGUE || i.operator() == YIELDPOINT_EPILOGUE || i.operator() == YIELDPOINT_BACKEDGE) {
                String prefix = yieldpointPrefix(i.operator());
                double incrementValue = 1.0;
                if (i.operator() == YIELDPOINT_EPILOGUE) {
                    prefix = "METHOD ENTRY ";
                } else if (i.operator() == YIELDPOINT_PROLOGUE) {
                    prefix = "METHOD EXIT ";
                } else {
                    prefix = "BACKEDGE ";
                    incrementValue = 1.0;
                }
                // Create an instruction to increment the counter for this
                // method.  By appending the prefix and method name, it
                // maintains a separate counter for each method, and
                // separates between method entry and backedges.
                Instruction counterInst = data.getCounterInstructionForEvent(prefix + ir.method.toString(), incrementValue);
                // Insert the new instruction into the code order
                i.insertAfter(counterInst);
            }
            i = i.nextInstructionInCodeOrder();
        }
    }
}
Also used : YieldpointCounterData(org.jikesrvm.adaptive.measurements.instrumentation.YieldpointCounterData) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) Instruction(org.jikesrvm.compilers.opt.ir.Instruction)

Aggregations

YieldpointCounterData (org.jikesrvm.adaptive.measurements.instrumentation.YieldpointCounterData)1 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)1 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)1