Fix String.init tests with baseline JIT.
Baseline JIT doesn't do deoptimizations, but the test assumes compiled
code will. Adjust the test to call ensureJitCompiled to force
non-baseline compilation.
Test: testrunner.py --host --64 --jit -t 563 -t 575
Bug: 147209001
Change-Id: I062650e07616610b01415e3add193687fcc35e30
diff --git a/test/563-checker-fakestring/src/Main.java b/test/563-checker-fakestring/src/Main.java
index 77a108f..1ca80f0 100644
--- a/test/563-checker-fakestring/src/Main.java
+++ b/test/563-checker-fakestring/src/Main.java
@@ -22,6 +22,7 @@
class Inner {}
public static native void assertIsInterpreted();
+ public static native void ensureJitCompiled(Class<?> cls, String methodName);
public static void assertEqual(String expected, String actual) {
if (!expected.equals(actual)) {
@@ -53,6 +54,8 @@
}
{
+ // If the JIT is enabled, ensure it has compiled the method to force the deopt.
+ ensureJitCompiled(c, "deoptimizeNewInstance");
Method m = c.getMethod("deoptimizeNewInstance", int[].class, byte[].class);
try {
m.invoke(null, new Object[] { new int[] { 1, 2, 3 }, testData });
@@ -114,6 +117,8 @@
assertEqual(testString, result);
}
{
+ // If the JIT is enabled, ensure it has compiled the method to force the deopt.
+ ensureJitCompiled(c, "deoptimizeNewInstanceAfterLoop");
Method m = c.getMethod(
"deoptimizeNewInstanceAfterLoop", int[].class, byte[].class, int.class);
try {
diff --git a/test/575-checker-string-init-alias/src/Main.java b/test/575-checker-string-init-alias/src/Main.java
index 1ab3207..b55b0c5 100644
--- a/test/575-checker-string-init-alias/src/Main.java
+++ b/test/575-checker-string-init-alias/src/Main.java
@@ -23,6 +23,7 @@
class Inner {}
public static native void assertIsInterpreted();
+ public static native void ensureJitCompiled(Class<?> cls, String methodName);
private static void assertEqual(String expected, String actual) {
if (!expected.equals(actual)) {
@@ -36,6 +37,8 @@
int[] array = new int[1];
{
+ // If the JIT is enabled, ensure it has compiled the method to force the deopt.
+ ensureJitCompiled(c, "testNoAlias");
Method m = c.getMethod("testNoAlias", int[].class, String.class);
try {
m.invoke(null, new Object[] { array , "foo" });
@@ -51,6 +54,8 @@
}
{
+ // If the JIT is enabled, ensure it has compiled the method to force the deopt.
+ ensureJitCompiled(c, "testAlias");
Method m = c.getMethod("testAlias", int[].class, String.class);
try {
m.invoke(null, new Object[] { array, "bar" });