hotspot/test/compiler/interpreter/DisableOSRTest.java
author lana
Thu, 23 Feb 2017 17:30:12 +0000
changeset 44011 5eea3031ae7b
parent 40631 ed82623d7831
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     1
/*
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     2
 * Copyright (c) 2016 SAP SE. All rights reserved.
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     4
 *
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     8
 *
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    13
 * accompanied this code).
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    14
 *
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    18
 *
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    21
 * questions.
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    22
 */
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    23
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    24
/*
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    25
 * @test
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    26
 * @bug 8159620
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    27
 * @summary testing that -XX:-UseOnStackReplacement works with both -XX:(+/-)TieredCompilation
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    28
 * @modules java.base/jdk.internal.misc
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40059
diff changeset
    29
 * @library /test/lib /
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    30
 *
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    31
 * @build sun.hotspot.WhiteBox
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    32
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    33
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    34
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+PrintCompilation
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    35
 *                   -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    36
 *                   compiler.interpreter.DisableOSRTest
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    37
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+PrintCompilation
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    38
 *                   -XX:-BackgroundCompilation -XX:+TieredCompilation -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    39
 *                   compiler.interpreter.DisableOSRTest
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    40
 */
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    41
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    42
package compiler.interpreter;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    43
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    44
import sun.hotspot.WhiteBox;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 40022
diff changeset
    45
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    46
import java.lang.reflect.Method;
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    47
import java.util.Random;
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    48
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    49
public class DisableOSRTest {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    50
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    51
    private static final Random RANDOM = new Random();
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    52
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    53
    public static int foo() {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    54
        return RANDOM.nextInt();
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    55
    }
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    56
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    57
    public static void main(String[] args) throws Exception {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    58
        Method m = DisableOSRTest.class.getMethod("main", String[].class);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    59
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    60
        for (int i = 0; i < 100_000; i++) {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    61
            foo();
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    62
        }
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    63
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    64
        if (WB.isMethodCompiled(m, true /* isOsr */)) {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    65
            throw new RuntimeException("\"" + m + "\" shouldn't be OSR compiled if running with -XX:-UseOnStackReplacement!");
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    66
        }
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    67
    }
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents:
diff changeset
    68
}