Search in sources :

Example 61 with NormalMethod

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

the class GenerationContextTest method packagePrivateMakeLocalReturnsRegWithInheritedFlagsAndGuard.

@Test
public void packagePrivateMakeLocalReturnsRegWithInheritedFlagsAndGuard() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
    OptOptions opts = new OptOptions();
    GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
    int localNumber = 0;
    TypeReference localType = nm.getDeclaringClass().getTypeRef();
    RegisterOperand regOp = gc.makeLocal(localNumber, localType);
    TrueGuardOperand guard = new TrueGuardOperand();
    regOp.setGuard(guard);
    regOp.setParameter();
    regOp.setNonVolatile();
    regOp.setExtant();
    regOp.setDeclaredType();
    regOp.setPreciseType();
    regOp.setPositiveInt();
    RegisterOperand newRegOpWithInheritance = gc.makeLocal(localNumber, regOp);
    Operand scratchObject = newRegOpWithInheritance.getGuard();
    assertTrue(scratchObject.isTrueGuard());
    assertTrue(newRegOpWithInheritance.isParameter());
    assertTrue(newRegOpWithInheritance.isNonVolatile());
    assertTrue(newRegOpWithInheritance.isExtant());
    assertTrue(newRegOpWithInheritance.isDeclaredType());
    assertTrue(newRegOpWithInheritance.isPreciseType());
    assertTrue(newRegOpWithInheritance.isPositiveInt());
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) 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) OptOptions(org.jikesrvm.compilers.opt.OptOptions) TypeReference(org.jikesrvm.classloader.TypeReference) TrueGuardOperand(org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand) Test(org.junit.Test)

Example 62 with NormalMethod

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

the class GenerationContextTest method resyncDoesNotDeleteNullCheckGuardsThatMapToUsedRegisters.

@Test
public void resyncDoesNotDeleteNullCheckGuardsThatMapToUsedRegisters() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
    OptOptions opts = new OptOptions();
    GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
    RegisterOperand thisLocal = gc.makeLocal(0, nm.getDeclaringClass().getTypeRef());
    Register thisReg = thisLocal.getRegister();
    RegisterOperand thisNullCheckGuard = gc.makeNullCheckGuard(thisReg);
    assertNotNull(thisNullCheckGuard);
    gc.resync();
    RegisterOperand newNullCheckGuard = gc.makeNullCheckGuard(thisReg);
    assertTrue(newNullCheckGuard.sameRegisterPropertiesAs(thisNullCheckGuard));
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) OptOptions(org.jikesrvm.compilers.opt.OptOptions) Test(org.junit.Test)

Example 63 with NormalMethod

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

the class OptTestHarness method compileMethodsInVector.

private void compileMethodsInVector() {
    // Compile all baseline methods first
    int size = baselineMethodVector.size();
    output.sysOutPrintln("Compiling " + size + " methods baseline");
    // Compile all methods in baseline vector
    for (int i = 0; i < size; i++) {
        NormalMethod method = (NormalMethod) baselineMethodVector.get(i);
        CompiledMethod cm = null;
        cm = BaselineCompiler.compile(method);
        method.replaceCompiledMethod(cm);
        if (printCodeAddress) {
            output.sysOutPrintln(compiledMethodMessage(method));
        }
    }
    // Now compile all methods in opt vector
    size = optMethodVector.size();
    output.sysOutPrintln("Compiling " + size + " methods opt");
    for (int i = 0; i < size; i++) {
        NormalMethod method = (NormalMethod) optMethodVector.get(i);
        OptOptions opts = optOptionsVector.get(i);
        try {
            CompiledMethod cm = null;
            CompilationPlan cp = new CompilationPlan(method, OptimizationPlanner.createOptimizationPlan(opts), null, opts);
            cm = OptimizingCompiler.compile(cp);
            method.replaceCompiledMethod(cm);
            if (printCodeAddress) {
                output.sysOutPrintln(compiledMethodMessage(method));
            }
        } catch (OptimizingCompilerException e) {
            if (e.isFatal && VM.ErrorsFatal) {
                e.printStackTrace();
                VM.sysFail("Internal vm error: " + e);
            } else {
                output.sysErrPrintln("SKIPPING opt-compilation of " + method + ":\n  " + e.getMessage());
                if (opts.PRINT_METHOD) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod)

Example 64 with NormalMethod

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

the class OptimizingCompiler method compile.

// //////////////////////////////////////////
// Public interface for compiling a method
// //////////////////////////////////////////
/**
 * Invoke the opt compiler to execute a compilation plan.
 *
 * @param cp the compilation plan to be executed
 * @return the CompiledMethod object that is the result of compilation
 */
public static CompiledMethod compile(CompilationPlan cp) {
    NormalMethod method = cp.method;
    OptOptions options = cp.options;
    checkSupported(method, options);
    try {
        printMethodMessage(method, options);
        IR ir = cp.execute();
        // if doing analysis only, don't try to return an object
        if (cp.analyzeOnly || cp.irGeneration) {
            return null;
        }
        // now that we're done compiling, give the specialization
        // system a chance to eagerly compile any specialized version
        // that are pending.  TODO: use lazy compilation with specialization.
        SpecializationDatabase.doDeferredSpecializations();
        ir.compiledMethod.compileComplete(ir.MIRInfo.machinecode);
        return ir.compiledMethod;
    } catch (OptimizingCompilerException e) {
        throw e;
    } catch (Throwable e) {
        fail(e, method);
        return null;
    }
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) IR(org.jikesrvm.compilers.opt.ir.IR) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException)

Example 65 with NormalMethod

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

the class UnsyncReplacer method transform.

/**
 * Perform the transformation for a given register appearance
 *
 * @param rop  The def or use to check
 */
private void transform(RegisterOperand rop) {
    final boolean DEBUG = false;
    Instruction inst = rop.instruction;
    switch(inst.getOpcode()) {
        case SYSCALL_opcode:
        case CALL_opcode:
            RegisterOperand invokee = Call.getParam(inst, 0).asRegister();
            if (invokee == rop) {
                // replace with equivalent call on the synthetic
                // unsynchronized type
                MethodOperand mop = Call.getMethod(inst);
                if (mop.getTarget().isSynchronized()) {
                    mop.spMethod = context.findOrCreateSpecializedVersion((NormalMethod) mop.getTarget());
                    if (DEBUG) {
                        VM.sysWriteln("Identified call " + inst + " for unsynchronization");
                    }
                }
            }
            break;
        case MONITORENTER_opcode:
            if (DEBUG) {
                VM.sysWrite("Removing " + inst);
            }
            inst.insertBefore(Empty.create(READ_CEILING));
            DefUse.removeInstructionAndUpdateDU(inst);
            break;
        case MONITOREXIT_opcode:
            if (DEBUG) {
                VM.sysWrite("Removing " + inst);
            }
            inst.insertAfter(Empty.create(WRITE_FLOOR));
            DefUse.removeInstructionAndUpdateDU(inst);
            break;
        default:
            // no action necessary
            break;
    }
}
Also used : RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) NormalMethod(org.jikesrvm.classloader.NormalMethod) Instruction(org.jikesrvm.compilers.opt.ir.Instruction) MethodOperand(org.jikesrvm.compilers.opt.ir.operand.MethodOperand)

Aggregations

NormalMethod (org.jikesrvm.classloader.NormalMethod)95 Test (org.junit.Test)66 OptOptions (org.jikesrvm.compilers.opt.OptOptions)45 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)41 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)31 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)28 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)21 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 TypeReference (org.jikesrvm.classloader.TypeReference)15 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)15 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)15 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)13 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)13 Register (org.jikesrvm.compilers.opt.ir.Register)13 RVMMethod (org.jikesrvm.classloader.RVMMethod)8 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)8 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)8 TypeOperand (org.jikesrvm.compilers.opt.ir.operand.TypeOperand)8