use of org.jikesrvm.classloader.NormalMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method createMostlyEmptyContext.
private static GenerationContext createMostlyEmptyContext(String methodName) throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, methodName);
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
return gc;
}
use of org.jikesrvm.classloader.NormalMethod 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);
}
use of org.jikesrvm.classloader.NormalMethod in project JikesRVM by JikesRVM.
the class GenerationContextTest method localRegAlwaysReturnsSameRegisterForSameArguments.
@Test
public void localRegAlwaysReturnsSameRegisterForSameArguments() throws Exception {
NormalMethod nm = TestingTools.getNormalMethod(MethodsForTests.class, "emptyInstanceMethodWithoutAnnotations");
OptOptions opts = new OptOptions();
GenerationContext gc = new GenerationContext(nm, null, null, opts, null);
Register regExpected = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
Register regActual = gc.localReg(0, nm.getDeclaringClass().getTypeRef());
assertSame(regActual, regExpected);
}
use of org.jikesrvm.classloader.NormalMethod 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);
}
use of org.jikesrvm.classloader.NormalMethod 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;
}
}
}
Aggregations