// Methods with non-deterministic output that should not be printed. static List<Predicate<Executable>> NON_DETERMINISTIC_OUTPUT_METHODS = new ArrayList<>(); static List<Predicate<Executable>> NON_DETERMINISTIC_OUTPUT_TYPE_METHODS = new ArrayList<>(); static List<Class<?>> NON_DETERMINISTIC_TYPE_NAMES = new ArrayList<>();
static String methodToString(Executable m) { // Make the output more similar between ART and RI, // by removing the 'native' specifier from methods.
String methodStr; if (NON_DETERMINISTIC_TYPE_NAMES.contains(m.getDeclaringClass())) {
methodStr = m.toString().replace(m.getDeclaringClass().getName(), "<non-deterministic-type " +
NON_DETERMINISTIC_TYPE_NAMES.indexOf(m.getDeclaringClass()) + ">");
} else {
methodStr = m.toString();
} return methodStr.replaceFirst(" native", "");
}
staticvoid addToResults(Printable obj) { // Reserve space for the current object. If any other method entry callbacks are called they // will reserve more space. Without this we may get into strange problems where ArrayList::add // cecks there is enough space (which involves a couple of method calls) which then use up the // space and by the time we actually add this record there is no capacity left.
results_index++;
results.ensureCapacity(results_index + 1);
results.add(obj);
}
// Iterative version staticfinalclass IterOp implements IntUnaryOperator { publicint applyAsInt(int x) { return iter_fibonacci(x);
}
} staticint iter_fibonacci(int n) { if (n < 0) { thrownew Error("Bad argument: " + n + " < 0");
} elseif (n == 0) { return0;
} int x = 1; int y = 1; for (int i = 3; i <= n; i++) { int z = x + y;
x = y;
y = z;
} return y;
}
publicstaticvoid notifyMethodEntry(Executable m) { // Called by native code when a method is entered. This method is ignored by the native // entry and exit hooks.
cnt++; if ((cnt - 1) > METHOD_TRACING_IGNORE_DEPTH && sMethodTracingIgnore) { return;
}
addToResults(new MethodEntry(m, cnt - 1));
}
publicstaticvoid notifyMethodExit(Executable m, boolean exception, Object result) {
cnt--;
if (cnt > METHOD_TRACING_IGNORE_DEPTH && sMethodTracingIgnore) { return;
}
publicstaticvoid run() throws Exception { // call this here so it is linked. It doesn't actually do anything here.
loadAllClasses();
Trace.disableTracing(Thread.currentThread()); // Call this prior to starting tracing since its implementation is so deep into reflection // that it will be changing all the time and difficult to keep up with.
Runnable runnable = (Runnable)Proxy.newProxyInstance(
Test988.class.getClassLoader(), newClass[]{ Runnable.class }, new TestRunnableInvokeHandler());
Trace.enableMethodTracing(
Test988.class,
Test988.class.getDeclaredMethod("notifyMethodEntry", Executable.class),
Test988.class.getDeclaredMethod( "notifyMethodExit", Executable.class, Boolean.TYPE, Object.class), Thread.currentThread());
doFibTest(30, new IterOp());
doFibTest(5, new RecurOp());
doFibTest(5, new NativeOp());
doFibTest(-19, new IterOp());
doFibTest(-19, new RecurOp());
doFibTest(-19, new NativeOp());
runnable.run();
sMethodTracingIgnore = true;
IntrinsicsTest.doTest();
sMethodTracingIgnore = false; // Turn off method tracing so we don't have to deal with print internals.
Trace.disableTracing(Thread.currentThread());
printResults();
}
// This ensures that all classes we touch are loaded before we start recording traces. This // eliminates a major source of divergence between the RI and ART. publicstaticvoid loadAllClasses() {
MethodThrownThrough.class.toString();
MethodEntry.class.toString();
MethodReturn.class.toString();
FibResult.class.toString();
FibThrow.class.toString();
Printable.class.toString();
ArrayList.class.toString();
RecurOp.class.toString();
IterOp.class.toString();
NativeOp.class.toString();
StringBuilder.class.toString();
Runnable.class.toString();
TestRunnableInvokeHandler.class.toString();
Proxy.class.toString();
Proxy.getProxyClass(
Test988.class.getClassLoader(), newClass[] { Runnable.class }).toString();
IntrinsicsTest.initialize(); // ensure <clinit> is executed prior to tracing.
}
publicstaticvoid printResults() { for (Printable p : results) {
p.Print();
}
}
// Pre-load all classes used in #doTest manual intrinsics.
java.lang.System.class.toString();
} staticvoid doTest() { // Ensure that the ART intrinsics in intrinsics_list.h are also being traced, // since in non-tracing operation they are effectively inlined by the optimizing compiler.
// Auto-generated test file that uses null/0s as default parameters.
Test988Intrinsics.test();
// Manual list here for functions that require special non-null/non-zero parameters:
System.arraycopy(sSourceArray, 0, sDestArray, 0, 1);
System.arraycopy(sSourceArrayChar, 0, sDestArrayChar, 0, 1);
}
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.