test/hotspot/jtreg/compiler/profiling/TestMethodHandleInvokesIntrinsic.java
author iignatyev
Thu, 05 Jul 2018 20:00:04 -0700
changeset 50997 b9361d8c58a5
parent 47216 71c04702a3d5
permissions -rw-r--r--
8206429: [REDO] 8202561 clean up TEST.groups Reviewed-by: kvn, dholmes, ctornqvi
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24313
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     1
/*
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     4
 *
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     8
 *
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    13
 * accompanied this code).
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    14
 *
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    18
 *
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    21
 * questions.
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    22
 */
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    23
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    24
/*
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    25
 * @test
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    26
 * @bug 8041458
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    27
 * @summary profiling of arguments in C1 at MethodHandle invoke of intrinsic tries to profile popped argument.
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    28
 *
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    29
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    30
 *                   -XX:TieredStopAtLevel=3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    31
 *                   compiler.profiling.TestMethodHandleInvokesIntrinsic
24313
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    32
 *
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    33
 */
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    34
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    35
package compiler.profiling;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    36
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    37
import java.lang.invoke.MethodHandle;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    38
import java.lang.invoke.MethodHandles;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 24313
diff changeset
    39
import java.lang.invoke.MethodType;
24313
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    40
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    41
public class TestMethodHandleInvokesIntrinsic {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    42
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    43
    static final MethodHandle mh_nanoTime;
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    44
    static final MethodHandle mh_getClass;
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    45
    static {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    46
        MethodHandles.Lookup lookup = MethodHandles.lookup();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    47
        MethodType mt = MethodType.methodType(long.class);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    48
        MethodHandle MH = null;
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    49
        try {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    50
            MH = lookup.findStatic(System.class, "nanoTime", mt);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    51
        } catch(NoSuchMethodException nsme) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    52
            nsme.printStackTrace();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    53
            throw new RuntimeException("TEST FAILED", nsme);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    54
        } catch(IllegalAccessException iae) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    55
            iae.printStackTrace();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    56
            throw new RuntimeException("TEST FAILED", iae);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    57
        }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    58
        mh_nanoTime = MH;
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    59
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    60
        mt = MethodType.methodType(Class.class);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    61
        MH = null;
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    62
        try {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    63
            MH = lookup.findVirtual(Object.class, "getClass", mt);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    64
        } catch(NoSuchMethodException nsme) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    65
            nsme.printStackTrace();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    66
            throw new RuntimeException("TEST FAILED", nsme);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    67
        } catch(IllegalAccessException iae) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    68
            iae.printStackTrace();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    69
            throw new RuntimeException("TEST FAILED", iae);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    70
        }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    71
        mh_getClass = MH;
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    72
    }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    73
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    74
    static long m1() throws Throwable {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    75
        return (long)mh_nanoTime.invokeExact();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    76
    }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    77
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    78
    static Class m2(Object o) throws Throwable {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    79
        return (Class)mh_getClass.invokeExact(o);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    80
    }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    81
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    82
    static public void main(String[] args) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    83
        try {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    84
            for (int i = 0; i < 20000; i++) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    85
                m1();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    86
            }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    87
            TestMethodHandleInvokesIntrinsic o = new TestMethodHandleInvokesIntrinsic();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    88
            for (int i = 0; i < 20000; i++) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    89
                m2(o);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    90
            }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    91
        } catch(Throwable t) {
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    92
            System.out.println("Unexpected exception");
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    93
            t.printStackTrace();
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    94
            throw new RuntimeException("TEST FAILED", t);
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    95
        }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    96
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    97
        System.out.println("TEST PASSED");
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    98
    }
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
    99
}