author | twisti |
Mon, 27 Apr 2015 09:02:41 -0700 | |
changeset 30288 | 476c276de939 |
parent 29678 | dd2f3932c21e |
child 34272 | 1b277b5ee6e3 |
permissions | -rw-r--r-- |
27616
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
27616
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
27616
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
4 |
* |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
8 |
* |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
13 |
* accompanied this code). |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
14 |
* |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
18 |
* |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
21 |
* questions. |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
22 |
*/ |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
23 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
24 |
import java.io.BufferedReader; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
25 |
import java.io.InputStreamReader; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
26 |
import java.lang.Class; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
27 |
import java.lang.String; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
28 |
import java.lang.System; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
29 |
import java.lang.management.ManagementFactory; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
30 |
import java.lang.management.RuntimeMXBean; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
31 |
import java.util.ArrayList; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
32 |
import java.util.List; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
33 |
import java.util.concurrent.CyclicBarrier; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
34 |
import java.util.regex.Matcher; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
35 |
import java.util.regex.Pattern; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
36 |
import java.lang.reflect.Field; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
37 |
import java.lang.reflect.Modifier; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
38 |
import sun.misc.Unsafe; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
39 |
import sun.misc.Contended; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
40 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
41 |
/* |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
42 |
* @test |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
43 |
* @bug 8015272 |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
44 |
* @summary \@Contended within the same group to use the same oop map |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
45 |
* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
27616
diff
changeset
|
46 |
* @modules java.base/sun.misc |
27616
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
47 |
* @run main/othervm -XX:-RestrictContended -XX:ContendedPaddingWidth=128 -Xmx128m OopMapsSameGroup |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
48 |
*/ |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
49 |
public class OopMapsSameGroup { |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
50 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
51 |
public static final int COUNT = 10000; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
52 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
53 |
public static void main(String[] args) throws Exception { |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
54 |
Object o01 = new Object(); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
55 |
Object o02 = new Object(); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
56 |
Object o03 = new Object(); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
57 |
Object o04 = new Object(); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
58 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
59 |
R[] rs = new R[COUNT]; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
60 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
61 |
for (int i = 0; i < COUNT; i++) { |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
62 |
R r = new R(); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
63 |
r.o01 = o01; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
64 |
r.o02 = o02; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
65 |
r.o03 = o03; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
66 |
r.o04 = o04; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
67 |
rs[i] = r; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
68 |
} |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
69 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
70 |
System.gc(); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
71 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
72 |
for (int i = 0; i < COUNT; i++) { |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
73 |
R r = rs[i]; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
74 |
if (r.o01 != o01) throw new Error("Test Error: o01"); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
75 |
if (r.o02 != o02) throw new Error("Test Error: o02"); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
76 |
if (r.o03 != o03) throw new Error("Test Error: o03"); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
77 |
if (r.o04 != o04) throw new Error("Test Error: o04"); |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
78 |
} |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
79 |
} |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
80 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
81 |
public static class R { |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
82 |
@Contended("group1") |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
83 |
Object o01; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
84 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
85 |
@Contended("group1") |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
86 |
Object o02; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
87 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
88 |
@Contended("group2") |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
89 |
Object o03; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
90 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
91 |
@Contended("group2") |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
92 |
Object o04; |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
93 |
} |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
94 |
|
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
95 |
} |
6a63de6a8276
8015272: Make @Contended within the same group to use the same oop map
shade
parents:
diff
changeset
|
96 |