Search in sources :

Example 26 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class BaselineGCMapIteratorTest method getNextReturnAddressAddressReturnsZeroIfNoJSRsArePresent.

@Test
public void getNextReturnAddressAddressReturnsZeroIfNoJSRsArePresent() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithoutAnnotations");
    CompiledMethod cm = nm.getCurrentCompiledMethod();
    gcMapIter.setupIterator(cm, NO_OFFSET, NO_FP);
    Address returnAddressAddress = gcMapIter.getNextReturnAddressAddress();
    assertZero(returnAddressAddress);
}
Also used : Address(org.vmmagic.unboxed.Address) NormalMethod(org.jikesrvm.classloader.NormalMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

Example 27 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class BaselineGCMapIteratorTest method setupOfIteratorRequiresOnlyCompiledMethod.

// The following test cases use JikesRVMSupport to access the actual
// compiled methods. This is obviously not possible on VMs other than
// Jikes RVM.
@Test
public void setupOfIteratorRequiresOnlyCompiledMethod() throws Exception {
    NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithoutAnnotations");
    CompiledMethod cm = nm.getCurrentCompiledMethod();
    gcMapIter.setupIterator(cm, NO_OFFSET, NO_FP);
}
Also used : NormalMethod(org.jikesrvm.classloader.NormalMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) Test(org.junit.Test)

Example 28 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class GenerationContextTest method instanceMethodsHaveMovesInPrologue.

@Test
public void instanceMethodsHaveMovesInPrologue() throws Exception {
    NormalMethod nm = getNormalMethodForTest("emptyInstanceMethodWithoutAnnotations");
    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);
    assertThatLocalsForInstanceMethodWithoutParametersAreCorrect(nm, gc);
    RegisterOperand thisOperand = getThisOperand(gc);
    BasicBlock prologue = gc.getPrologue();
    assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
    assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, thisOperand, 0);
    Instruction lastPrologueInstruction = prologue.lastRealInstruction();
    assertThatInstructionIsGuardMoveForPrologue(lastPrologueInstruction, thisOperand, gc);
    assertThatEpilogueIsForVoidReturnMethod(gc, inlineSequence);
    assertThatExitBlockIsSetCorrectly(gc);
    assertThatDataIsSavedCorrectly(nm, cm, io, gc);
    assertThatReturnValueIsVoid(gc);
    assertThatGCHasNoExceptionHandlers(gc);
    assertThatRegisterPoolExists(gc);
    assertThatChecksWontBeSkipped(gc);
    assertThatNoRethrowBlockExists(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) 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 CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class GenerationContextTest method constructorCreatesOperandsForStaticMethodWithParameters.

@Test
public void constructorCreatesOperandsForStaticMethodWithParameters() throws Exception {
    Class<?>[] argumentTypes = { long.class, int.class, Object.class, double.class };
    NormalMethod nm = getNormalMethodForTest("emptyStaticMethodWithParams", argumentTypes);
    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, 4);
    RegisterOperand longRegOp = getThisOperand(gc);
    assertThat(longRegOp.isLong(), is(true));
    assertThatRegOpHasDeclaredType(longRegOp);
    RegisterOperand intRegOp = gc.getArguments()[1].asRegister();
    assertThat(intRegOp.isInt(), is(true));
    assertThatRegOpHasDeclaredType(intRegOp);
    RegisterOperand objectRegOp = gc.getArguments()[2].asRegister();
    assertThatRegOpHoldsClassType(objectRegOp);
    assertThatRegOpHasDeclaredType(objectRegOp);
    RegisterOperand doubleRegOp = gc.getArguments()[3].asRegister();
    assertThat(doubleRegOp.isDouble(), is(true));
    assertThatRegOpHasDeclaredType(doubleRegOp);
    Register longReg = gc.localReg(0, TypeReference.Long);
    assertThatRegOpIsLocalRegOfRegister(longRegOp, longReg);
    Register intReg = gc.localReg(2, TypeReference.Int);
    assertThatRegOpIsLocalRegOfRegister(intRegOp, intReg);
    Register objectReg = gc.localReg(3, TypeReference.JavaLangObject);
    assertThatRegOpIsLocalRegOfRegister(objectRegOp, objectReg);
    Register doubleReg = gc.localReg(4, TypeReference.Double);
    assertThatRegOpIsLocalRegOfRegister(doubleRegOp, doubleReg);
    BasicBlock prologue = gc.getPrologue();
    assertThatPrologueBlockIsSetupCorrectly(gc, inlineSequence, prologue);
    assertThatFirstInstructionInPrologueIsPrologue(inlineSequence, prologue);
    assertThatBlockOnlyHasOneRealInstruction(prologue);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, longRegOp, 0);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, intRegOp, 1);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, objectRegOp, 2);
    assertThatPrologueOperandIsRegOpFromLocalNr(prologue, doubleRegOp, 3);
    assertThatEpilogueIsForVoidReturnMethod(gc, inlineSequence);
    assertThatExitBlockIsSetCorrectly(gc);
    assertThatDataIsSavedCorrectly(nm, cm, io, gc);
    assertThatReturnValueIsVoid(gc);
    assertThatGCHasNoExceptionHandlers(gc);
    assertThatRegisterPoolExists(gc);
    assertThatChecksWontBeSkipped(gc);
    assertThatNoRethrowBlockExists(gc);
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineOracle(org.jikesrvm.compilers.opt.inlining.InlineOracle) BasicBlock(org.jikesrvm.compilers.opt.ir.BasicBlock) ExceptionHandlerBasicBlock(org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock) OptOptions(org.jikesrvm.compilers.opt.OptOptions) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) RegisterOperand(org.jikesrvm.compilers.opt.ir.operand.RegisterOperand) Register(org.jikesrvm.compilers.opt.ir.Register) NormalMethod(org.jikesrvm.classloader.NormalMethod) DefaultInlineOracle(org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle) InlineSequence(org.jikesrvm.compilers.opt.inlining.InlineSequence) Test(org.junit.Test)

Example 30 with CompiledMethod

use of org.jikesrvm.compilers.common.CompiledMethod in project JikesRVM by JikesRVM.

the class OptTestHarness method processOptionString.

private void processOptionString(String[] args) {
    for (int i = 0, n = args.length; i < n; i++) {
        try {
            String arg = args[i];
            if (arg.startsWith("-oc:") && options.processAsOption("-X:irc:", arg.substring(4))) {
            // handled in processAsOption
            } else if ("-useBootOptions".equals(arg)) {
                OptimizingCompiler.setBootOptions(options);
            } else if ("-longcommandline".equals(arg)) {
                // the -longcommandline option reads options from a file.
                String fileName = args[++i];
                String[] optionString = fileAccess.readOptionStringFromFile(fileName);
                processOptionString(optionString);
            } else if ("+baseline".equals(arg)) {
                useBaselineCompiler = true;
            } else if ("-baseline".equals(arg)) {
                useBaselineCompiler = false;
            } else if ("-load".equals(arg)) {
                loadClass(args[++i]);
            } else if ("-class".equals(arg)) {
                RVMClass klass = loadClass(args[++i]);
                processClass(klass, options);
                duplicateOptions();
            } else if ("-method".equals(arg) || "-methodOpt".equals(arg) || "-methodBase".equals(arg)) {
                // Default for this method is determined by BASELINE var
                boolean isBaseline = useBaselineCompiler;
                // Unless specified by these options
                if ("-methodOpt".equals(arg)) {
                    isBaseline = false;
                }
                if ("-methodBase".equals(arg)) {
                    isBaseline = true;
                }
                RVMClass klass = null;
                try {
                    klass = loadClass(args[++i]);
                } catch (Exception e) {
                    output.sysErrPrintln("WARNING: Skipping method from " + args[i]);
                }
                if (klass == null)
                    continue;
                String name = args[++i];
                String desc = args[++i];
                RVMMethod method = findDeclaredOrFirstMethod(klass, name, desc);
                if (method == null || method.isAbstract() || method.isNative()) {
                    output.sysErrPrintln("WARNING: Skipping method " + args[i - 2] + "." + name);
                } else {
                    processMethod(method, options, isBaseline);
                }
                duplicateOptions();
            } else if ("-performance".equals(arg)) {
                perf = new Performance(output);
            } else if ("-disableClassLoading".equals(arg)) {
                disableClassloading = true;
            } else if ("-er".equals(arg)) {
                executeWithReflection = true;
                RVMClass klass = loadClass(args[++i]);
                String name = args[++i];
                String desc = args[++i];
                NormalMethod method = (NormalMethod) findDeclaredOrFirstMethod(klass, name, desc);
                CompiledMethod cm = null;
                if (method == null) {
                    output.sysErrPrintln("Canceling further option processing to prevent assertion failures.");
                    return;
                }
                if (useBaselineCompiler) {
                    cm = BaselineCompiler.compile(method);
                } else {
                    CompilationPlan cp = new CompilationPlan(method, OptimizationPlanner.createOptimizationPlan(options), null, options);
                    try {
                        cm = OptimizingCompiler.compile(cp);
                    } catch (Throwable e) {
                        output.sysErrPrintln("SKIPPING method:" + method + "Due to exception: " + e);
                    }
                }
                if (cm != null) {
                    method.replaceCompiledMethod(cm);
                    if (printCodeAddress) {
                        output.sysOutPrintln(compiledMethodMessage(method));
                    }
                }
                TypeReference[] argDesc = method.getDescriptor().parseForParameterTypes(klass.getClassLoader());
                Object[] reflectMethodArgs = new Object[argDesc.length];
                i = parseMethodArgs(argDesc, args, i, reflectMethodArgs);
                java.lang.reflect.Method reflectoid = java.lang.reflect.JikesRVMSupport.createMethod(method);
                reflectoidVector.add(reflectoid);
                reflectMethodVector.add(method);
                reflectMethodArgsVector.add(reflectMethodArgs);
                duplicateOptions();
            } else if ("-main".equals(arg)) {
                executeMainMethod = true;
                i++;
                mainClass = loadClass(args[i]);
                i++;
                mainArgs = new String[args.length - i];
                for (int j = 0, z = mainArgs.length; j < z; j++) {
                    mainArgs[j] = args[i + j];
                }
                break;
            } else {
                output.sysErrPrintln("Unrecognized argument: " + arg + " - ignored");
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            output.sysErrPrintln("Uncaught ArrayIndexOutOfBoundsException, possibly" + " not enough command-line arguments - aborting");
            printFormatString();
            e.printStackTrace(output.getSystemErr());
            break;
        } catch (Exception e) {
            output.sysErrPrintln(e.toString());
            e.printStackTrace(output.getSystemErr());
            break;
        }
    }
}
Also used : CompilationPlan(org.jikesrvm.compilers.opt.driver.CompilationPlan) InvocationTargetException(java.lang.reflect.InvocationTargetException) OptimizingCompilerException(org.jikesrvm.compilers.opt.OptimizingCompilerException) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) RVMClass(org.jikesrvm.classloader.RVMClass) RVMMethod(org.jikesrvm.classloader.RVMMethod) NormalMethod(org.jikesrvm.classloader.NormalMethod) TypeReference(org.jikesrvm.classloader.TypeReference) Method(java.lang.reflect.Method)

Aggregations

CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)97 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)56 NormalMethod (org.jikesrvm.classloader.NormalMethod)41 Test (org.junit.Test)33 OptOptions (org.jikesrvm.compilers.opt.OptOptions)32 Address (org.vmmagic.unboxed.Address)30 DefaultInlineOracle (org.jikesrvm.compilers.opt.inlining.DefaultInlineOracle)28 InlineOracle (org.jikesrvm.compilers.opt.inlining.InlineOracle)28 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)20 Offset (org.vmmagic.unboxed.Offset)20 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)19 InlineSequence (org.jikesrvm.compilers.opt.inlining.InlineSequence)17 RVMMethod (org.jikesrvm.classloader.RVMMethod)14 ExceptionHandlerBasicBlockBag (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlockBag)14 TypeReference (org.jikesrvm.classloader.TypeReference)13 BasicBlock (org.jikesrvm.compilers.opt.ir.BasicBlock)13 ExceptionHandlerBasicBlock (org.jikesrvm.compilers.opt.ir.ExceptionHandlerBasicBlock)13 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)13 BaselineCompiledMethod (org.jikesrvm.compilers.baseline.BaselineCompiledMethod)10 RVMClass (org.jikesrvm.classloader.RVMClass)7