author | gtriantafill |
Wed, 14 Sep 2016 08:17:50 -0400 | |
changeset 41092 | c388d897472d |
parent 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
17611
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
1 |
/* |
36209
8db2a78cbc29
8151156: [TESTBUG] Integrate trivial Hotspot test changes from Jake before Jigsaw M3
ctornqvi
parents:
34272
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
17611
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
4 |
* |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
8 |
* |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
13 |
* accompanied this code). |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
14 |
* |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
18 |
* |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
21 |
* questions. |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
22 |
*/ |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
23 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
24 |
import java.io.BufferedReader; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
25 |
import java.io.InputStreamReader; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
26 |
import java.lang.Class; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
27 |
import java.lang.String; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
28 |
import java.lang.System; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
29 |
import java.lang.management.ManagementFactory; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
30 |
import java.lang.management.RuntimeMXBean; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
31 |
import java.util.ArrayList; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
32 |
import java.util.List; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
33 |
import java.util.concurrent.CyclicBarrier; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
34 |
import java.util.regex.Matcher; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
35 |
import java.util.regex.Pattern; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
36 |
import java.lang.reflect.Field; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
37 |
import java.lang.reflect.Modifier; |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36209
diff
changeset
|
38 |
import jdk.internal.misc.Unsafe; |
34272
1b277b5ee6e3
8140687: Move @Contended to the jdk.internal.vm.annotation package
chegar
parents:
29678
diff
changeset
|
39 |
import jdk.internal.vm.annotation.Contended; |
17611
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
40 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
41 |
/* |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
42 |
* @test |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
43 |
* @bug 8003985 |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
44 |
* @summary Support Contended Annotation - JEP 142 |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36209
diff
changeset
|
45 |
* @modules java.base/jdk.internal.misc |
36209
8db2a78cbc29
8151156: [TESTBUG] Integrate trivial Hotspot test changes from Jake before Jigsaw M3
ctornqvi
parents:
34272
diff
changeset
|
46 |
* @modules java.base/jdk.internal.vm.annotation |
17611
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
47 |
* @run main/othervm -XX:-RestrictContended Basic |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
48 |
*/ |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
49 |
public class Basic { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
50 |
|
41092
c388d897472d
8165889: Remove jdk.test.lib.unsafe.UnsafeHelper
gtriantafill
parents:
38152
diff
changeset
|
51 |
private static final Unsafe U = Unsafe.getUnsafe(); |
17611
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
52 |
private static int ADDRESS_SIZE; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
53 |
private static int HEADER_SIZE; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
54 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
55 |
static { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
56 |
// When running with CompressedOops on 64-bit platform, the address size |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
57 |
// reported by Unsafe is still 8, while the real reference fields are 4 bytes long. |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
58 |
// Try to guess the reference field size with this naive trick. |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
59 |
try { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
60 |
long off1 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj1")); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
61 |
long off2 = U.objectFieldOffset(CompressedOopsClass.class.getField("obj2")); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
62 |
ADDRESS_SIZE = (int) Math.abs(off2 - off1); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
63 |
HEADER_SIZE = (int) Math.min(off1, off2); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
64 |
} catch (NoSuchFieldException e) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
65 |
ADDRESS_SIZE = -1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
66 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
67 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
68 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
69 |
static class CompressedOopsClass { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
70 |
public Object obj1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
71 |
public Object obj2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
72 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
73 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
74 |
public static boolean arePaddedPairwise(Class klass, String field1, String field2) throws Exception { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
75 |
Field f1 = klass.getDeclaredField(field1); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
76 |
Field f2 = klass.getDeclaredField(field2); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
77 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
78 |
if (isStatic(f1) != isStatic(f2)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
79 |
return true; // these guys are in naturally disjoint locations |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
80 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
81 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
82 |
int diff = offset(f1) - offset(f2); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
83 |
if (diff < 0) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
84 |
// f1 is first |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
85 |
return (offset(f2) - (offset(f1) + getSize(f1))) > 64; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
86 |
} else { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
87 |
// f2 is first |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
88 |
return (offset(f1) - (offset(f2) + getSize(f2))) > 64; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
89 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
90 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
91 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
92 |
public static boolean isPadded(Class klass, String field1) throws Exception { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
93 |
Field f1 = klass.getDeclaredField(field1); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
94 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
95 |
if (isStatic(f1)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
96 |
return offset(f1) > 128 + 64; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
97 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
98 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
99 |
return offset(f1) > 64; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
100 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
101 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
102 |
public static boolean sameLayout(Class klass1, Class klass2) throws Exception { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
103 |
for (Field f1 : klass1.getDeclaredFields()) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
104 |
Field f2 = klass2.getDeclaredField(f1.getName()); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
105 |
if (offset(f1) != offset(f2)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
106 |
return false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
107 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
108 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
109 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
110 |
for (Field f2 : klass1.getDeclaredFields()) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
111 |
Field f1 = klass2.getDeclaredField(f2.getName()); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
112 |
if (offset(f1) != offset(f2)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
113 |
return false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
114 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
115 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
116 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
117 |
return true; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
118 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
119 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
120 |
public static boolean isStatic(Field field) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
121 |
return Modifier.isStatic(field.getModifiers()); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
122 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
123 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
124 |
public static int offset(Field field) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
125 |
if (isStatic(field)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
126 |
return (int) U.staticFieldOffset(field); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
127 |
} else { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
128 |
return (int) U.objectFieldOffset(field); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
129 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
130 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
131 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
132 |
public static int getSize(Field field) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
133 |
Class type = field.getType(); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
134 |
if (type == byte.class) { return 1; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
135 |
if (type == boolean.class) { return 1; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
136 |
if (type == short.class) { return 2; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
137 |
if (type == char.class) { return 2; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
138 |
if (type == int.class) { return 4; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
139 |
if (type == float.class) { return 4; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
140 |
if (type == long.class) { return 8; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
141 |
if (type == double.class) { return 8; } |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
142 |
return ADDRESS_SIZE; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
143 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
144 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
145 |
public static void main(String[] args) throws Exception { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
146 |
boolean endResult = true; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
147 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
148 |
// --------------- INSTANCE FIELDS --------------------- |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
149 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
150 |
if (arePaddedPairwise(Test1.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
151 |
isPadded(Test1.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
152 |
isPadded(Test1.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
153 |
System.err.println("Test1 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
154 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
155 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
156 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
157 |
if (!arePaddedPairwise(Test2.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
158 |
!isPadded(Test2.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
159 |
isPadded(Test2.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
160 |
System.err.println("Test2 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
161 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
162 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
163 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
164 |
if (!arePaddedPairwise(Test3.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
165 |
!isPadded(Test3.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
166 |
!isPadded(Test3.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
167 |
System.err.println("Test3 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
168 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
169 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
170 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
171 |
if (arePaddedPairwise(Test4.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
172 |
!isPadded(Test4.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
173 |
!isPadded(Test4.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
174 |
System.err.println("Test4 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
175 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
176 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
177 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
178 |
if (!arePaddedPairwise(Test5.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
179 |
!isPadded(Test5.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
180 |
!isPadded(Test5.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
181 |
System.err.println("Test5 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
182 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
183 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
184 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
185 |
if (!arePaddedPairwise(Test6.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
186 |
!isPadded(Test6.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
187 |
!isPadded(Test6.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
188 |
System.err.println("Test6 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
189 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
190 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
191 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
192 |
if (arePaddedPairwise(Test7.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
193 |
!isPadded(Test7.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
194 |
!isPadded(Test7.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
195 |
System.err.println("Test7 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
196 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
197 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
198 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
199 |
if (!arePaddedPairwise(Test8.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
200 |
!isPadded(Test8.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
201 |
!isPadded(Test8.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
202 |
System.err.println("Test8 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
203 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
204 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
205 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
206 |
if (!arePaddedPairwise(Test9.class, "int1", "int2") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
207 |
!isPadded(Test9.class, "int1") || |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
208 |
!isPadded(Test9.class, "int2")) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
209 |
System.err.println("Test9 failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
210 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
211 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
212 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
213 |
if (!sameLayout(Test4.class, Test7.class)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
214 |
System.err.println("Test4 and Test7 have different layouts"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
215 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
216 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
217 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
218 |
if (!sameLayout(Test5.class, Test6.class)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
219 |
System.err.println("Test5 and Test6 have different layouts"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
220 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
221 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
222 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
223 |
if (!sameLayout(Test8.class, Test9.class)) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
224 |
System.err.println("Test8 and Test9 have different layouts"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
225 |
endResult &= false; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
226 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
227 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
228 |
System.out.println(endResult ? "Test PASSES" : "Test FAILS"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
229 |
if (!endResult) { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
230 |
throw new Error("Test failed"); |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
231 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
232 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
233 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
234 |
// ----------------------------------- INSTANCE FIELDS ----------------------------------------- |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
235 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
236 |
// naturally packed |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
237 |
public static class Test1 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
238 |
private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
239 |
private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
240 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
241 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
242 |
// int1 is padded |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
243 |
public static class Test2 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
244 |
@Contended private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
245 |
private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
246 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
247 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
248 |
// both fields are padded |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
249 |
public static class Test3 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
250 |
@Contended private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
251 |
@Contended private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
252 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
253 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
254 |
// fields are padded in the singular group |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
255 |
public static class Test4 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
256 |
@Contended("sameGroup") private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
257 |
@Contended("sameGroup") private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
258 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
259 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
260 |
// fields are padded in disjoint groups |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
261 |
public static class Test5 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
262 |
@Contended("diffGroup1") private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
263 |
@Contended("diffGroup2") private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
264 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
265 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
266 |
// fields are padded in disjoint groups |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
267 |
public static class Test6 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
268 |
@Contended private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
269 |
@Contended("diffGroup2") private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
270 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
271 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
272 |
// fields are padded in the singular group |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
273 |
@Contended |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
274 |
public static class Test7 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
275 |
private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
276 |
private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
277 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
278 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
279 |
// all fields are padded as the group, and one field is padded specifically |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
280 |
@Contended |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
281 |
public static class Test8 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
282 |
@Contended private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
283 |
private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
284 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
285 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
286 |
// all fields are padded as the group, and one field is padded specifically |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
287 |
@Contended |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
288 |
public static class Test9 { |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
289 |
@Contended("group") private int int1; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
290 |
private int int2; |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
291 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
292 |
|
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
293 |
} |
5b5a5ad4c222
8014871: Move @Contended regression tests to the same place
shade
parents:
diff
changeset
|
294 |