author | stefank |
Tue, 28 Nov 2017 21:43:45 +0100 (2017-11-28) | |
changeset 48157 | 7c4d43c26352 |
parent 47216 | 71c04702a3d5 |
child 52220 | 9c260a6b6471 |
permissions | -rw-r--r-- |
19156
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
19160
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
19156
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
4 |
* |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
8 |
* |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
13 |
* accompanied this code). |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
14 |
* |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
18 |
* |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
21 |
* questions. |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
22 |
*/ |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
23 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
24 |
/* |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
25 |
* @test |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
26 |
* @bug 8016474 |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
27 |
* @summary The bug only happens with C1 and G1 using a different ObjectAlignmentInBytes than KlassAlignmentInBytes (which is 8) |
40059 | 28 |
* |
42307
cefc81dc1d52
8169069: Module system implementation refresh (11/2016)
alanb
parents:
40059
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc:+open |
40059 | 30 |
* @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 |
31 |
* compiler.unsafe.GetUnsafeObjectG1PreBarrier |
|
19156
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
32 |
*/ |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
33 |
|
40059 | 34 |
package compiler.unsafe; |
19156
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
35 |
|
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36851
diff
changeset
|
36 |
import jdk.internal.misc.Unsafe; |
19156
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
37 |
|
40059 | 38 |
import java.lang.reflect.Field; |
39 |
||
19156
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
40 |
public class GetUnsafeObjectG1PreBarrier { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
41 |
private static final Unsafe unsafe; |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
42 |
private static final int N = 100_000; |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
43 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
44 |
static { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
45 |
try { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
46 |
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
47 |
theUnsafe.setAccessible(true); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
48 |
unsafe = (Unsafe) theUnsafe.get(null); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
49 |
} catch (NoSuchFieldException | IllegalAccessException e) { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
50 |
throw new IllegalStateException(e); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
51 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
52 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
53 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
54 |
public Object a; |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
55 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
56 |
public static void main(String[] args) throws Throwable { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
57 |
new GetUnsafeObjectG1PreBarrier(); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
58 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
59 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
60 |
public GetUnsafeObjectG1PreBarrier() throws Throwable { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
61 |
doit(); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
62 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
63 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
64 |
private void doit() throws Throwable { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
65 |
Field field = GetUnsafeObjectG1PreBarrier.class.getField("a"); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
66 |
long fieldOffset = unsafe.objectFieldOffset(field); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
67 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
68 |
for (int i = 0; i < N; i++) { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
69 |
readField(this, fieldOffset); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
70 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
71 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
72 |
|
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
73 |
private void readField(Object o, long fieldOffset) { |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
74 |
unsafe.getObject(o, fieldOffset); |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
75 |
} |
96abb5953450
8016474: Crash in sun.reflect.UnsafeObjectFieldAccessorImpl.get
twisti
parents:
diff
changeset
|
76 |
} |