Mercurial > hg > truffle
annotate src/share/vm/memory/compactingPermGenGen.cpp @ 6024:973046802b6f
7162955: Attach api on Solaris, too many open files
Summary: Release server-side socket after client receives it.
Reviewed-by: sla, dsamersoff, dcubed, acorn
Contributed-by: dean.long@oracle.com
author | dlong |
---|---|
date | Thu, 26 Apr 2012 16:24:15 -0400 |
parents | b632e80fc9dc |
children |
rev | line source |
---|---|
0 | 1 /* |
4907
77a488cd4af2
7140866: assert(covered) failed: Card for end of new region not committed
dlong
parents:
2426
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1051
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1051
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1051
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/symbolTable.hpp" | |
27 #include "classfile/systemDictionary.hpp" | |
28 #include "memory/compactingPermGenGen.hpp" | |
29 #include "memory/filemap.hpp" | |
30 #include "memory/genOopClosures.inline.hpp" | |
31 #include "memory/generation.inline.hpp" | |
32 #include "memory/generationSpec.hpp" | |
33 #include "oops/oop.inline.hpp" | |
34 #include "runtime/java.hpp" | |
35 #ifndef SERIALGC | |
36 #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.inline.hpp" | |
37 #endif | |
0 | 38 |
39 | |
47
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
40 // 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
|
41 // 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
|
42 // 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
|
43 // RedefineClasses() API has been called. |
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 class AdjustSharedObjectClosure : public ObjectClosure { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
46 public: |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
47 void do_object(oop obj) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
48 if (obj->is_shared_readwrite()) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
49 if (obj->mark()->is_marked()) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
50 obj->init_mark(); // Don't revisit this object. |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
51 obj->adjust_pointers(); // Adjust this object's references. |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
52 } |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
53 } |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
54 } |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
55 }; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
56 |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
57 |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
58 // 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
|
59 // 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
|
60 // to prevent visiting any object twice. |
0 | 61 |
62 class RecursiveAdjustSharedObjectClosure : public OopClosure { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
63 protected: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
64 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
|
65 oop obj = oopDesc::load_decode_heap_oop_not_null(p); |
0 | 66 if (obj->is_shared_readwrite()) { |
67 if (obj->mark()->is_marked()) { | |
68 obj->init_mark(); // Don't revisit this object. | |
69 obj->oop_iterate(this); // Recurse - adjust objects referenced. | |
70 obj->adjust_pointers(); // Adjust this object's references. | |
71 | |
72 // Special case: if a class has a read-only constant pool, | |
73 // then the read-write objects referenced by the pool must | |
74 // have their marks reset. | |
75 | |
76 if (obj->klass() == Universe::instanceKlassKlassObj()) { | |
77 instanceKlass* ik = instanceKlass::cast((klassOop)obj); | |
78 constantPoolOop cp = ik->constants(); | |
79 if (cp->is_shared_readonly()) { | |
80 cp->oop_iterate(this); | |
81 } | |
82 } | |
83 } | |
84 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
85 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
86 public: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
47
diff
changeset
|
87 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
|
88 virtual void do_oop(narrowOop* p) { RecursiveAdjustSharedObjectClosure::do_oop_work(p); } |
0 | 89 }; |
90 | |
91 | |
92 // We need to go through all placeholders in the system dictionary and | |
93 // try to resolve them into shared classes. Other threads might be in | |
94 // the process of loading a shared class and have strong roots on | |
95 // their stack to the class without having added the class to the | |
96 // dictionary yet. This means the class will be marked during phase 1 | |
97 // but will not be unmarked during the application of the | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
98 // RecursiveAdjustSharedObjectClosure to the SystemDictionary. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
99 class TraversePlaceholdersClosure { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
100 public: |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
101 static void placeholders_do(Symbol* sym, oop loader) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
102 if (CompactingPermGenGen::is_shared(sym)) { |
0 | 103 oop k = SystemDictionary::find_shared_class(sym); |
104 if (k != NULL) { | |
105 RecursiveAdjustSharedObjectClosure clo; | |
106 clo.do_oop(&k); | |
107 } | |
108 } | |
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 if (UseSharedSpaces) { | |
244 | |
245 // Map in the regions in the shared file. | |
246 FileMapInfo* mapinfo = FileMapInfo::current_info(); | |
247 size_t image_alignment = mapinfo->alignment(); | |
248 CollectedHeap* ch = Universe::heap(); | |
249 if ((!mapinfo->map_space(ro, ro_rs, _ro_space)) || | |
250 (!mapinfo->map_space(rw, rw_rs, _rw_space)) || | |
251 (!mapinfo->map_space(md, md_rs, NULL)) || | |
252 (!mapinfo->map_space(mc, mc_rs, NULL)) || | |
253 // check the alignment constraints | |
254 (ch == NULL || ch->kind() != CollectedHeap::GenCollectedHeap || | |
255 image_alignment != | |
256 ((GenCollectedHeap*)ch)->gen_policy()->max_alignment())) { | |
257 // Base addresses didn't match; skip sharing, but continue | |
258 shared_rs.release(); | |
259 spec()->disable_sharing(); | |
260 // If -Xshare:on is specified, print out the error message and exit VM, | |
261 // otherwise, set UseSharedSpaces to false and continue. | |
262 if (RequireSharedSpaces) { | |
263 vm_exit_during_initialization("Unable to use shared archive.", NULL); | |
264 } else { | |
265 FLAG_SET_DEFAULT(UseSharedSpaces, false); | |
266 } | |
267 | |
268 // Note: freeing the block offset array objects does not | |
269 // currently free up the underlying storage. | |
270 delete _ro_bts; | |
271 _ro_bts = NULL; | |
272 delete _ro_space; | |
273 _ro_space = NULL; | |
274 delete _rw_bts; | |
275 _rw_bts = NULL; | |
276 delete _rw_space; | |
277 _rw_space = NULL; | |
278 shared_end = (HeapWord*)(rs.base() + rs.size()); | |
279 } | |
280 } | |
281 | |
4907
77a488cd4af2
7140866: assert(covered) failed: Card for end of new region not committed
dlong
parents:
2426
diff
changeset
|
282 if (spec()->enable_shared_spaces()) { |
77a488cd4af2
7140866: assert(covered) failed: Card for end of new region not committed
dlong
parents:
2426
diff
changeset
|
283 // Cover both shared spaces entirely with cards. |
77a488cd4af2
7140866: assert(covered) failed: Card for end of new region not committed
dlong
parents:
2426
diff
changeset
|
284 _rs->resize_covered_region(MemRegion(readonly_bottom, readwrite_end)); |
77a488cd4af2
7140866: assert(covered) failed: Card for end of new region not committed
dlong
parents:
2426
diff
changeset
|
285 } |
77a488cd4af2
7140866: assert(covered) failed: Card for end of new region not committed
dlong
parents:
2426
diff
changeset
|
286 |
0 | 287 // Reserved region includes shared spaces for oop.is_in_reserved(). |
288 _reserved.set_end(shared_end); | |
289 | |
290 } else { | |
291 _ro_space = NULL; | |
292 _rw_space = NULL; | |
293 } | |
294 } | |
295 | |
296 | |
297 // Do a complete scan of the shared read write space to catch all | |
298 // objects which contain references to any younger generation. Forward | |
299 // the pointers. Avoid space_iterate, as actually visiting all the | |
300 // objects in the space will page in more objects than we need. | |
301 // Instead, use the system dictionary as strong roots into the read | |
302 // write space. | |
47
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
303 // |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
304 // 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
|
305 // 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
|
306 // 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
|
307 // 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
|
308 // 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
|
309 // 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
|
310 // 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
|
311 // (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
|
312 // 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
|
313 // 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
|
314 // 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
|
315 // even after we've severed our minimal attachments. |
0 | 316 |
317 void CompactingPermGenGen::pre_adjust_pointers() { | |
318 if (spec()->enable_shared_spaces()) { | |
47
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
319 if (JvmtiExport::has_redefined_a_class()) { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
320 // RedefineClasses() requires a brute force approach |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
321 AdjustSharedObjectClosure blk; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
322 rw_space()->object_iterate(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
323 } else { |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
324 RecursiveAdjustSharedObjectClosure blk; |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
325 Universe::oops_do(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
326 StringTable::oops_do(&blk); |
2c106685d6d0
6497639: 4/3 Profiling Swing application caused JVM crash
dcubed
parents:
0
diff
changeset
|
327 SystemDictionary::always_strong_classes_do(&blk); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
328 SystemDictionary::placeholders_do(TraversePlaceholdersClosure::placeholders_do); |
47
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 | |
1051
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
355 // Do not use in time-critical operations due to the possibility of paging |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
356 // in otherwise untouched or previously unread portions of the perm gen, |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
357 // for instance, the shared spaces. NOTE: Because CompactingPermGenGen |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
358 // derives from OneContigSpaceCardGeneration which is supposed to have a |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
359 // single space, and does not override its object_iterate() method, |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
360 // object iteration via that interface does not look at the objects in |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
361 // the shared spaces when using CDS. This should be fixed; see CR 6897798. |
0 | 362 void CompactingPermGenGen::space_iterate(SpaceClosure* blk, bool usedOnly) { |
363 OneContigSpaceCardGeneration::space_iterate(blk, usedOnly); | |
364 if (spec()->enable_shared_spaces()) { | |
365 // Making the rw_space walkable will page in the entire space, and | |
1051
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
366 // is to be avoided in the case of time-critical operations. |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
291
diff
changeset
|
367 // However, this is required for Verify and heap dump operations. |
0 | 368 blk->do_space(ro_space()); |
369 blk->do_space(rw_space()); | |
370 } | |
371 } | |
372 | |
373 | |
374 void CompactingPermGenGen::print_on(outputStream* st) const { | |
375 OneContigSpaceCardGeneration::print_on(st); | |
376 if (spec()->enable_shared_spaces()) { | |
377 st->print(" ro"); | |
378 ro_space()->print_on(st); | |
379 st->print(" rw"); | |
380 rw_space()->print_on(st); | |
381 } else { | |
382 st->print_cr("No shared spaces configured."); | |
383 } | |
384 } | |
385 | |
386 | |
387 // References from the perm gen to the younger generation objects may | |
388 // occur in static fields in Java classes or in constant pool references | |
389 // to String objects. | |
390 | |
391 void CompactingPermGenGen::younger_refs_iterate(OopsInGenClosure* blk) { | |
392 OneContigSpaceCardGeneration::younger_refs_iterate(blk); | |
393 if (spec()->enable_shared_spaces()) { | |
394 blk->set_generation(this); | |
395 // ro_space has no younger gen refs. | |
396 _rs->younger_refs_in_space_iterate(rw_space(), blk); | |
397 blk->reset_generation(); | |
398 } | |
399 } | |
400 | |
401 | |
402 // Shared spaces are addressed in pre_adjust_pointers. | |
403 void CompactingPermGenGen::adjust_pointers() { | |
404 the_space()->adjust_pointers(); | |
405 } | |
406 | |
407 | |
408 void CompactingPermGenGen::compact() { | |
409 the_space()->compact(); | |
410 } | |
411 | |
412 | |
413 size_t CompactingPermGenGen::contiguous_available() const { | |
414 // Don't include shared spaces. | |
415 return OneContigSpaceCardGeneration::contiguous_available() | |
416 - _shared_space_size; | |
417 } | |
418 | |
419 size_t CompactingPermGenGen::max_capacity() const { | |
420 // Don't include shared spaces. | |
421 assert(UseSharedSpaces || (_shared_space_size == 0), | |
422 "If not used, the size of shared spaces should be 0"); | |
423 return OneContigSpaceCardGeneration::max_capacity() | |
424 - _shared_space_size; | |
425 } | |
426 | |
427 | |
428 // No young generation references, clear this generation's main space's | |
429 // card table entries. Do NOT clear the card table entries for the | |
430 // read-only space (always clear) or the read-write space (valuable | |
431 // information). | |
432 | |
433 void CompactingPermGenGen::clear_remembered_set() { | |
434 _rs->clear(MemRegion(the_space()->bottom(), the_space()->end())); | |
435 } | |
436 | |
437 | |
438 // Objects in this generation's main space may have moved, invalidate | |
439 // that space's cards. Do NOT invalidate the card table entries for the | |
440 // read-only or read-write spaces, as those objects never move. | |
441 | |
442 void CompactingPermGenGen::invalidate_remembered_set() { | |
443 _rs->invalidate(used_region()); | |
444 } | |
445 | |
446 | |
6008 | 447 void CompactingPermGenGen::verify() { |
448 the_space()->verify(); | |
0 | 449 if (!SharedSkipVerify && spec()->enable_shared_spaces()) { |
6008 | 450 ro_space()->verify(); |
451 rw_space()->verify(); | |
0 | 452 } |
453 } | |
454 | |
455 | |
456 HeapWord* CompactingPermGenGen::unshared_bottom; | |
457 HeapWord* CompactingPermGenGen::unshared_end; | |
458 HeapWord* CompactingPermGenGen::shared_bottom; | |
459 HeapWord* CompactingPermGenGen::shared_end; | |
460 HeapWord* CompactingPermGenGen::readonly_bottom; | |
461 HeapWord* CompactingPermGenGen::readonly_end; | |
462 HeapWord* CompactingPermGenGen::readwrite_bottom; | |
463 HeapWord* CompactingPermGenGen::readwrite_end; | |
464 HeapWord* CompactingPermGenGen::miscdata_bottom; | |
465 HeapWord* CompactingPermGenGen::miscdata_end; | |
466 HeapWord* CompactingPermGenGen::misccode_bottom; | |
467 HeapWord* CompactingPermGenGen::misccode_end; | |
468 | |
469 // JVM/TI RedefineClasses() support: | |
470 bool CompactingPermGenGen::remap_shared_readonly_as_readwrite() { | |
471 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); | |
472 | |
473 if (UseSharedSpaces) { | |
474 // remap the shared readonly space to shared readwrite, private | |
475 FileMapInfo* mapinfo = FileMapInfo::current_info(); | |
476 if (!mapinfo->remap_shared_readonly_as_readwrite()) { | |
477 return false; | |
478 } | |
479 } | |
480 return true; | |
481 } |