Skip to content

Commit

Permalink
[Misc] fix unstable coroutine tests
Browse files Browse the repository at this point in the history
Summary: fix unstable coroutine tests

Test Plan: CI pipeline

Reviewed-by: zhengxiaolinX, yuleil

Issue: dragonwell-project/dragonwell8#273
  • Loading branch information
joeylee.lz committed Nov 25, 2021
1 parent 45373c2 commit 1b40531
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion test/runtime/coroutine/MemLeakTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@

import java.dyn.Coroutine;
import java.io.*;
import sun.misc.SharedSecrets;
import sun.misc.JavaLangAccess;


public class MemLeakTest {
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
private final static Runnable r = () -> {};

public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -72,7 +76,7 @@ private static void testThreadCoroutineLeak() throws Exception {
* After fix : 25436kB -> 25572kB
*/
private static void testUserCreatedCoroutineLeak() throws Exception {
Coroutine threadCoro = Thread.currentThread().getCoroutineSupport().threadCoroutine();
Coroutine threadCoro = JLA.getCoroutineSupport(Thread.currentThread()).threadCoroutine();
// occupy rss
for (int i = 0; i < 200000; i++) {
Coroutine target = new Coroutine(r);
Expand Down
8 changes: 7 additions & 1 deletion test/runtime/coroutine/TestAvoidDeoptCoroutineMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@
import sun.hotspot.WhiteBox;
import java.dyn.Coroutine;
import java.io.*;
import sun.misc.JavaLangAccess;
import sun.misc.SharedSecrets;


public class TestAvoidDeoptCoroutineMethod {
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();


public static void main(String[] args) throws Exception {
WhiteBox whiteBox = WhiteBox.getWhiteBox();
Coroutine threadCoro = Thread.currentThread().getCoroutineSupport().threadCoroutine();
Coroutine threadCoro = JLA.getCoroutineSupport(Thread.currentThread()).threadCoroutine();
runSomeCoroutines(threadCoro);
// deoptimize all
whiteBox.deoptimizeAll();
Expand Down

0 comments on commit 1b40531

Please sign in to comment.