annotate test/compiler/profiling/TestMethodHandleInvokesIntrinsic.java @ 20304:a22acf6d7598

8048112: G1 Full GC needs to support the case when the very first region is not available Summary: Refactor preparation for compaction during Full GC so that it lazily initializes the first compaction point. This also avoids problems later when the first region may not be committed. Also reviewed by K. Barrett. Reviewed-by: brutisso
author tschatzl
date Mon, 21 Jul 2014 10:00:31 +0200
parents 45e59fae8f2b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17925
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
1 /*
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
4 *
45e59fae8f2b 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
45e59fae8f2b 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
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
7 * published by the Free Software Foundation.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
8 *
45e59fae8f2b 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
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
45e59fae8f2b 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
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
13 * accompanied this code).
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
14 *
45e59fae8f2b 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
45e59fae8f2b 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,
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
18 *
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
45e59fae8f2b 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
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
21 * questions.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
22 */
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
23
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
24 /*
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
25 * @test
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
26 * @bug 8041458
45e59fae8f2b 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.
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
28 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TieredStopAtLevel=3 TestMethodHandleInvokesIntrinsic
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
29 *
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
30 */
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
31
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
32 import java.lang.invoke.*;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
33
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
34 public class TestMethodHandleInvokesIntrinsic {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
35
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
36 static final MethodHandle mh_nanoTime;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
37 static final MethodHandle mh_getClass;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
38 static {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
39 MethodHandles.Lookup lookup = MethodHandles.lookup();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
40 MethodType mt = MethodType.methodType(long.class);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
41 MethodHandle MH = null;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
42 try {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
43 MH = lookup.findStatic(System.class, "nanoTime", mt);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
44 } catch(NoSuchMethodException nsme) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
45 nsme.printStackTrace();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
46 throw new RuntimeException("TEST FAILED", nsme);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
47 } catch(IllegalAccessException iae) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
48 iae.printStackTrace();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
49 throw new RuntimeException("TEST FAILED", iae);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
50 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
51 mh_nanoTime = MH;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
52
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
53 mt = MethodType.methodType(Class.class);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
54 MH = null;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
55 try {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
56 MH = lookup.findVirtual(Object.class, "getClass", mt);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
57 } catch(NoSuchMethodException nsme) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
58 nsme.printStackTrace();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
59 throw new RuntimeException("TEST FAILED", nsme);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
60 } catch(IllegalAccessException iae) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
61 iae.printStackTrace();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
62 throw new RuntimeException("TEST FAILED", iae);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
63 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
64 mh_getClass = MH;
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
65 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
66
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
67 static long m1() throws Throwable {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
68 return (long)mh_nanoTime.invokeExact();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
69 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
70
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
71 static Class m2(Object o) throws Throwable {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
72 return (Class)mh_getClass.invokeExact(o);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
73 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
74
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
75 static public void main(String[] args) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
76 try {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
77 for (int i = 0; i < 20000; i++) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
78 m1();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
79 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
80 TestMethodHandleInvokesIntrinsic o = new TestMethodHandleInvokesIntrinsic();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
81 for (int i = 0; i < 20000; i++) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
82 m2(o);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
83 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
84 } catch(Throwable t) {
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
85 System.out.println("Unexpected exception");
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
86 t.printStackTrace();
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
87 throw new RuntimeException("TEST FAILED", t);
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
88 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
89
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
90 System.out.println("TEST PASSED");
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
91 }
45e59fae8f2b 8041481: JVM crashes with collect_args_for_profiling
roland
parents:
diff changeset
92 }