Search in sources :

Example 46 with RVMMethod

use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.

the class BarrierSize method methodInstructionCount.

private static int methodInstructionCount(String name, Class<?>... parameterTypes) throws SecurityException, NoSuchMethodException {
    Method m = thisClass.getDeclaredMethod(name, parameterTypes);
    RVMMethod internalMethod = java.lang.reflect.JikesRVMSupport.getMethodOf(m);
    internalMethod.compile();
    CompiledMethod compiledMethod = internalMethod.getCurrentCompiledMethod();
    // If you really care, count the instructions by hand!
    return compiledMethod.numberOfInstructions() - emptySize;
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) RVMMethod(org.jikesrvm.classloader.RVMMethod) Method(java.lang.reflect.Method) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 47 with RVMMethod

use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.

the class InlineAllocation method main.

/**
 * Force compilation of each of the methods and report on the size
 * of the generated machine code.
 */
public static void main(String[] args) throws Exception {
    Class<?> clazz = Class.forName("InlineAllocation");
    Method trivialJ = clazz.getDeclaredMethod("trivial", new Class[] { clazz });
    Method alloc1J = clazz.getDeclaredMethod("alloc1", (Class[]) null);
    Method alloc2J = clazz.getDeclaredMethod("alloc2", (Class[]) null);
    Method alloc3J = clazz.getDeclaredMethod("alloc3", (Class[]) null);
    Method alloc4J = clazz.getDeclaredMethod("alloc4", new Class[] { Integer.TYPE });
    RVMMethod trivial = java.lang.reflect.JikesRVMSupport.getMethodOf(trivialJ);
    RVMMethod alloc1 = java.lang.reflect.JikesRVMSupport.getMethodOf(alloc1J);
    RVMMethod alloc2 = java.lang.reflect.JikesRVMSupport.getMethodOf(alloc2J);
    RVMMethod alloc3 = java.lang.reflect.JikesRVMSupport.getMethodOf(alloc3J);
    RVMMethod alloc4 = java.lang.reflect.JikesRVMSupport.getMethodOf(alloc4J);
    trivial.compile();
    int trivialSize = trivial.getCurrentCompiledMethod().numberOfInstructions();
    alloc1.compile();
    int alloc1Size = alloc1.getCurrentCompiledMethod().numberOfInstructions();
    alloc2.compile();
    int alloc2Size = alloc2.getCurrentCompiledMethod().numberOfInstructions();
    alloc3.compile();
    int alloc3Size = alloc3.getCurrentCompiledMethod().numberOfInstructions();
    alloc4.compile();
    int alloc4Size = alloc4.getCurrentCompiledMethod().numberOfInstructions();
    // System.out.println("Trivial method is "+trivialSize);
    // System.out.println("Scalar allocation size is "+alloc1Size);
    // System.out.println("Small array allocation is "+alloc2Size);
    // System.out.println("Large array allocation is "+alloc3Size);
    // System.out.println("Unknown size array allocation is "+alloc4Size);
    // Subtract off prologue/epilogue size. This is approximate!!!
    // If you really care, count the instructions by hand!
    alloc1Size -= trivialSize;
    alloc2Size -= trivialSize;
    alloc3Size -= trivialSize;
    alloc4Size -= trivialSize;
    System.out.println("Approximate scalar allocation size is " + alloc1Size + unit);
    System.out.println("Approximate small array allocation is " + alloc2Size + unit);
    System.out.println("Approximate large array allocation is " + alloc3Size + unit);
    System.out.println("Approximate unknown size array allocation is " + alloc4Size + unit);
    boolean fail = false;
    if (alloc1Size > alloc1Limit) {
        System.out.println("FAIL: scalar allocation is too porky");
        printLimit(alloc1Limit);
        fail = true;
    }
    if (alloc2Size > alloc2Limit) {
        System.out.println("FAIL: small array allocation is too porky");
        printLimit(alloc2Limit);
        fail = true;
    }
    if (alloc3Size > alloc3Limit) {
        System.out.println("FAIL: large array allocation is too porky");
        printLimit(alloc3Limit);
        fail = true;
    }
    if (alloc4Size > alloc4Limit) {
        System.out.println("FAIL: unknown size array allocation is too porky");
        printLimit(alloc4Limit);
        fail = true;
    }
    if (!fail) {
        System.out.println("ALL TESTS PASSED");
    }
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) RVMMethod(org.jikesrvm.classloader.RVMMethod) Method(java.lang.reflect.Method)

Example 48 with RVMMethod

use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.

the class ScanThread method printMethodHeader.

/**
 * Print out the method header for the method associated with the
 * current frame
 */
private void printMethodHeader() {
    RVMMethod method = compiledMethod.getMethod();
    Log.write("\n--- METHOD (");
    Log.write(CompiledMethod.compilerTypeToString(compiledMethodType));
    Log.write(") ");
    if (method == null)
        Log.write("null method");
    else
        printMethod(method);
    Log.writeln();
    Log.write("--- fp = ");
    Log.write(fp);
    if (compiledMethod.isCompiled()) {
        ObjectReference codeBase = ObjectReference.fromObject(compiledMethod.getEntryCodeArray());
        Log.write("     code base = ");
        Log.write(codeBase);
        Log.write("     code offset = ");
        Log.writeln(ip.diff(codeBase.toAddress()));
        Log.write("     line number = ");
        Log.writeln(compiledMethod.findLineNumberForInstruction(ip.diff(codeBase.toAddress())));
    } else {
        Log.write("   Method is uncompiled - ip = ");
        Log.writeln(ip);
    }
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) ObjectReference(org.vmmagic.unboxed.ObjectReference)

Example 49 with RVMMethod

use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.

the class TraceInterface method skipOwnFramesAndDump.

@Override
@NoInline
// This can't be uninterruptible --- it is an IO routine
@Interruptible
public Address skipOwnFramesAndDump(ObjectReference typeRef) {
    TIB tib = Magic.addressAsTIB(typeRef.toAddress());
    RVMMethod m = null;
    int bci = -1;
    int compiledMethodID = 0;
    Offset ipOffset = Offset.zero();
    Address fp = Magic.getFramePointer();
    Address ip = Magic.getReturnAddressUnchecked(fp);
    fp = Magic.getCallerFramePointer(fp);
    // This code borrows heavily from RVMThread.dumpStack
    final Address STACKFRAME_SENTINEL_FP = StackFrameLayout.getStackFrameSentinelFP();
    final int INVISIBLE_METHOD_ID = StackFrameLayout.getInvisibleMethodID();
    while (Magic.getCallerFramePointer(fp).NE(STACKFRAME_SENTINEL_FP)) {
        compiledMethodID = Magic.getCompiledMethodID(fp);
        if (compiledMethodID != INVISIBLE_METHOD_ID) {
            // normal java frame(s)
            CompiledMethod compiledMethod = CompiledMethods.getCompiledMethod(compiledMethodID);
            if (compiledMethod.getCompilerType() != CompiledMethod.TRAP) {
                ipOffset = compiledMethod.getInstructionOffset(ip);
                m = compiledMethod.getMethod();
                if (VM.BuildForOptCompiler && compiledMethod.getCompilerType() == CompiledMethod.OPT) {
                    OptCompiledMethod optInfo = (OptCompiledMethod) compiledMethod;
                    /* Opt stack frames may contain multiple inlined methods. */
                    OptMachineCodeMap map = optInfo.getMCMap();
                    int iei = map.getInlineEncodingForMCOffset(ipOffset);
                    if (iei >= 0) {
                        int[] inlineEncoding = map.inlineEncoding;
                        boolean allocCall = true;
                        bci = map.getBytecodeIndexForMCOffset(ipOffset);
                        for (int j = iei; j >= 0 && allocCall; j = OptEncodedCallSiteTree.getParent(j, inlineEncoding)) {
                            int mid = OptEncodedCallSiteTree.getMethodID(j, inlineEncoding);
                            m = MemberReference.getMethodRef(mid).getResolvedMember();
                            if (!isAllocCall(m.getName().getBytes()))
                                allocCall = false;
                            if (j > 0)
                                bci = OptEncodedCallSiteTree.getByteCodeOffset(j, inlineEncoding);
                        }
                        if (!allocCall)
                            break;
                    }
                } else {
                    if (!isAllocCall(m.getName().getBytes())) {
                        BaselineCompiledMethod baseInfo = (BaselineCompiledMethod) compiledMethod;
                        final int INSTRUCTION_WIDTH = ArchConstants.getInstructionWidth();
                        bci = baseInfo.findBytecodeIndexForInstruction(ipOffset.toWord().lsh(INSTRUCTION_WIDTH).toOffset());
                        break;
                    }
                }
            }
        }
        ip = Magic.getReturnAddressUnchecked(fp);
        fp = Magic.getCallerFramePointer(fp);
    }
    if (m != null) {
        int allocid = (((compiledMethodID & 0x0000ffff) << 15) ^ ((compiledMethodID & 0xffff0000) >> 16) ^ ipOffset.toInt()) & ~0x80000000;
        /* Now print the location string. */
        VM.sysWrite('\n');
        VM.writeHex(allocid);
        VM.sysWrite('-');
        VM.sysWrite('>');
        VM.sysWrite('[');
        VM.writeHex(compiledMethodID);
        VM.sysWrite(']');
        m.getDeclaringClass().getDescriptor().sysWrite();
        VM.sysWrite(':');
        m.getName().sysWrite();
        m.getDescriptor().sysWrite();
        VM.sysWrite(':');
        VM.writeHex(bci);
        VM.sysWrite('\t');
        RVMType type = tib.getType();
        type.getDescriptor().sysWrite();
        VM.sysWrite('\n');
    }
    return fp;
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) OptMachineCodeMap(org.jikesrvm.compilers.opt.runtimesupport.OptMachineCodeMap) Address(org.vmmagic.unboxed.Address) RVMType(org.jikesrvm.classloader.RVMType) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) TIB(org.jikesrvm.objectmodel.TIB) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) BaselineCompiledMethod(org.jikesrvm.compilers.baseline.BaselineCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Offset(org.vmmagic.unboxed.Offset) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 50 with RVMMethod

use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.

the class ControllerMemory method printFinalMethodStats.

/**
 * This method summarizes the recompilation actions taken for all methods
 * in this object and produces a report to the passed PrintStream.
 * @param log the stream to print to
 */
public static synchronized void printFinalMethodStats(PrintStream log) {
    // We will traverse the hash table and for each method record its status as
    // one of the following
    // B -> 0 -> 1 -> 2
    // B -> 0 -> 1
    // B -> 0
    // B      -> 1 -> 2
    // B -> 0      -> 2
    // B           -> 2
    // B      -> 1
    // 
    // We encode these possibilities by turning on 1 of three bits for 0, 1, 2
    // Also, for all methods that eventually get to level 2, they can be
    // recompiled an arbitrary amount of times.  We record this in in a counter.
    final int MAX_BIT_PATTERN = 7;
    int[] summaryArray = new int[MAX_BIT_PATTERN + 1];
    int[] recompsAtLevel2Array = new int[MAX_BIT_PATTERN + 1];
    int totalRecompsAtLevel2 = 0;
    // traverse table and give a summary of all actions that have occurred
    for (RVMMethod meth : table.keys()) {
        LinkedList<ControllerPlan> planList = table.get(meth);
        int bitPattern = 0;
        int recompsAtLevel2 = 0;
        for (ControllerPlan plan : planList) {
            // only process plans that were completed or completed and outdated
            // by subsequent plans for this method
            byte status = plan.getStatus();
            if (status == ControllerPlan.COMPLETED || status == ControllerPlan.OUTDATED) {
                int optLevel = plan.getCompPlan().options.getOptLevel();
                // check for recomps at level 2
                if (optLevel == 2 && bitIsSet(bitPattern, 2)) {
                    recompsAtLevel2++;
                }
                bitPattern = setBitPattern(bitPattern, optLevel);
            }
        // if
        }
        if (Controller.options.LOGGING_LEVEL >= 2) {
            log.println("Method: " + meth + ", bitPattern: " + bitPattern + ", recompsAtLevel2: " + recompsAtLevel2);
        }
        summaryArray[bitPattern]++;
        // track level 2 recomps per pattern
        recompsAtLevel2Array[bitPattern] += recompsAtLevel2;
    }
    // Print the summary
    int totalUniqueMethods = 0;
    for (int i = 1; i <= MAX_BIT_PATTERN; i++) {
        log.print("    Base");
        for (int optLevel = 0; optLevel <= 2; optLevel++) {
            if (bitIsSet(i, optLevel)) {
                log.print(" -> " + optLevel);
            }
        }
        log.print(": " + summaryArray[i]);
        // print any level 2 recomps for this pattern
        if (recompsAtLevel2Array[i] > 0) {
            totalRecompsAtLevel2 += recompsAtLevel2Array[i];
            log.println(" (" + recompsAtLevel2Array[i] + " opt level 2 recomps)");
        } else {
            log.println();
        }
        totalUniqueMethods = totalUniqueMethods + summaryArray[i];
    }
    log.println("  Num recompilations At level 2: " + totalRecompsAtLevel2);
    log.println("  Num unique methods recompiled: " + totalUniqueMethods);
    log.println();
}
Also used : RVMMethod(org.jikesrvm.classloader.RVMMethod)

Aggregations

RVMMethod (org.jikesrvm.classloader.RVMMethod)86 RVMClass (org.jikesrvm.classloader.RVMClass)29 TypeReference (org.jikesrvm.classloader.TypeReference)17 RVMType (org.jikesrvm.classloader.RVMType)15 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)14 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 Atom (org.jikesrvm.classloader.Atom)11 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)11 Offset (org.vmmagic.unboxed.Offset)11 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)10 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)10 Address (org.vmmagic.unboxed.Address)9 MethodReference (org.jikesrvm.classloader.MethodReference)8 NormalMethod (org.jikesrvm.classloader.NormalMethod)8 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)8 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)8 Method (java.lang.reflect.Method)7 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)7 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)7 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)7