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