publicclass Main { publicstaticvoid main(String[] args) {
System.loadLibrary(args[0]); while (runTests(true));
runTests(false);
runSmaliTest();
}
publicstaticboolean runTests(boolean warmup) { if (warmup) { return isInInterpreter("runTests");
}
// Several local variables which live across calls below, // thus they are likely to be saved in callee save registers. int i = $noinline$magicValue(); long l = $noinline$magicValue(); float f = $noinline$magicValue(); double d = $noinline$magicValue();
// The calls below will OSR. We pass the expected value in // argument, which should be saved in callee save register. if ($noinline$returnInt(53) != 53) { thrownew Error("Unexpected return value");
} if ($noinline$returnFloat(42.2f) != 42.2f) { thrownew Error("Unexpected return value");
} if ($noinline$returnDouble(Double.longBitsToDouble(0xF000000000001111L)) != Double.longBitsToDouble(0xF000000000001111L)) { thrownew Error("Unexpected return value ");
} if ($noinline$returnLong(0xFFFF000000001111L) != 0xFFFF000000001111L) { thrownew Error("Unexpected return value");
}
// Check that the register used in callee did not clober our value. if (i != $noinline$magicValue()) { thrownew Error("Corrupted int local variable in caller");
} if (l != $noinline$magicValue()) { thrownew Error("Corrupted long local variable in caller");
} if (f != $noinline$magicValue()) { thrownew Error("Corrupted float local variable in caller");
} if (d != $noinline$magicValue()) { thrownew Error("Corrupted double local variable in caller");
} returntrue;
}
publicstaticvoid runSmaliTest() { try { Class<?> c = Class.forName("WeirdLoop"); // Make sure `WeirdLoop` is visibly initialized to avoid waiting for OSR // for the `--jit-on=first-use` configuration.
makeVisiblyInitialized(); int result = (int) c.getDeclaredMethod("weirdLoop").invoke(null); if (result != 42) { thrownew Error("Unexpected result: " + result);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
publicstaticint $noinline$returnInt(int result) { // If we are running in non-JIT mode, or were unlucky enough to get this method // already JITted, skip the wait for OSR code. if (isInInterpreter("$noinline$returnInt")) { while (!isInOsrCode("$noinline$returnInt")) {}
} return result;
}
publicstaticfloat $noinline$returnFloat(float result) { // If we are running in non-JIT mode, or were unlucky enough to get this method // already JITted, skip the wait for OSR code. if (isInInterpreter("$noinline$returnFloat")) { while (!isInOsrCode("$noinline$returnFloat")) {}
} return result;
}
publicstaticdouble $noinline$returnDouble(double result) { // If we are running in non-JIT mode, or were unlucky enough to get this method // already JITted, skip the wait for OSR code. if (isInInterpreter("$noinline$returnDouble")) { while (!isInOsrCode("$noinline$returnDouble")) {}
} return result;
}
publicstaticlong $noinline$returnLong(long result) { // If we are running in non-JIT mode, or were unlucky enough to get this method // already JITted, skip the wait for OSR code. if (isInInterpreter("$noinline$returnLong")) { while (!isInOsrCode("$noinline$returnLong")) {}
} return result;
}
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.