summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2018-01-31 07:45:20 -0800
committer Mathieu Chartier <mathieuc@google.com> 2018-01-31 07:55:22 -0800
commit45caa1d80a16e51a2a84db751eff4908a62ae864 (patch)
tree315c135acc0fd16563c6041954cea7ede6f21d90
parentf346af51a5d44ee0a3cd26e7e0e1b28ec1c5579f (diff)
Make test 044-proxy less flaky
Stop the JIT before filling up the heap. Bug: 69836158 Test: test-art-host Change-Id: Idb488b645cbab1eb3b2eb64f316b79b1bf4e61af
-rw-r--r--test/044-proxy/src/Main.java4
-rw-r--r--test/044-proxy/src/OOMEOnDispatch.java18
-rw-r--r--test/141-class-unload/jni_unload.cc14
-rw-r--r--test/common/runtime_state.cc21
4 files changed, 32 insertions, 25 deletions
diff --git a/test/044-proxy/src/Main.java b/test/044-proxy/src/Main.java
index e44c122e3d..7b70e65b8c 100644
--- a/test/044-proxy/src/Main.java
+++ b/test/044-proxy/src/Main.java
@@ -54,4 +54,8 @@ public class Main {
private static final HashMap<String, String> proxyClassNameMap = new HashMap<String, String>();
private static int uniqueTestProxyClassNum = 0;
+
+ static native void startJit();
+ static native void stopJit();
+ static native void waitForCompilation();
}
diff --git a/test/044-proxy/src/OOMEOnDispatch.java b/test/044-proxy/src/OOMEOnDispatch.java
index 94f267980d..2ee57926ae 100644
--- a/test/044-proxy/src/OOMEOnDispatch.java
+++ b/test/044-proxy/src/OOMEOnDispatch.java
@@ -32,6 +32,11 @@ public class OOMEOnDispatch implements InvocationHandler {
OOMEInterface.class.getClassLoader(), new Class[] { OOMEInterface.class },
handler);
+ // Stop the JIT to be sure nothing is running that could be resolving classes or causing
+ // verification.
+ Main.stopJit();
+ Main.waitForCompilation();
+
int l = 1024 * 1024;
while (l > 8) {
try {
@@ -40,17 +45,6 @@ public class OOMEOnDispatch implements InvocationHandler {
l = l/2;
}
}
- // Have an extra run with the exact size of Method objects. The above loop should have
- // filled with enough large objects for simplicity and speed, but ensure exact allocation
- // size.
- final int methodAsByteArrayLength = 40 - 12; // Method size - byte array overhead.
- for (;;) {
- try {
- storage.add(new byte[methodAsByteArrayLength]);
- } catch (OutOfMemoryError e) {
- break;
- }
- }
try {
inf.foo();
@@ -60,6 +54,8 @@ public class OOMEOnDispatch implements InvocationHandler {
storage.clear();
System.out.println("Received OOME");
}
+
+ Main.startJit();
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
diff --git a/test/141-class-unload/jni_unload.cc b/test/141-class-unload/jni_unload.cc
index 355457d68d..894ae8b0d7 100644
--- a/test/141-class-unload/jni_unload.cc
+++ b/test/141-class-unload/jni_unload.cc
@@ -32,19 +32,5 @@ extern "C" JNIEXPORT void JNICALL Java_IntHolder_waitForCompilation(JNIEnv*, jcl
}
}
-extern "C" JNIEXPORT void JNICALL Java_Main_stopJit(JNIEnv*, jclass) {
- jit::Jit* jit = Runtime::Current()->GetJit();
- if (jit != nullptr) {
- jit->Stop();
- }
-}
-
-extern "C" JNIEXPORT void JNICALL Java_Main_startJit(JNIEnv*, jclass) {
- jit::Jit* jit = Runtime::Current()->GetJit();
- if (jit != nullptr) {
- jit->Start();
- }
-}
-
} // namespace
} // namespace art
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index c2408b0d2f..84993483f2 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -297,4 +297,25 @@ extern "C" JNIEXPORT jboolean JNICALL Java_Main_isClassMoveable(JNIEnv*,
return runtime->GetHeap()->IsMovableObject(klass);
}
+extern "C" JNIEXPORT void JNICALL Java_Main_waitForCompilation(JNIEnv*, jclass) {
+ jit::Jit* jit = Runtime::Current()->GetJit();
+ if (jit != nullptr) {
+ jit->WaitForCompilationToFinish(Thread::Current());
+ }
+}
+
+extern "C" JNIEXPORT void JNICALL Java_Main_stopJit(JNIEnv*, jclass) {
+ jit::Jit* jit = Runtime::Current()->GetJit();
+ if (jit != nullptr) {
+ jit->Stop();
+ }
+}
+
+extern "C" JNIEXPORT void JNICALL Java_Main_startJit(JNIEnv*, jclass) {
+ jit::Jit* jit = Runtime::Current()->GetJit();
+ if (jit != nullptr) {
+ jit->Start();
+ }
+}
+
} // namespace art