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