Mercurial > hg > truffle
comparison test/runtime/contended/OopMaps.java @ 10348:3970971c91e0
8015270: @Contended: fix multiple issues in the layout code
Summary: field count handling fixed, has_nonstatic_fields invariant fixed, oop map overrun fixed; new asserts
Reviewed-by: kvn, dcubed, coleenp
author | shade |
---|---|
date | Mon, 27 May 2013 12:49:08 -0700 |
parents | |
children | 01c2bdd24bb5 |
comparison
equal
deleted
inserted
replaced
10347:6c138b9851fb | 10348:3970971c91e0 |
---|---|
1 /* | |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 | |
24 import java.io.BufferedReader; | |
25 import java.io.InputStreamReader; | |
26 import java.lang.Class; | |
27 import java.lang.String; | |
28 import java.lang.System; | |
29 import java.lang.management.ManagementFactory; | |
30 import java.lang.management.RuntimeMXBean; | |
31 import java.util.ArrayList; | |
32 import java.util.List; | |
33 import java.util.concurrent.CyclicBarrier; | |
34 import java.util.regex.Matcher; | |
35 import java.util.regex.Pattern; | |
36 import java.lang.reflect.Field; | |
37 import java.lang.reflect.Modifier; | |
38 import sun.misc.Unsafe; | |
39 import sun.misc.Contended; | |
40 | |
41 /* | |
42 * @test | |
43 * @bug 8015270 | |
44 * @summary \@Contended: fix multiple issues in the layout code | |
45 * | |
46 * @run main/othervm -XX:-RestrictContended OopMaps | |
47 */ | |
48 public class OopMaps { | |
49 | |
50 public static void main(String[] args) throws Exception { | |
51 Object o01 = new Object(); | |
52 Object o02 = new Object(); | |
53 Object o03 = new Object(); | |
54 Object o04 = new Object(); | |
55 Object o05 = new Object(); | |
56 Object o06 = new Object(); | |
57 Object o07 = new Object(); | |
58 Object o08 = new Object(); | |
59 Object o09 = new Object(); | |
60 Object o10 = new Object(); | |
61 Object o11 = new Object(); | |
62 Object o12 = new Object(); | |
63 Object o13 = new Object(); | |
64 Object o14 = new Object(); | |
65 | |
66 final int COUNT = 100000; | |
67 R1[] rs = new R1[COUNT]; | |
68 | |
69 for (int i = 0; i < COUNT; i++) { | |
70 R1 r1 = new R1(); | |
71 r1.o01 = o01; | |
72 r1.o02 = o02; | |
73 r1.o03 = o03; | |
74 r1.o04 = o04; | |
75 r1.o05 = o05; | |
76 r1.o06 = o06; | |
77 r1.o07 = o07; | |
78 r1.o08 = o08; | |
79 r1.o09 = o09; | |
80 r1.o10 = o10; | |
81 r1.o11 = o11; | |
82 r1.o12 = o12; | |
83 r1.o13 = o13; | |
84 r1.o14 = o14; | |
85 r1.i1 = 1; | |
86 r1.i2 = 2; | |
87 r1.i3 = 3; | |
88 r1.i4 = 4; | |
89 rs[i] = r1; | |
90 } | |
91 | |
92 System.gc(); | |
93 | |
94 for (int i = 0; i < COUNT; i++) { | |
95 R1 r1 = rs[i]; | |
96 if (r1.o01 != o01) throw new Error("Test Error: o01"); | |
97 if (r1.o02 != o02) throw new Error("Test Error: o02"); | |
98 if (r1.o03 != o03) throw new Error("Test Error: o03"); | |
99 if (r1.o04 != o04) throw new Error("Test Error: o04"); | |
100 if (r1.o05 != o05) throw new Error("Test Error: o05"); | |
101 if (r1.o06 != o06) throw new Error("Test Error: o06"); | |
102 if (r1.o07 != o07) throw new Error("Test Error: o07"); | |
103 if (r1.o08 != o08) throw new Error("Test Error: o08"); | |
104 if (r1.o09 != o09) throw new Error("Test Error: o09"); | |
105 if (r1.o10 != o10) throw new Error("Test Error: o10"); | |
106 if (r1.o11 != o11) throw new Error("Test Error: o11"); | |
107 if (r1.o12 != o12) throw new Error("Test Error: o12"); | |
108 if (r1.o13 != o13) throw new Error("Test Error: o13"); | |
109 if (r1.o14 != o14) throw new Error("Test Error: o14"); | |
110 if (r1.i1 != 1) throw new Error("Test Error: i1"); | |
111 if (r1.i2 != 2) throw new Error("Test Error: i2"); | |
112 if (r1.i3 != 3) throw new Error("Test Error: i3"); | |
113 if (r1.i4 != 4) throw new Error("Test Error: i4"); | |
114 } | |
115 } | |
116 | |
117 public static class R0 { | |
118 int i1; | |
119 int i2; | |
120 | |
121 Object o01; | |
122 Object o02; | |
123 | |
124 @Contended | |
125 Object o03; | |
126 | |
127 @Contended | |
128 Object o04; | |
129 | |
130 @Contended | |
131 Object o05; | |
132 | |
133 @Contended | |
134 Object o06; | |
135 | |
136 @Contended | |
137 Object o07; | |
138 } | |
139 | |
140 public static class R1 extends R0 { | |
141 int i3; | |
142 int i4; | |
143 | |
144 Object o08; | |
145 Object o09; | |
146 | |
147 @Contended | |
148 Object o10; | |
149 | |
150 @Contended | |
151 Object o11; | |
152 | |
153 @Contended | |
154 Object o12; | |
155 | |
156 @Contended | |
157 Object o13; | |
158 | |
159 @Contended | |
160 Object o14; | |
161 } | |
162 | |
163 } | |
164 |