< prev index next >

test/compiler/loopopts/UseCountedLoopSafepoints.java

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


  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 /**
  26  * @test
  27  * @bug 6869327
  28  * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop
  29  * @library /testlibrary
  30  * @modules java.base/jdk.internal.misc
  31  * @modules java.base
  32  * @ignore 8146096
  33  * @run main UseCountedLoopSafepoints
  34  */
  35 
  36 import java.util.concurrent.atomic.AtomicLong;
  37 import jdk.test.lib.ProcessTools;
  38 import jdk.test.lib.OutputAnalyzer;

  39 


  40 public class UseCountedLoopSafepoints {
  41     private static final AtomicLong _num = new AtomicLong(0);
  42 
  43     // Uses the fact that an EnableBiasedLocking vmop will be started
  44     // after 500ms, while we are still in the loop. If there is a
  45     // safepoint in the counted loop, then we will reach safepoint
  46     // very quickly. Otherwise SafepointTimeout will be hit.
  47     public static void main (String args[]) throws Exception {
  48         if (args.length == 1) {
  49             final int loops = Integer.parseInt(args[0]);
  50             for (int i = 0; i < loops; i++) {
  51                 _num.addAndGet(1);
  52             }
  53         } else {
  54             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  55                     "-XX:+IgnoreUnrecognizedVMOptions",
  56                     "-XX:-TieredCompilation",
  57                     "-XX:+UseBiasedLocking",
  58                     "-XX:BiasedLockingStartupDelay=500",
  59                     "-XX:+SafepointTimeout",
  60                     "-XX:SafepointTimeoutDelay=2000",
  61                     "-XX:+UseCountedLoopSafepoints",
  62                     "UseCountedLoopSafepoints",
  63                     "2000000000"
  64                     );
  65             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  66             output.shouldNotContain("Timeout detected");
  67             output.shouldHaveExitValue(0);
  68         }
  69     }
  70 }


  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 /**
  26  * @test
  27  * @bug 6869327
  28  * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop
  29  * @library /testlibrary
  30  * @modules java.base/jdk.internal.misc

  31  * @ignore 8146096
  32  * @run driver compiler.loopopts.UseCountedLoopSafepoints
  33  */
  34 
  35 package compiler.loopopts;
  36 
  37 import jdk.test.lib.OutputAnalyzer;
  38 import jdk.test.lib.ProcessTools;
  39 
  40 import java.util.concurrent.atomic.AtomicLong;
  41 
  42 public class UseCountedLoopSafepoints {
  43     private static final AtomicLong _num = new AtomicLong(0);
  44 
  45     // Uses the fact that an EnableBiasedLocking vmop will be started
  46     // after 500ms, while we are still in the loop. If there is a
  47     // safepoint in the counted loop, then we will reach safepoint
  48     // very quickly. Otherwise SafepointTimeout will be hit.
  49     public static void main (String args[]) throws Exception {
  50         if (args.length == 1) {
  51             final int loops = Integer.parseInt(args[0]);
  52             for (int i = 0; i < loops; i++) {
  53                 _num.addAndGet(1);
  54             }
  55         } else {
  56             ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  57                     "-XX:+IgnoreUnrecognizedVMOptions",
  58                     "-XX:-TieredCompilation",
  59                     "-XX:+UseBiasedLocking",
  60                     "-XX:BiasedLockingStartupDelay=500",
  61                     "-XX:+SafepointTimeout",
  62                     "-XX:SafepointTimeoutDelay=2000",
  63                     "-XX:+UseCountedLoopSafepoints",
  64                     UseCountedLoopSafepoints.class.getName(),
  65                     "2000000000"
  66                     );
  67             OutputAnalyzer output = new OutputAnalyzer(pb.start());
  68             output.shouldNotContain("Timeout detected");
  69             output.shouldHaveExitValue(0);
  70         }
  71     }
  72 }
< prev index next >