test/hotspot/jtreg/compiler/profiling/TestUnexpectedProfilingMismatch.java
author iignatyev
Mon, 18 Feb 2019 09:31:07 -0800
changeset 53791 bec6c8739833
parent 47216 71c04702a3d5
permissions -rw-r--r--
8219157: vm/mlvm/mixed/stress/java/findDeadlock should be problem-listed only on mac Reviewed-by: thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     1
/*
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     4
 *
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     8
 *
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    13
 * accompanied this code).
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    14
 *
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    18
 *
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    21
 * questions.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    22
 */
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    23
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    24
/*
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    25
 * @test
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    26
 * @bug 8027631
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    27
 * @summary profiling of arguments at calls cannot rely on signature of callee for types
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation -XX:TieredStopAtLevel=3 -XX:TypeProfileLevel=111
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    30
 *                   -XX:Tier3InvocationThreshold=200 -XX:Tier0InvokeNotifyFreqLog=7
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    31
 *                   compiler.profiling.TestUnexpectedProfilingMismatch
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    32
 */
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    33
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    34
package compiler.profiling;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    35
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    36
import java.lang.invoke.MethodHandle;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    37
import java.lang.invoke.MethodHandles;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 21579
diff changeset
    38
import java.lang.invoke.MethodType;
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    39
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    40
public class TestUnexpectedProfilingMismatch {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    41
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    42
    static class A {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    43
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    44
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    45
    static class B {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    46
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    47
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    48
    static void mA(A a) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    49
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    50
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    51
    static void mB(B b) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    52
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    53
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    54
    static final MethodHandle mhA;
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    55
    static final MethodHandle mhB;
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    56
    static {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    57
        MethodHandles.Lookup lookup = MethodHandles.lookup();
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    58
        MethodType mt = MethodType.methodType(void.class, A.class);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    59
        MethodHandle res = null;
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    60
        try {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    61
            res = lookup.findStatic(TestUnexpectedProfilingMismatch.class, "mA", mt);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    62
        } catch(NoSuchMethodException ex) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    63
        } catch(IllegalAccessException ex) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    64
        }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    65
        mhA = res;
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    66
        mt = MethodType.methodType(void.class, B.class);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    67
        try {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    68
            res = lookup.findStatic(TestUnexpectedProfilingMismatch.class, "mB", mt);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    69
        } catch(NoSuchMethodException ex) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    70
        } catch(IllegalAccessException ex) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    71
        }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    72
        mhB = res;
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    73
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    74
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    75
    void m1(A a, boolean doit) throws Throwable {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    76
        if (doit) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    77
            mhA.invoke(a);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    78
        }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    79
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    80
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    81
    void m2(B b) throws Throwable {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    82
        mhB.invoke(b);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    83
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    84
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    85
    static public void main(String[] args) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    86
        TestUnexpectedProfilingMismatch tih = new TestUnexpectedProfilingMismatch();
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    87
        A a = new A();
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    88
        B b = new B();
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    89
        try {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    90
            for (int i = 0; i < 256 - 1; i++) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    91
                tih.m1(a, true);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    92
            }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    93
            // Will trigger the compilation but will also run once
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    94
            // more interpreted with a non null MDO which it will
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    95
            // update. Make it skip the body of the method.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    96
            tih.m1(a, false);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    97
            // Compile this one as well and do the profiling
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    98
            for (int i = 0; i < 256; i++) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
    99
                tih.m2(b);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   100
            }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   101
            // Will run and see a conflict
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   102
            tih.m1(a, true);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   103
        } catch(Throwable ex) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   104
            ex.printStackTrace();
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   105
        }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   106
        System.out.println("TEST PASSED");
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   107
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents:
diff changeset
   108
}