Search in sources :

Example 26 with OptCompiledMethod

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

the class OptExceptionDeliverer method unwindStackFrame.

/**
 * Unwind a stackframe.
 */
@Override
@Unpreemptible("Deliver exception possibly from unpreemptible code")
public void unwindStackFrame(CompiledMethod cm, AbstractRegisters registers) {
    Address fp = registers.getInnermostFramePointer();
    OptCompiledMethod compiledMethod = (OptCompiledMethod) cm;
    // restore non-volatile registers
    Offset frameOffset = Offset.fromIntSignExtend(compiledMethod.getUnsignedNonVolatileOffset());
    int firstInteger = compiledMethod.getFirstNonVolatileGPR();
    if (firstInteger >= 0) {
        if (VM.BuildFor64Addr) {
            frameOffset = frameOffset.plus(7).toWord().and(Word.fromIntSignExtend(~7)).toOffset();
        }
        for (int i = firstInteger; i < 32; i++) {
            registers.getGPRs().set(i, fp.loadWord(frameOffset));
            frameOffset = frameOffset.plus(BYTES_IN_ADDRESS);
        }
    }
    int firstFloat = compiledMethod.getFirstNonVolatileFPR();
    if (firstFloat >= 0) {
        frameOffset = frameOffset.plus(7).toWord().and(Word.fromIntSignExtend(~7)).toOffset();
        for (int i = firstFloat; i < 32; i++) {
            long temp = Magic.getLongAtOffset(Magic.addressAsObject(fp), frameOffset);
            registers.getFPRs()[i] = Magic.longBitsAsDouble(temp);
            frameOffset = frameOffset.plus(BYTES_IN_DOUBLE);
        }
    }
    registers.unwindStackFrame();
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) Address(org.vmmagic.unboxed.Address) Offset(org.vmmagic.unboxed.Offset) Unpreemptible(org.vmmagic.pragma.Unpreemptible)

Example 27 with OptCompiledMethod

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

the class CompiledMethods method createCompiledMethod.

public static synchronized CompiledMethod createCompiledMethod(RVMMethod m, int compilerType) {
    int id = currentCompiledMethodId + 1;
    ensureCapacity(id);
    currentCompiledMethodId++;
    CompiledMethod cm = null;
    if (compilerType == CompiledMethod.BASELINE) {
        if (VM.BuildForIA32) {
            cm = new org.jikesrvm.compilers.baseline.ia32.ArchBaselineCompiledMethod(id, m);
        } else {
            if (VM.VerifyAssertions)
                VM._assert(VM.BuildForPowerPC);
            cm = new org.jikesrvm.compilers.baseline.ppc.ArchBaselineCompiledMethod(id, m);
        }
    } else if (VM.BuildForOptCompiler && compilerType == CompiledMethod.OPT) {
        cm = new OptCompiledMethod(id, m);
    } else if (compilerType == CompiledMethod.JNI) {
        cm = new JNICompiledMethod(id, m);
    } else {
        if (VM.VerifyAssertions)
            VM._assert(VM.NOT_REACHED, "Unexpected compiler type!");
    }
    setCompiledMethod(id, cm);
    return cm;
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) JNICompiledMethod(org.jikesrvm.jni.JNICompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) JNICompiledMethod(org.jikesrvm.jni.JNICompiledMethod)

Example 28 with OptCompiledMethod

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

the class GenerationContextTest method prologueAndEpilogueForSynchronizedStaticMethodHaveMonitorEnterAndExit.

@Test
public void prologueAndEpilogueForSynchronizedStaticMethodHaveMonitorEnterAndExit() throws Exception {
    NormalMethod nm = getNormalMethodForTest("emptySynchronizedStaticMethod");
    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);
    Enumeration<Instruction> prologueInstructions = prologue.forwardRealInstrEnumerator();
    prologueInstructions.nextElement();
    Instruction secondInstruction = prologueInstructions.nextElement();
    assertInstructionIsMonitorEnterInPrologue(secondInstruction, inlineSequence);
    assertThatGuardIsCorrectForMonitorEnter(secondInstruction);
    Operand lockObject = MonitorOp.getRef(secondInstruction);
    Operand expectedLockObject = buildLockObjectForStaticMethod(nm);
    assertTrue(expectedLockObject.similar(lockObject));
    assertThatNumberOfRealInstructionsMatches(prologue, 2);
    BasicBlock epilogue = gc.getEpilogue();
    assertThatEpilogueBlockIsSetupCorrectly(gc, inlineSequence, epilogue);
    assertThatFirstInstructionEpilogueIsMonitorExit(inlineSequence, epilogue);
    assertThatLastInstructionInEpilogueIsReturn(gc, epilogue);
    assertThatReturnInstructionReturnsVoid(epilogue);
    assertThatNumberOfRealInstructionsMatches(epilogue, 2);
    assertThatExitBlockIsSetCorrectly(gc);
    assertThatRegisterPoolExists(gc);
    assertThatDataIsSavedCorrectly(nm, cm, io, gc);
    assertThatReturnValueIsVoid(gc);
    assertThatExceptionHandlersWereGenerated(gc);
    assertThatUnlockAndRethrowBlockIsCorrect(gc, inlineSequence, prologue, expectedLockObject, epilogue);
    assertThatChecksWontBeSkipped(gc);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand) TypeOperand(org.jikesrvm.compilers.opt.ir.operand.TypeOperand) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Operand(org.jikesrvm.compilers.opt.ir.operand.Operand) ObjectConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ObjectConstantOperand) ClassConstantOperand(org.jikesrvm.compilers.opt.ir.operand.ClassConstantOperand) 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) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

Example 29 with OptCompiledMethod

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

the class GenerationContextTest method constructorIsCorrectForTheSimplestMethods.

@Test
public void constructorIsCorrectForTheSimplestMethods() throws Exception {
    NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithoutAnnotations");
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
    assertThatStateIsCorrectForUnsynchronizedEmptyStaticMethod(nm, cm, io, gc);
}
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) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

Example 30 with OptCompiledMethod

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

the class GenerationContextTest method unintBeginAndUnintEndAreAddedWhenNecessary.

@Test
public void unintBeginAndUnintEndAreAddedWhenNecessary() throws Exception {
    NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithoutAnnotations");
    CompiledMethod cm = new OptCompiledMethod(-1, nm);
    OptOptions opts = new OptOptions();
    InlineOracle io = new DefaultInlineOracle();
    GenerationContext gc = new GenerationContext(nm, null, cm, opts, io);
    assertThatStateIsCorrectForUnsynchronizedEmptyStaticMethod(nm, cm, io, gc);
    NormalMethod callee = getNormalMethodForTest("emptyStaticUninterruptibleMethod");
    Instruction callInstr = buildCallInstructionForStaticMethodWithoutReturn(callee, nm);
    ExceptionHandlerBasicBlockBag ebag = getMockEbag();
    int nodeNumber = 23456;
    gc.getCfg().setNumberOfNodes(nodeNumber);
    GenerationContext child = gc.createChildContext(ebag, callee, callInstr);
    assertThatStateIsCopiedFromParentToChild(gc, callee, child, ebag);
    InlineSequence expectedInlineSequence = new InlineSequence(callee, callInstr.position(), callInstr);
    assertEquals(expectedInlineSequence, child.getInlineSequence());
    assertThatPrologueAndEpilogueAreWiredCorrectlyForChildContext(ebag, nodeNumber, child);
    Enumeration<Instruction> prologueRealInstr = child.getPrologue().forwardRealInstrEnumerator();
    Instruction unintBegin = prologueRealInstr.nextElement();
    assertThatInstructionIsUnintMarker(unintBegin, UNINT_BEGIN);
    assertThatNoMoreInstructionsExist(prologueRealInstr);
    Enumeration<Instruction> epilogueRealInstr = child.getEpilogue().forwardRealInstrEnumerator();
    Instruction unintEnd = epilogueRealInstr.nextElement();
    assertThatInstructionIsUnintMarker(unintEnd, UNINT_END);
    assertThatNoMoreInstructionsExist(epilogueRealInstr);
}
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) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) 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) ExceptionHandlerBasicBlockBag(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag) 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