test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java
author iignatyev
Wed, 13 Nov 2019 10:59:25 -0800
changeset 59063 058d299b22b6
parent 54119 6bf8877eb1b9
permissions -rw-r--r--
8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay Reviewed-by: kvn, epavlova, roland, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     1
/*
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     2
 * Copyright (c) 2019, SAP SE. All rights reserved.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     4
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     8
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    13
 * accompanied this code).
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    14
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    18
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    21
 * questions.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    22
 */
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    23
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    24
/**
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    25
 * @test
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    26
 * @bug 8220374
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    27
 * @summary C2: LoopStripMining doesn't strip as expected
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    28
 * @requires vm.compiler2.enabled
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    29
 *
59063
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    30
 * @library /test/lib
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    31
 * @run driver compiler.loopstripmining.CheckLoopStripMining
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    32
 */
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    33
59063
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    34
package compiler.loopstripmining;
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    35
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    36
import jdk.test.lib.Utils;
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    37
import jdk.test.lib.process.ProcessTools;
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    38
59063
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    39
public class CheckLoopStripMining {
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    40
  public static void main(String args[]) throws Exception {
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    41
    ProcessTools.executeTestJvm(
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    42
        "-XX:+UnlockDiagnosticVMOptions",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    43
        // to prevent biased locking handshakes from changing the timing of this test
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    44
        "-XX:-UseBiasedLocking",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    45
        "-XX:+SafepointTimeout",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    46
        "-XX:+SafepointALot",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    47
        "-XX:+AbortVMOnSafepointTimeout",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    48
        "-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(500),
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    49
        "-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(500),
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    50
        "-XX:-TieredCompilation",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    51
        "-XX:+UseCountedLoopSafepoints",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    52
        "-XX:LoopStripMiningIter=1000",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    53
        "-XX:LoopUnrollLimit=0",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    54
        "-XX:CompileCommand=compileonly,compiler.loopstripmining.CheckLoopStripMining$Test::test_loop",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    55
        "-Xcomp",
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    56
        Test.class.getName()).shouldHaveExitValue(0)
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    57
                             .stdoutShouldContain("sum: 715827882");
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    58
  }
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    59
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    60
  public static class Test {
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    61
    public static int test_loop(int x) {
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    62
      int sum = 0;
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    63
      if (x != 0) {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    64
          for (int y = 1; y < Integer.MAX_VALUE; ++y) {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    65
              if (y % x == 0) ++sum;
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    66
          }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    67
      }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    68
      return sum;
59063
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    69
    }
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    70
59063
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    71
    public static void main(String args[]) {
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    72
      int sum = test_loop(3);
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    73
      System.out.println("sum: " + sum);
058d299b22b6 8225756: [testbug] compiler/loopstripmining/CheckLoopStripMining.java sets too short a SafepointTimeoutDelay
iignatyev
parents: 54119
diff changeset
    74
    }
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    75
  }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    76
}