annotate test/compiler/uncommontrap/TestSpecTrapClassUnloading.java @ 14670:27689a7550a8

8036092: [TESTBUG] compiler/uncommontrap/TestSpecTrapClassUnloading.java fails with: Unrecognized VM option 'UseTypeSpeculation' Summary: Add -XX:+IgnoreUnrecognizedVMOptions to @main/othervm to make the test pass on Client VM Reviewed-by: kvn, roland
author anoll
date Wed, 05 Mar 2014 06:08:19 +0100
parents fdad2932c73f
children 45b0159f30f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14500
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
1 /*
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
4 *
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
7 * published by the Free Software Foundation.
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
8 *
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
13 * accompanied this code).
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
14 *
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
18 *
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
21 * questions.
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
22 */
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
23
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
24 /*
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
25 * @test
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
26 * @bug 8031752
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
27 * @summary speculative traps need to be cleaned up at GC
14670
27689a7550a8 8036092: [TESTBUG] compiler/uncommontrap/TestSpecTrapClassUnloading.java fails with: Unrecognized VM option 'UseTypeSpeculation'
anoll
parents: 14500
diff changeset
28 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+UnlockExperimentalVMOptions -XX:+UseTypeSpeculation -XX:TypeProfileLevel=222 -XX:CompileCommand=exclude,java.lang.reflect.Method::invoke -XX:CompileCommand=exclude,sun.reflect.DelegatingMethodAccessorImpl::invoke -Xmx1M TestSpecTrapClassUnloading
14500
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
29 *
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
30 */
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
31
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
32 import java.lang.reflect.Method;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
33
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
34 public class TestSpecTrapClassUnloading {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
35 static class B {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
36 final public boolean m(Object o) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
37 if (o.getClass() == B.class) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
38 return true;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
39 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
40 return false;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
41 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
42 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
43
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
44 static class MemoryChunk {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
45 MemoryChunk other;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
46 long[] array;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
47 MemoryChunk(MemoryChunk other) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
48 other = other;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
49 array = new long[1024 * 1024 * 1024];
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
50 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
51 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
52
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
53 static void m1(B b, Object o) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
54 b.m(o);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
55 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
56
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
57 static void m2(B b, Object o) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
58 b.m(o);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
59 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
60
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
61 public static void main(String[] args) throws Exception {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
62 Method m = B.class.getMethod("m", Object.class);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
63 Object o = new Object();
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
64 B b = new B();
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
65
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
66 // add speculative trap in B.m() for m1
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
67 for (int i = 0; i < 20000; i++) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
68 m1(b, b);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
69 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
70 m1(b, o);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
71
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
72 // add speculative trap in B.m() for code generated by reflection
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
73 for (int i = 0; i < 20000; i++) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
74 m.invoke(b, b);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
75 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
76 m.invoke(b, o);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
77
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
78 m = null;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
79
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
80 // add speculative trap in B.m() for m2
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
81 for (int i = 0; i < 20000; i++) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
82 m2(b, b);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
83 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
84 m2(b, o);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
85
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
86 // Exhaust memory which causes the code generated by
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
87 // reflection to be unloaded but B.m() is not.
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
88 MemoryChunk root = null;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
89 try {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
90 while (true) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
91 root = new MemoryChunk(root);
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
92 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
93 } catch(OutOfMemoryError e) {
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
94 root = null;
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
95 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
96 }
fdad2932c73f 8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff changeset
97 }