< prev index next >

test/hotspot/jtreg/compiler/runtime/TestFloatsOnStackDeopt.java

Print this page

        

@@ -37,10 +37,11 @@
     private static final int ARRLEN = 97;
     private static final int ITERS1 = 100;
     private static final int ITERS2 = 40000;
     private static final float VALUE = 15.f;
     public static String dummyString = "long long string";
+    static volatile boolean pleaseStop = false;
 
     static void run_loop_with_safepoint(float[] a0, float b) {
         // Non-counted loop with safepoint.
         for (long l = 0; l < ITERS2; l++) {
             // Counted and vectorized loop.

@@ -52,13 +53,13 @@
 
     static int test() {
         // thread provokes frequent GC - together with +DeoptimizeALot and safepoint it forces executed function deoptimization
         Thread th = new Thread() {
             public void run() {
-                while(true) {
+                while (!pleaseStop) {
                     synchronized(this) { try { wait(1); } catch (Exception ex) {} }
-                    dummyString += dummyString;
+                    dummyString = new StringBuilder(dummyString).append(dummyString).toString();
                     if (dummyString.length() > 1024*1024) { dummyString = "long long string"; }
                 }
             }
         };
         th.start();

@@ -75,11 +76,16 @@
                 x0[i] = 0.f; // Reset
             }
             if (errn > 0) break;
         }
 
-        th.stop();
+        pleaseStop = true;
+        try {
+            th.join();
+        } catch (InterruptedException e) {
+            throw new Error("InterruptedException in main thread ", e);
+        }
         return errn;
     }
 
     public static void main(String args[]) {
         int errn = test();
< prev index next >