Search in sources :

Example 6 with OptCompiledMethod

use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod 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 7 with OptCompiledMethod

use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod 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)

Example 8 with OptCompiledMethod

use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.

the class GenerationContextTest method childContextsQueryOSRBarrierInformationViaOutermostParent.

@Test
public void childContextsQueryOSRBarrierInformationViaOutermostParent() throws Exception {
    NormalMethod nm = getNormalMethodForTest("methodForInliningTests");
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext outermost = new GenerationContext(nm, null, cm, opts, io);
    Class<?>[] classArgs = { Object.class };
    NormalMethod callee = getNormalMethodForTest("emptyStaticMethodWithObjectParamAndReturnValue", classArgs);
    MethodOperand methOp = MethodOperand.STATIC(callee);
    RegisterOperand result = createMockRegisterOperand(TypeReference.JavaLangObject);
    Instruction callInstr = Call.create(CALL, result, null, methOp, 1);
    RegisterOperand objectParam = createMockRegisterOperand(TypeReference.JavaLangObject);
    Call.setParam(callInstr, 0, objectParam);
    callInstr.setPosition(new InlineSequence(nm));
    ExceptionHandlerBasicBlockBag ebag = getMockEbag();
    GenerationContext child = outermost.createChildContext(ebag, callee, callInstr);
    Instruction osrBarrier = createMockOSRBarrier();
    Instruction call = createMockCall();
    child.saveOSRBarrierForInst(osrBarrier, call);
    assertThat(outermost.getOSRBarrierFromInst(call), is(osrBarrier));
    assertThat(child.getOSRBarrierFromInst(call), is(osrBarrier));
    GenerationContext child2 = outermost.createChildContext(ebag, callee, callInstr);
    assertThat(child2.getOSRBarrierFromInst(call), is(osrBarrier));
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) Test(org.junit.Test)

Example 9 with OptCompiledMethod

use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.

the class GenerationContextTest method methodsWithReturnValueHaveReturnInstructionInEpilogue.

@Test
public void methodsWithReturnValueHaveReturnInstructionInEpilogue() throws Exception {
    NormalMethod nm = getNormalMethodForTest("staticMethodReturningLongMaxValue");
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
    InlineSequence inlineSequence = new InlineSequence(nm);
    assertThatInlineSequenceWasSetCorrectly(gc, inlineSequence);
    assertThatNumberOfParametersIs(gc, 0);
    BasicBlock prologue = gc.getPrologue();
    assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
    assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
    assertThatBlockOnlyHasOneRealInstruction(prologue);
    BasicBlock epilogue = gc.getEpilogue();
    assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
    assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
    RegisterOperand returnValue = Return.getVal(epilogue.lastRealInstruction()).asRegister();
    assertThat(returnValue.getType(), is(TypeReference.Long));
    assertThatExitBlockIsSetCorrectly(gc);
    assertThatDataIsSavedCorrectly(nm, cm, io, gc);
    assertThat(gc.getResultReg().isLong(), is(true));
    assertThatGCHasNoExceptionHandlers(gc);
    assertThatRegisterPoolExists(gc);
    assertThatChecksWontBeSkipped(gc);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

Example 10 with OptCompiledMethod

use of org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod in project JikesRVM by JikesRVM.

the class GenerationContextTest method specializedParametersAreNotSanityChecked.

@Test
public void specializedParametersAreNotSanityChecked() throws Exception {
    Class<?>[] argumentTypes = { Object.class };
    TypeReference[] specializedArgumentTypes = {};
    NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithObjectParam", argumentTypes);
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext gc = new GenerationContext(nm, specializedArgumentTypes, cm, opts, io);
    assertThatNumberOfParametersIs(gc, 0);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) OptOptions(org.jikesrvm.compilers.opt.OptOptions) TypeReference(org.jikesrvm.classloader.TypeReference) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

Aggregations

OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)53 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)43 NormalMethod (org.jikesrvm.classloader.NormalMethod)31 OptOptions (org.jikesrvm.compilers.opt.OptOptions)29 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 Test (org.junit.Test)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)19 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)18 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)14 Offset (org.vmmagic.unboxed.Offset)13 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)12 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)12 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)12 Address (org.vmmagic.unboxed.Address)12 TypeReference (org.jikesrvm.classloader.TypeReference)7 ClassConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand)6 ObjectConstantOperand (org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand)6 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)6