Mercurial > hg > truffle
annotate test/compiler/uncommontrap/TestSpecTrapClassUnloading.java @ 20228:f72d8917322a
8050978: Fix bad field access check in C1 and C2
Summary: JCK8 test vm/constantpool/accessControl/accessControl004/accessControl00402m3/accessControl00402m3.html fails with -Xbatch -Xcomp due to bad field access check in C1 and C2. Fix: In ciField::ciField(), just before the canonical holder is stored into the _holder variable (and which is used by ciField::will_link()) perform an additional access check with the holder declared in the class file. If this check fails, store the declared holder instead and ciField::will_link() will bail out compilation for this field later on. Then, the interpreter will throw an PrivilegedAccessException at runtime.
Reviewed-by: kvn, vlivanov
Contributed-by: andreas.schoesser@sap.com
author | goetz |
---|---|
date | Fri, 18 Jul 2014 09:04:01 +0200 |
parents | 8f28240318a2 |
children | 92aa6797d639 |
rev | line source |
---|---|
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
1 /* |
b8413a9cbb84
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. |
b8413a9cbb84
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. |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
4 * |
b8413a9cbb84
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 |
b8413a9cbb84
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 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
8 * |
b8413a9cbb84
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 |
b8413a9cbb84
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 |
b8413a9cbb84
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 |
b8413a9cbb84
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 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
13 * accompanied this code). |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
14 * |
b8413a9cbb84
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 |
b8413a9cbb84
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, |
b8413a9cbb84
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. |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
18 * |
b8413a9cbb84
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 |
b8413a9cbb84
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 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
21 * questions. |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
22 */ |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
23 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
24 /* |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
25 * @test |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
26 * @bug 8031752 |
b8413a9cbb84
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 |
17735 | 28 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+UseTypeSpeculation -XX:TypeProfileLevel=222 -XX:CompileCommand=exclude,java.lang.reflect.Method::invoke -XX:CompileCommand=exclude,sun.reflect.DelegatingMethodAccessorImpl::invoke -Xmx1M TestSpecTrapClassUnloading |
17728
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
29 * |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
30 */ |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
31 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
32 import java.lang.reflect.Method; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
33 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
34 public class TestSpecTrapClassUnloading { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
35 static class B { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
36 final public boolean m(Object o) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
37 if (o.getClass() == B.class) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
38 return true; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
39 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
40 return false; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
41 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
42 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
43 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
44 static class MemoryChunk { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
45 MemoryChunk other; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
46 long[] array; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
47 MemoryChunk(MemoryChunk other) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
48 other = other; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
49 array = new long[1024 * 1024 * 1024]; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
50 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
51 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
52 |
b8413a9cbb84
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) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
54 b.m(o); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
55 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
56 |
b8413a9cbb84
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) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
58 b.m(o); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
59 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
60 |
b8413a9cbb84
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 { |
b8413a9cbb84
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); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
63 Object o = new Object(); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
64 B b = new B(); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
65 |
b8413a9cbb84
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 |
b8413a9cbb84
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++) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
68 m1(b, b); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
69 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
70 m1(b, o); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
71 |
b8413a9cbb84
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 |
b8413a9cbb84
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++) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
74 m.invoke(b, b); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
75 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
76 m.invoke(b, o); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
77 |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
78 m = null; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
79 |
b8413a9cbb84
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 |
b8413a9cbb84
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++) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
82 m2(b, b); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
83 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
84 m2(b, o); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
85 |
b8413a9cbb84
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 |
b8413a9cbb84
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. |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
88 MemoryChunk root = null; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
89 try { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
90 while (true) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
91 root = new MemoryChunk(root); |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
92 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
93 } catch(OutOfMemoryError e) { |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
94 root = null; |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
95 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
96 } |
b8413a9cbb84
8031752: Failed speculative optimizations should be reattempted when root of compilation is different
roland
parents:
diff
changeset
|
97 } |