hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java
author iignatyev
Tue, 26 Jan 2016 00:25:20 +0300
changeset 35596 07098f03eb07
parent 35084 5b34a4ae0f58
child 38152 80e5da81fb2c
permissions -rw-r--r--
8148161: quarantine compiler/loopopts/UseCountedLoopSafepoints.java Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35084
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     1
/*
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     4
 *
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     8
 *
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    13
 * accompanied this code).
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    14
 *
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    18
 *
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    21
 * questions.
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    22
 *
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    23
 */
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    24
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    25
/**
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    26
 * @test
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    27
 * @bug 6869327
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    28
 * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    29
 * @library /testlibrary
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    30
 * @modules java.base
35596
07098f03eb07 8148161: quarantine compiler/loopopts/UseCountedLoopSafepoints.java
iignatyev
parents: 35084
diff changeset
    31
 * @ignore 8146096
35084
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    32
 * @run main UseCountedLoopSafepoints
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    33
 */
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    34
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    35
import java.util.concurrent.atomic.AtomicLong;
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    36
import jdk.test.lib.ProcessTools;
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    37
import jdk.test.lib.OutputAnalyzer;
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    38
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    39
public class UseCountedLoopSafepoints {
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    40
    private static final AtomicLong _num = new AtomicLong(0);
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    41
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    42
    // Uses the fact that an EnableBiasedLocking vmop will be started
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    43
    // after 500ms, while we are still in the loop. If there is a
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    44
    // safepoint in the counted loop, then we will reach safepoint
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    45
    // very quickly. Otherwise SafepointTimeout will be hit.
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    46
    public static void main (String args[]) throws Exception {
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    47
        if (args.length == 1) {
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    48
            final int loops = Integer.parseInt(args[0]);
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    49
            for (int i = 0; i < loops; i++) {
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    50
                _num.addAndGet(1);
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    51
            }
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    52
        } else {
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    53
            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    54
                    "-XX:+IgnoreUnrecognizedVMOptions",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    55
                    "-XX:-TieredCompilation",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    56
                    "-XX:+UseBiasedLocking",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    57
                    "-XX:BiasedLockingStartupDelay=500",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    58
                    "-XX:+SafepointTimeout",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    59
                    "-XX:SafepointTimeoutDelay=2000",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    60
                    "-XX:+UseCountedLoopSafepoints",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    61
                    "UseCountedLoopSafepoints",
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    62
                    "2000000000"
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    63
                    );
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    64
            OutputAnalyzer output = new OutputAnalyzer(pb.start());
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    65
            output.shouldNotContain("Timeout detected");
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    66
            output.shouldHaveExitValue(0);
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    67
        }
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    68
    }
5b34a4ae0f58 6869327: Add new C2 flag to keep safepoints in counted loops.
aeriksso
parents:
diff changeset
    69
}