hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java
changeset 27917 c5937f7b4e8b
parent 27642 8c9eff693145
child 28190 5a6b07edeb21
--- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java	Mon Dec 01 22:41:16 2014 +0300
+++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java	Tue Dec 02 12:36:03 2014 +0300
@@ -29,10 +29,11 @@
 import sun.hotspot.WhiteBox;
 import sun.hotspot.code.BlobType;
 import com.oracle.java.testlibrary.Asserts;
+import com.oracle.java.testlibrary.InfiniteLoop;
 
 /*
  * @test AllocationCodeBlobTest
- * @bug 8059624
+ * @bug 8059624 8064669
  * @library /testlibrary /testlibrary/whitebox
  * @build AllocationCodeBlobTest
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
@@ -53,11 +54,32 @@
 
     public static void main(String[] args) {
         // check that Sweeper handels dummy blobs correctly
-        new ForcedSweeper(500).start();
+        Thread t = new Thread(
+                new InfiniteLoop(WHITE_BOX::forceNMethodSweep, 1L),
+                "ForcedSweeper");
+        t.setDaemon(true);
+        System.out.println("Starting " + t.getName());
+        t.start();
+
         EnumSet<BlobType> blobTypes = BlobType.getAvailable();
         for (BlobType type : blobTypes) {
             new AllocationCodeBlobTest(type).test();
         }
+
+        // check that deoptimization works well w/ dummy blobs
+        t = new Thread(
+                new InfiniteLoop(WHITE_BOX::deoptimizeAll, 1L),
+                "Deoptimize Thread");
+        t.setDaemon(true);
+        System.out.println("Starting " + t.getName());
+        t.start();
+
+        for (int i = 0; i < 10_000; ++i) {
+            for (BlobType type : blobTypes) {
+                long addr = WHITE_BOX.allocateCodeBlob(SIZE, type.id);
+            }
+        }
+
     }
 
     private final BlobType type;
@@ -105,24 +127,4 @@
     private long getUsage() {
         return bean.getUsage().getUsed();
     }
-
-    private static class ForcedSweeper extends Thread {
-        private final int millis;
-        public ForcedSweeper(int millis) {
-            super("ForcedSweeper");
-            setDaemon(true);
-            this.millis = millis;
-        }
-        public void run() {
-            try {
-                while (true) {
-                    WHITE_BOX.forceNMethodSweep();
-                    Thread.sleep(millis);
-                }
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                throw new Error(e);
-            }
-        }
-    }
 }