annotate src/share/vm/oops/cpCacheKlass.cpp @ 452:00b023ae2d78

6722113: CMS: Incorrect overflow handling during precleaning of Reference lists Summary: When we encounter marking stack overflow during precleaning of Reference lists, we were using the overflow list mechanism, which can cause problems on account of mutating the mark word of the header because of conflicts with mutator accesses and updates of that field. Instead we should use the usual mechanism for overflow handling in concurrent phases, namely dirtying of the card on which the overflowed object lies. Since precleaning effectively does a form of discovered list processing, albeit with discovery enabled, we needed to adjust some code to be correct in the face of interleaved processing and discovery. Reviewed-by: apetrusenko, jcoomes
author ysr
date Thu, 20 Nov 2008 12:27:41 -0800
parents d1605aabd0a1
children 9a25e0c45327
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_cpCacheKlass.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 int constantPoolCacheKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 assert(obj->is_constantPoolCache(), "must be constantPool");
a61af66fc99e Initial load
duke
parents:
diff changeset
31 return constantPoolCacheOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
32 }
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 constantPoolCacheOop constantPoolCacheKlass::allocate(int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // allocate memory
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int size = constantPoolCacheOopDesc::object_size(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
38 KlassHandle klass (THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
39 constantPoolCacheOop cache = (constantPoolCacheOop)
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
40 CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
41 cache->set_length(length);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 cache->set_constant_pool(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 return cache;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 klassOop constantPoolCacheKlass::create_klass(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 constantPoolCacheKlass o;
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
48 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
49 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
50 // Make sure size calculation is right
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
51 assert(k()->size() == align_object_size(header_size()), "wrong size for object");
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
52 java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 void constantPoolCacheKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // gc of constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
63 MarkSweep::mark_and_push((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // gc of constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
65 int i = cache->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 while (i-- > 0) cache->entry_at(i)->follow_contents();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
70 void constantPoolCacheKlass::oop_follow_contents(ParCompactionManager* cm,
a61af66fc99e Initial load
duke
parents:
diff changeset
71 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // gc of constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
77 PSParallelCompact::mark_and_push(cm, (oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // gc of constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
79 int i = cache->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 while (i-- > 0) cache->entry_at(i)->follow_contents(cm);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 int constantPoolCacheKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 int size = cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
94 blk->do_oop((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
96 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate(blk);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 int constantPoolCacheKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
103 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 int size = cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
110 oop* addr = (oop*)cache->constant_pool_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if (mr.contains(addr)) blk->do_oop(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
113 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->oop_iterate_m(blk, mr);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
120 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Get size before changing pointers.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Don't call size() or oop_size() since that is a virtual call.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int size = cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // know that Universe::constantPoolCacheKlassObj never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
127 MarkSweep::adjust_pointer((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
129 for (int i = 0; i < cache->length(); i++)
a61af66fc99e Initial load
duke
parents:
diff changeset
130 cache->entry_at(i)->adjust_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 return size;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
135 void constantPoolCacheKlass::oop_copy_contents(PSPromotionManager* pm,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 assert(obj->is_constantPoolCache(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
a61af66fc99e Initial load
duke
parents:
diff changeset
141 oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 assert(obj->is_constantPoolCache(), "should be constant pool");
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 int
a61af66fc99e Initial load
duke
parents:
diff changeset
146 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
148 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
151 PSParallelCompact::adjust_pointer((oop*)cache->constant_pool_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
154 for (int i = 0; i < cache->length(); ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 cache->entry_at(i)->update_pointers();
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 }
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 int
a61af66fc99e Initial load
duke
parents:
diff changeset
162 constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
163 HeapWord* beg_addr,
a61af66fc99e Initial load
duke
parents:
diff changeset
164 HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Iteration over constant pool cache instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
169 oop* p;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 p = (oop*)cache->constant_pool_addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
171 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Iteration over constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
174 for (int i = 0; i < cache->length(); ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 cache->entry_at(i)->update_pointers(beg_addr, end_addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 return cache->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
185 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 // super print
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
187 Klass::oop_print_on(obj, st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // print constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
189 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->print(st, i);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 void constantPoolCacheKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 guarantee(obj->is_constantPoolCache(), "obj must be constant pool cache");
a61af66fc99e Initial load
duke
parents:
diff changeset
196 constantPoolCacheOop cache = (constantPoolCacheOop)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 // super verify
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
198 Klass::oop_verify_on(obj, st);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // print constant pool cache entries
a61af66fc99e Initial load
duke
parents:
diff changeset
200 for (int i = 0; i < cache->length(); i++) cache->entry_at(i)->verify(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 const char* constantPoolCacheKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 return "{constant pool cache}";
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }