hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java
author iveresov
Fri, 19 Aug 2016 15:29:57 -0700
changeset 40866 3eef10047a6b
parent 40631 ed82623d7831
child 42607 acd91f1875d4
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40067
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     4
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     8
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    13
 * accompanied this code).
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    14
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    18
 *
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    21
 * questions.
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    22
 */
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    23
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    24
/*
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    25
 * @test
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    26
 * @bug 8136421
39291
a4efe145313d 8157831: JVMCI tests should not be executed on linux-arm32
lmesnik
parents: 38152
diff changeset
    27
 * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9" | vm.simpleArch == "aarch64")
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40067
diff changeset
    28
 * @library / /test/lib
40067
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    29
 *          ../common/patches
38152
80e5da81fb2c 8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents: 36508
diff changeset
    30
 * @modules java.base/jdk.internal.misc
40067
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    31
 *          jdk.vm.ci/jdk.vm.ci.hotspot
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    32
 *
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    33
 * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
40067
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    34
 *        sun.hotspot.WhiteBox
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    35
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    36
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    37
 * @run main/othervm -Xbootclasspath/a:.
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    38
 *                   -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    39
 *                   -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35148
diff changeset
    40
 *                   compiler.jvmci.compilerToVM.IsMatureTest
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    41
 */
34219
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    42
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    43
package compiler.jvmci.compilerToVM;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    44
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    45
import compiler.jvmci.common.testcases.SimpleClass;
34219
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    46
import compiler.whitebox.CompilerWhiteBoxTest;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39450
diff changeset
    47
import jdk.test.lib.Asserts;
40067
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    48
import jdk.test.lib.Platform;
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    49
import jdk.vm.ci.hotspot.CompilerToVMHelper;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    50
import sun.hotspot.WhiteBox;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    51
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    52
import java.lang.reflect.Executable;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    53
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    54
public class IsMatureTest {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    55
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
34219
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    56
    private static final boolean TIERED
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    57
            = WB.getBooleanVMFlag("TieredCompilation");
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    58
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    59
    public static void main(String[] args) throws Exception {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    60
        new IsMatureTest().test();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    61
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    62
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    63
    public void test() throws Exception {
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    64
        SimpleClass sclass = new SimpleClass();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    65
        Executable method = SimpleClass.class.getDeclaredMethod("testMethod");
34219
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    66
        long methodData = WB.getMethodData(method);
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    67
        boolean isMature = CompilerToVMHelper.isMature(methodData);
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    68
        Asserts.assertEQ(methodData, 0L,
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    69
                "Never invoked method can't have method data");
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    70
        Asserts.assertFalse(isMature, "Never invoked method can't be mature");
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    71
        for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    72
            sclass.testMethod();
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    73
        }
34219
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    74
        methodData = WB.getMethodData(method);
eb43fec35c99 8139384: [TESTBUG] JVMCI test fails with java.lang.RuntimeException: a 100_000 times invoked method should be mature
dpochepk
parents: 33730
diff changeset
    75
        isMature = CompilerToVMHelper.isMature(methodData);
39447
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    76
        int compLevel = WB.getMethodCompilationLevel(method);
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    77
        // methodData doesn't necessarily exist for interpreter and compilation level 1
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    78
        if (compLevel != CompilerWhiteBoxTest.COMP_LEVEL_NONE
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    79
                && compLevel != CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE) {
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    80
            Asserts.assertNE(methodData, 0L,
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    81
                    "Multiple times invoked method should have method data");
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    82
            /* a method is not mature in Xcomp mode with tiered compilation disabled,
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    83
               see NonTieredCompPolicy::is_mature */
40067
db6c74a53556 8151280: update hotspot tests to use vm.compMode instead of their own logic
tpivovarova
parents: 40059
diff changeset
    84
            Asserts.assertEQ(isMature, !(Platform.isComp() && !TIERED),
39447
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    85
                    "Unexpected isMature state for multiple times invoked method");
6de9e469842e 8159730: compiler/jvmci/compilerToVM/IsMatureTest failed with "Multiple times invoked method should have method data (assert failed: 0 != 0)"
dpochepk
parents: 38152
diff changeset
    86
        }
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    87
    }
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
diff changeset
    88
}