< prev index next >

test/compiler/c2/Test6912517.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke

   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 6912517
  27  * @summary JIT bug compiles out (and stops running) code that needs to be run.  Causes NPE.
  28  *
  29  * @run main/othervm -Xbatch -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops Test

  30  */
  31 


  32 /**
  33  * Highlights a bug with the JIT compiler.
  34  * @author Matt Bruce m b r u c e __\at/__ g m a i l DOT c o m
  35  */
  36 public class Test implements Runnable
  37 {
  38     private final Thread myThread;
  39     private Thread       myInitialThread;
  40     private boolean      myShouldCheckThreads;
  41 
  42     /**
  43      * Sets up the running thread, and starts it.
  44      */
  45     public Test(int id)
  46     {
  47         myThread = new Thread(this);
  48         myThread.setName("Runner: " + id);
  49         myThread.start();
  50         myShouldCheckThreads = false;
  51     }
  52 
  53     /**
  54      * @param shouldCheckThreads the shouldCheckThreads to set
  55      */
  56     public void setShouldCheckThreads(boolean shouldCheckThreads)
  57     {
  58         myShouldCheckThreads = shouldCheckThreads;
  59     }
  60 
  61     /**
  62      * Starts up the two threads with enough delay between them for JIT to
  63      * kick in.
  64      * @param args
  65      * @throws InterruptedException
  66      */
  67     public static void main(String[] args) throws InterruptedException
  68     {
  69         // let this run for a bit, so the "run" below is JITTed.
  70         for (int id = 0; id < 20; id++) {
  71             System.out.println("Starting thread: " + id);
  72             Test bug = new Test(id);
  73             bug.setShouldCheckThreads(true);
  74             Thread.sleep(2500);
  75         }
  76     }
  77 
  78     /**
  79      * @see java.lang.Runnable#run()
  80      */
  81     public void run()
  82     {
  83         long runNumber = 0;
  84         while (true) {
  85             // run hot for a little while, give JIT time to kick in to this loop.
  86             // then run less hot.
  87             if (runNumber > 15000) {
  88                 try {
  89                     Thread.sleep(5);
  90                 }
  91                 catch (InterruptedException e) {
  92                     e.printStackTrace();



   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 6912517
  27  * @summary JIT bug compiles out (and stops running) code that needs to be run.  Causes NPE.
  28  *
  29  * @run main/othervm -Xbatch -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops
  30  *      compiler.c2.Test6912517
  31  */
  32 
  33 package compiler.c2;
  34 
  35 /**
  36  * Highlights a bug with the JIT compiler.
  37  * @author Matt Bruce m b r u c e __\at/__ g m a i l DOT c o m
  38  */
  39 public class Test6912517 implements Runnable
  40 {
  41     private final Thread myThread;
  42     private Thread       myInitialThread;
  43     private boolean      myShouldCheckThreads;
  44 
  45     /**
  46      * Sets up the running thread, and starts it.
  47      */
  48     public Test6912517(int id)
  49     {
  50         myThread = new Thread(this);
  51         myThread.setName("Runner: " + id);
  52         myThread.start();
  53         myShouldCheckThreads = false;
  54     }
  55 
  56     /**
  57      * @param shouldCheckThreads the shouldCheckThreads to set
  58      */
  59     public void setShouldCheckThreads(boolean shouldCheckThreads)
  60     {
  61         myShouldCheckThreads = shouldCheckThreads;
  62     }
  63 
  64     /**
  65      * Starts up the two threads with enough delay between them for JIT to
  66      * kick in.
  67      * @param args
  68      * @throws InterruptedException
  69      */
  70     public static void main(String[] args) throws InterruptedException
  71     {
  72         // let this run for a bit, so the "run" below is JITTed.
  73         for (int id = 0; id < 20; id++) {
  74             System.out.println("Starting thread: " + id);
  75             Test6912517 bug = new Test6912517(id);
  76             bug.setShouldCheckThreads(true);
  77             Thread.sleep(2500);
  78         }
  79     }
  80 
  81     /**
  82      * @see java.lang.Runnable#run()
  83      */
  84     public void run()
  85     {
  86         long runNumber = 0;
  87         while (true) {
  88             // run hot for a little while, give JIT time to kick in to this loop.
  89             // then run less hot.
  90             if (runNumber > 15000) {
  91                 try {
  92                     Thread.sleep(5);
  93                 }
  94                 catch (InterruptedException e) {
  95                     e.printStackTrace();


< prev index next >