use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class MethodCountData method report.
/**
* Print the counted (nonzero) methods.
* To get a sorted list, pipe the output through sort -n -r.
*/
@Override
public synchronized void report() {
RVMThread.dumpLock.lockNoHandshake();
VM.sysWriteln("Method counts: A total of " + totalCountsTaken + " samples");
for (int i = 1; i < nextIndex; i++) {
double percent = 100 * countsToHotness(counts[i]);
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmids[i]);
VM.sysWrite(counts[i] + " (" + percent + "%) ");
if (cm == null) {
// Compiled Method Obsolete
VM.sysWriteln("OBSOLETE");
} else {
if (cm.getCompilerType() == CompiledMethod.TRAP) {
VM.sysWriteln("<Hardware Trap Frame>");
} else {
RVMMethod m = cm.getMethod();
VM.sysWrite(m);
if (m.getDeclaringClass().isInBootImage()) {
VM.sysWrite("\tBOOT");
}
}
VM.sysWriteln();
}
}
RVMThread.dumpLock.unlock();
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class DynamicCallFileInfoReader method readOneCallSiteAttribute.
private static void readOneCallSiteAttribute(StringTokenizer parser, boolean boot) {
String firstToken = parser.nextToken();
if (firstToken.equals("CallSite")) {
try {
MemberReference callerKey = MemberReference.parse(parser, boot);
if (callerKey == null)
return;
MethodReference callerRef = callerKey.asMethodReference();
RVMMethod caller, callee;
caller = getMethod(callerRef);
// serves as doco - token skipped
@SuppressWarnings("unused") int callerSize = Integer.parseInt(parser.nextToken());
int bci = Integer.parseInt(parser.nextToken());
MemberReference calleeKey = MemberReference.parse(parser, boot);
if (calleeKey == null)
return;
MethodReference calleeRef = calleeKey.asMethodReference();
callee = getMethod(calleeRef);
// serves as doco - token skipped
@SuppressWarnings("unused") int calleeSize = Integer.parseInt(parser.nextToken());
// skip "weight:"
parser.nextToken();
float weight = Float.parseFloat(parser.nextToken());
if ((caller == null) || (callee == null)) {
Controller.dcg.incrementUnResolvedEdge(callerRef, bci, calleeRef, weight);
} else {
Controller.dcg.incrementEdge(caller, bci, callee, weight);
}
} catch (Exception e) {
VM.sysWriteln("Caught exception: " + e);
}
} else {
VM.sysFail("Format error in dynamic call graph file");
}
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class TailRecursionEliminationTest method callsWithNoTailCallEliminationAnnotationArentSubjectToOptimization.
@Test
public void callsWithNoTailCallEliminationAnnotationArentSubjectToOptimization() throws Exception {
Class<?>[] types = {};
RVMMethod m = TestingTools.getNormalMethod(MethodsForTests.class, "emptyStaticMethodWithNoTailCallEliminationAnnotation", types);
MethodOperand methOp = MethodOperand.STATIC(m);
Instruction call = Call.create(CALL, null, null, methOp, 0);
assertFalse(tailRecursionElimination.allowedToOptimize(call));
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class OptTestHarness method findDeclaredOrFirstMethod.
/**
* Finds a method, either one with a given descriptor or the first matching
* one in in the given class.
* @param klass the class to search
* @param methname the method's name
* @param methdesc a descriptor of the method's signature if a specific
* method is desired or "-" to find the first method with the given name
* @return the method or {@code null} if no method was found
*/
RVMMethod findDeclaredOrFirstMethod(RVMClass klass, String methname, String methdesc) {
if (klass == null)
return null;
Atom methodName = Atom.findOrCreateAsciiAtom(methname);
Atom methodDesc = "-".equals(methdesc) ? null : Atom.findOrCreateAsciiAtom(methdesc);
for (RVMMethod method : klass.getDeclaredMethods()) {
if (method.getName() == methodName && ((methodDesc == null) || (methodDesc == method.getDescriptor()))) {
return method;
}
}
if (methodDesc == null) {
output.sysErrPrintln("No method named " + methodName + " found in class " + klass);
} else {
output.sysErrPrintln("No method matching " + methodName + " " + methodDesc + " found in class " + klass);
}
return null;
}
use of org.jikesrvm.classloader.RVMMethod 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