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