Mercurial > hg > graal-jvmci-8
annotate src/share/vm/memory/compactingPermGenGen.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 | 5251a9cd8eb8 |
children | 26f1542097f1 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 #include "incls/_precompiled.incl" | |
26 #include "incls/_compactingPermGenGen.cpp.incl" | |
27 | |
28 | |
47
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
29 // An ObjectClosure helper: Recursively adjust all pointers in an object |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
30 // and all objects by referenced it. Clear marks on objects in order to |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
31 // prevent visiting any object twice. This helper is used when the |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
32 // RedefineClasses() API has been called. |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
33 |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
34 class AdjustSharedObjectClosure : public ObjectClosure { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
35 public: |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
36 void do_object(oop obj) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
37 if (obj->is_shared_readwrite()) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
38 if (obj->mark()->is_marked()) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
39 obj->init_mark(); // Don't revisit this object. |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
40 obj->adjust_pointers(); // Adjust this object's references. |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
41 } |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
42 } |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
43 } |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
44 }; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
45 |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
46 |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
47 // An OopClosure helper: Recursively adjust all pointers in an object |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
48 // and all objects by referenced it. Clear marks on objects in order |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
49 // to prevent visiting any object twice. |
0 | 50 |
51 class RecursiveAdjustSharedObjectClosure : public OopClosure { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
52 protected: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
53 template <class T> inline void do_oop_work(T* p) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
54 oop obj = oopDesc::load_decode_heap_oop_not_null(p); |
0 | 55 if (obj->is_shared_readwrite()) { |
56 if (obj->mark()->is_marked()) { | |
57 obj->init_mark(); // Don't revisit this object. | |
58 obj->oop_iterate(this); // Recurse - adjust objects referenced. | |
59 obj->adjust_pointers(); // Adjust this object's references. | |
60 | |
61 // Special case: if a class has a read-only constant pool, | |
62 // then the read-write objects referenced by the pool must | |
63 // have their marks reset. | |
64 | |
65 if (obj->klass() == Universe::instanceKlassKlassObj()) { | |
66 instanceKlass* ik = instanceKlass::cast((klassOop)obj); | |
67 constantPoolOop cp = ik->constants(); | |
68 if (cp->is_shared_readonly()) { | |
69 cp->oop_iterate(this); | |
70 } | |
71 } | |
72 } | |
73 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
74 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
75 public: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
76 virtual void do_oop(oop* p) { RecursiveAdjustSharedObjectClosure::do_oop_work(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
77 virtual void do_oop(narrowOop* p) { RecursiveAdjustSharedObjectClosure::do_oop_work(p); } |
0 | 78 }; |
79 | |
80 | |
81 // We need to go through all placeholders in the system dictionary and | |
82 // try to resolve them into shared classes. Other threads might be in | |
83 // the process of loading a shared class and have strong roots on | |
84 // their stack to the class without having added the class to the | |
85 // dictionary yet. This means the class will be marked during phase 1 | |
86 // but will not be unmarked during the application of the | |
87 // RecursiveAdjustSharedObjectClosure to the SystemDictionary. Note | |
88 // that we must not call find_shared_class with non-read-only symbols | |
89 // as doing so can cause hash codes to be computed, destroying | |
90 // forwarding pointers. | |
91 class TraversePlaceholdersClosure : public OopClosure { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
92 protected: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
93 template <class T> inline void do_oop_work(T* p) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
94 oop obj = oopDesc::load_decode_heap_oop_not_null(p); |
0 | 95 if (obj->klass() == Universe::symbolKlassObj() && |
96 obj->is_shared_readonly()) { | |
97 symbolHandle sym((symbolOop) obj); | |
98 oop k = SystemDictionary::find_shared_class(sym); | |
99 if (k != NULL) { | |
100 RecursiveAdjustSharedObjectClosure clo; | |
101 clo.do_oop(&k); | |
102 } | |
103 } | |
104 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
105 public: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
106 virtual void do_oop(oop* p) { TraversePlaceholdersClosure::do_oop_work(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
107 virtual void do_oop(narrowOop* p) { TraversePlaceholdersClosure::do_oop_work(p); } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
108 |
0 | 109 }; |
110 | |
111 | |
112 void CompactingPermGenGen::initialize_performance_counters() { | |
113 | |
114 const char* gen_name = "perm"; | |
115 | |
116 // Generation Counters - generation 2, 1 subspace | |
117 _gen_counters = new GenerationCounters(gen_name, 2, 1, &_virtual_space); | |
118 | |
119 _space_counters = new CSpaceCounters(gen_name, 0, | |
120 _virtual_space.reserved_size(), | |
121 _the_space, _gen_counters); | |
122 } | |
123 | |
124 void CompactingPermGenGen::update_counters() { | |
125 if (UsePerfData) { | |
126 _space_counters->update_all(); | |
127 _gen_counters->update_all(); | |
128 } | |
129 } | |
130 | |
131 | |
132 CompactingPermGenGen::CompactingPermGenGen(ReservedSpace rs, | |
133 ReservedSpace shared_rs, | |
134 size_t initial_byte_size, | |
135 int level, GenRemSet* remset, | |
136 ContiguousSpace* space, | |
137 PermanentGenerationSpec* spec_) : | |
138 OneContigSpaceCardGeneration(rs, initial_byte_size, MinPermHeapExpansion, | |
139 level, remset, space) { | |
140 | |
141 set_spec(spec_); | |
142 if (!UseSharedSpaces && !DumpSharedSpaces) { | |
143 spec()->disable_sharing(); | |
144 } | |
145 | |
146 // Break virtual space into address ranges for all spaces. | |
147 | |
148 if (spec()->enable_shared_spaces()) { | |
149 shared_end = (HeapWord*)(shared_rs.base() + shared_rs.size()); | |
150 misccode_end = shared_end; | |
151 misccode_bottom = misccode_end - heap_word_size(spec()->misc_code_size()); | |
152 miscdata_end = misccode_bottom; | |
153 miscdata_bottom = miscdata_end - heap_word_size(spec()->misc_data_size()); | |
154 readwrite_end = miscdata_bottom; | |
155 readwrite_bottom = | |
156 readwrite_end - heap_word_size(spec()->read_write_size()); | |
157 readonly_end = readwrite_bottom; | |
158 readonly_bottom = | |
159 readonly_end - heap_word_size(spec()->read_only_size()); | |
160 shared_bottom = readonly_bottom; | |
161 unshared_end = shared_bottom; | |
162 assert((char*)shared_bottom == shared_rs.base(), "shared space mismatch"); | |
163 } else { | |
164 shared_end = (HeapWord*)(rs.base() + rs.size()); | |
165 misccode_end = shared_end; | |
166 misccode_bottom = shared_end; | |
167 miscdata_end = shared_end; | |
168 miscdata_bottom = shared_end; | |
169 readwrite_end = shared_end; | |
170 readwrite_bottom = shared_end; | |
171 readonly_end = shared_end; | |
172 readonly_bottom = shared_end; | |
173 shared_bottom = shared_end; | |
174 unshared_end = shared_bottom; | |
175 } | |
176 unshared_bottom = (HeapWord*) rs.base(); | |
177 | |
178 // Verify shared and unshared spaces adjacent. | |
179 assert((char*)shared_bottom == rs.base()+rs.size(), "shared space mismatch"); | |
180 assert(unshared_end > unshared_bottom, "shared space mismatch"); | |
181 | |
182 // Split reserved memory into pieces. | |
183 | |
184 ReservedSpace ro_rs = shared_rs.first_part(spec()->read_only_size(), | |
185 UseSharedSpaces); | |
186 ReservedSpace tmp_rs1 = shared_rs.last_part(spec()->read_only_size()); | |
187 ReservedSpace rw_rs = tmp_rs1.first_part(spec()->read_write_size(), | |
188 UseSharedSpaces); | |
189 ReservedSpace tmp_rs2 = tmp_rs1.last_part(spec()->read_write_size()); | |
190 ReservedSpace md_rs = tmp_rs2.first_part(spec()->misc_data_size(), | |
191 UseSharedSpaces); | |
192 ReservedSpace mc_rs = tmp_rs2.last_part(spec()->misc_data_size()); | |
193 | |
194 _shared_space_size = spec()->read_only_size() | |
195 + spec()->read_write_size() | |
196 + spec()->misc_data_size() | |
197 + spec()->misc_code_size(); | |
198 | |
199 // Allocate the unshared (default) space. | |
200 _the_space = new ContigPermSpace(_bts, | |
201 MemRegion(unshared_bottom, heap_word_size(initial_byte_size))); | |
202 if (_the_space == NULL) | |
203 vm_exit_during_initialization("Could not allocate an unshared" | |
204 " CompactingPermGen Space"); | |
205 | |
206 // Allocate shared spaces | |
207 if (spec()->enable_shared_spaces()) { | |
208 | |
209 // If mapping a shared file, the space is not committed, don't | |
210 // mangle. | |
211 NOT_PRODUCT(bool old_ZapUnusedHeapArea = ZapUnusedHeapArea;) | |
212 NOT_PRODUCT(if (UseSharedSpaces) ZapUnusedHeapArea = false;) | |
213 | |
214 // Commit the memory behind the shared spaces if dumping (not | |
215 // mapping). | |
216 if (DumpSharedSpaces) { | |
217 _ro_vs.initialize(ro_rs, spec()->read_only_size()); | |
218 _rw_vs.initialize(rw_rs, spec()->read_write_size()); | |
219 _md_vs.initialize(md_rs, spec()->misc_data_size()); | |
220 _mc_vs.initialize(mc_rs, spec()->misc_code_size()); | |
221 } | |
222 | |
223 // Allocate the shared spaces. | |
224 _ro_bts = new BlockOffsetSharedArray( | |
225 MemRegion(readonly_bottom, | |
226 heap_word_size(spec()->read_only_size())), | |
227 heap_word_size(spec()->read_only_size())); | |
228 _ro_space = new OffsetTableContigSpace(_ro_bts, | |
229 MemRegion(readonly_bottom, readonly_end)); | |
230 _rw_bts = new BlockOffsetSharedArray( | |
231 MemRegion(readwrite_bottom, | |
232 heap_word_size(spec()->read_write_size())), | |
233 heap_word_size(spec()->read_write_size())); | |
234 _rw_space = new OffsetTableContigSpace(_rw_bts, | |
235 MemRegion(readwrite_bottom, readwrite_end)); | |
236 | |
237 // Restore mangling flag. | |
238 NOT_PRODUCT(ZapUnusedHeapArea = old_ZapUnusedHeapArea;) | |
239 | |
240 if (_ro_space == NULL || _rw_space == NULL) | |
241 vm_exit_during_initialization("Could not allocate a shared space"); | |
242 | |
243 // Cover both shared spaces entirely with cards. | |
244 _rs->resize_covered_region(MemRegion(readonly_bottom, readwrite_end)); | |
245 | |
246 if (UseSharedSpaces) { | |
247 | |
248 // Map in the regions in the shared file. | |
249 FileMapInfo* mapinfo = FileMapInfo::current_info(); | |
250 size_t image_alignment = mapinfo->alignment(); | |
251 CollectedHeap* ch = Universe::heap(); | |
252 if ((!mapinfo->map_space(ro, ro_rs, _ro_space)) || | |
253 (!mapinfo->map_space(rw, rw_rs, _rw_space)) || | |
254 (!mapinfo->map_space(md, md_rs, NULL)) || | |
255 (!mapinfo->map_space(mc, mc_rs, NULL)) || | |
256 // check the alignment constraints | |
257 (ch == NULL || ch->kind() != CollectedHeap::GenCollectedHeap || | |
258 image_alignment != | |
259 ((GenCollectedHeap*)ch)->gen_policy()->max_alignment())) { | |
260 // Base addresses didn't match; skip sharing, but continue | |
261 shared_rs.release(); | |
262 spec()->disable_sharing(); | |
263 // If -Xshare:on is specified, print out the error message and exit VM, | |
264 // otherwise, set UseSharedSpaces to false and continue. | |
265 if (RequireSharedSpaces) { | |
266 vm_exit_during_initialization("Unable to use shared archive.", NULL); | |
267 } else { | |
268 FLAG_SET_DEFAULT(UseSharedSpaces, false); | |
269 } | |
270 | |
271 // Note: freeing the block offset array objects does not | |
272 // currently free up the underlying storage. | |
273 delete _ro_bts; | |
274 _ro_bts = NULL; | |
275 delete _ro_space; | |
276 _ro_space = NULL; | |
277 delete _rw_bts; | |
278 _rw_bts = NULL; | |
279 delete _rw_space; | |
280 _rw_space = NULL; | |
281 shared_end = (HeapWord*)(rs.base() + rs.size()); | |
282 _rs->resize_covered_region(MemRegion(shared_bottom, shared_bottom)); | |
283 } | |
284 } | |
285 | |
286 // Reserved region includes shared spaces for oop.is_in_reserved(). | |
287 _reserved.set_end(shared_end); | |
288 | |
289 } else { | |
290 _ro_space = NULL; | |
291 _rw_space = NULL; | |
292 } | |
293 } | |
294 | |
295 | |
296 // Do a complete scan of the shared read write space to catch all | |
297 // objects which contain references to any younger generation. Forward | |
298 // the pointers. Avoid space_iterate, as actually visiting all the | |
299 // objects in the space will page in more objects than we need. | |
300 // Instead, use the system dictionary as strong roots into the read | |
301 // write space. | |
47
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
302 // |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
303 // If a RedefineClasses() call has been made, then we have to iterate |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
304 // over the entire shared read-write space in order to find all the |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
305 // objects that need to be forwarded. For example, it is possible for |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
306 // an nmethod to be found and marked in GC phase-1 only for the nmethod |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
307 // to be freed by the time we reach GC phase-3. The underlying method |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
308 // is still marked, but we can't (easily) find it in GC phase-3 so we |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
309 // blow up in GC phase-4. With RedefineClasses() we want replaced code |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
310 // (EMCP or obsolete) to go away (i.e., be collectible) once it is no |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
311 // longer being executed by any thread so we keep minimal attachments |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
312 // to the replaced code. However, we can't guarantee when those EMCP |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
313 // or obsolete methods will be collected so they may still be out there |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
314 // even after we've severed our minimal attachments. |
0 | 315 |
316 void CompactingPermGenGen::pre_adjust_pointers() { | |
317 if (spec()->enable_shared_spaces()) { | |
47
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
318 if (JvmtiExport::has_redefined_a_class()) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
319 // RedefineClasses() requires a brute force approach |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
320 AdjustSharedObjectClosure blk; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
321 rw_space()->object_iterate(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
322 } else { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
323 RecursiveAdjustSharedObjectClosure blk; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
324 Universe::oops_do(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
325 StringTable::oops_do(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
326 SystemDictionary::always_strong_classes_do(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
327 TraversePlaceholdersClosure tpc; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
328 SystemDictionary::placeholders_do(&tpc); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
329 } |
0 | 330 } |
331 } | |
332 | |
333 | |
334 #ifdef ASSERT | |
335 class VerifyMarksClearedClosure : public ObjectClosure { | |
336 public: | |
337 void do_object(oop obj) { | |
338 assert(SharedSkipVerify || !obj->mark()->is_marked(), | |
339 "Shared oop still marked?"); | |
340 } | |
341 }; | |
342 #endif | |
343 | |
344 | |
345 void CompactingPermGenGen::post_compact() { | |
346 #ifdef ASSERT | |
347 if (!SharedSkipVerify && spec()->enable_shared_spaces()) { | |
348 VerifyMarksClearedClosure blk; | |
349 rw_space()->object_iterate(&blk); | |
350 } | |
351 #endif | |
352 } | |
353 | |
354 | |
355 void CompactingPermGenGen::space_iterate(SpaceClosure* blk, bool usedOnly) { | |
356 OneContigSpaceCardGeneration::space_iterate(blk, usedOnly); | |
357 if (spec()->enable_shared_spaces()) { | |
358 #ifdef PRODUCT | |
359 // Making the rw_space walkable will page in the entire space, and | |
360 // is to be avoided. However, this is required for Verify options. | |
361 ShouldNotReachHere(); | |
362 #endif | |
363 | |
364 blk->do_space(ro_space()); | |
365 blk->do_space(rw_space()); | |
366 } | |
367 } | |
368 | |
369 | |
370 void CompactingPermGenGen::print_on(outputStream* st) const { | |
371 OneContigSpaceCardGeneration::print_on(st); | |
372 if (spec()->enable_shared_spaces()) { | |
373 st->print(" ro"); | |
374 ro_space()->print_on(st); | |
375 st->print(" rw"); | |
376 rw_space()->print_on(st); | |
377 } else { | |
378 st->print_cr("No shared spaces configured."); | |
379 } | |
380 } | |
381 | |
382 | |
383 // References from the perm gen to the younger generation objects may | |
384 // occur in static fields in Java classes or in constant pool references | |
385 // to String objects. | |
386 | |
387 void CompactingPermGenGen::younger_refs_iterate(OopsInGenClosure* blk) { | |
388 OneContigSpaceCardGeneration::younger_refs_iterate(blk); | |
389 if (spec()->enable_shared_spaces()) { | |
390 blk->set_generation(this); | |
391 // ro_space has no younger gen refs. | |
392 _rs->younger_refs_in_space_iterate(rw_space(), blk); | |
393 blk->reset_generation(); | |
394 } | |
395 } | |
396 | |
397 | |
398 // Shared spaces are addressed in pre_adjust_pointers. | |
399 void CompactingPermGenGen::adjust_pointers() { | |
400 the_space()->adjust_pointers(); | |
401 } | |
402 | |
403 | |
404 void CompactingPermGenGen::compact() { | |
405 the_space()->compact(); | |
406 } | |
407 | |
408 | |
409 size_t CompactingPermGenGen::contiguous_available() const { | |
410 // Don't include shared spaces. | |
411 return OneContigSpaceCardGeneration::contiguous_available() | |
412 - _shared_space_size; | |
413 } | |
414 | |
415 size_t CompactingPermGenGen::max_capacity() const { | |
416 // Don't include shared spaces. | |
417 assert(UseSharedSpaces || (_shared_space_size == 0), | |
418 "If not used, the size of shared spaces should be 0"); | |
419 return OneContigSpaceCardGeneration::max_capacity() | |
420 - _shared_space_size; | |
421 } | |
422 | |
423 | |
424 // No young generation references, clear this generation's main space's | |
425 // card table entries. Do NOT clear the card table entries for the | |
426 // read-only space (always clear) or the read-write space (valuable | |
427 // information). | |
428 | |
429 void CompactingPermGenGen::clear_remembered_set() { | |
430 _rs->clear(MemRegion(the_space()->bottom(), the_space()->end())); | |
431 } | |
432 | |
433 | |
434 // Objects in this generation's main space may have moved, invalidate | |
435 // that space's cards. Do NOT invalidate the card table entries for the | |
436 // read-only or read-write spaces, as those objects never move. | |
437 | |
438 void CompactingPermGenGen::invalidate_remembered_set() { | |
439 _rs->invalidate(used_region()); | |
440 } | |
441 | |
442 | |
443 void CompactingPermGenGen::verify(bool allow_dirty) { | |
444 the_space()->verify(allow_dirty); | |
445 if (!SharedSkipVerify && spec()->enable_shared_spaces()) { | |
446 ro_space()->verify(allow_dirty); | |
447 rw_space()->verify(allow_dirty); | |
448 } | |
449 } | |
450 | |
451 | |
452 HeapWord* CompactingPermGenGen::unshared_bottom; | |
453 HeapWord* CompactingPermGenGen::unshared_end; | |
454 HeapWord* CompactingPermGenGen::shared_bottom; | |
455 HeapWord* CompactingPermGenGen::shared_end; | |
456 HeapWord* CompactingPermGenGen::readonly_bottom; | |
457 HeapWord* CompactingPermGenGen::readonly_end; | |
458 HeapWord* CompactingPermGenGen::readwrite_bottom; | |
459 HeapWord* CompactingPermGenGen::readwrite_end; | |
460 HeapWord* CompactingPermGenGen::miscdata_bottom; | |
461 HeapWord* CompactingPermGenGen::miscdata_end; | |
462 HeapWord* CompactingPermGenGen::misccode_bottom; | |
463 HeapWord* CompactingPermGenGen::misccode_end; | |
464 | |
465 // JVM/TI RedefineClasses() support: | |
466 bool CompactingPermGenGen::remap_shared_readonly_as_readwrite() { | |
467 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | |
468 | |
469 if (UseSharedSpaces) { | |
470 // remap the shared readonly space to shared readwrite, private | |
471 FileMapInfo* mapinfo = FileMapInfo::current_info(); | |
472 if (!mapinfo->remap_shared_readonly_as_readwrite()) { | |
473 return false; | |
474 } | |
475 } | |
476 return true; | |
477 } | |
478 | |
479 void** CompactingPermGenGen::_vtbl_list; |