Mercurial > hg > truffle
comparison src/share/vm/memory/compactingPermGenGen.hpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | 818a18cd69a8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
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 // All heaps contains a "permanent generation," containing permanent | |
26 // (reflective) objects. This is like a regular generation in some ways, | |
27 // but unlike one in others, and so is split apart. | |
28 | |
29 class PermanentGenerationSpec; | |
30 | |
31 // This is the "generation" view of a CompactingPermGen. | |
32 class CompactingPermGenGen: public OneContigSpaceCardGeneration { | |
33 friend class VMStructs; | |
34 // Abstractly, this is a subtype that gets access to protected fields. | |
35 friend class CompactingPermGen; | |
36 | |
37 private: | |
38 // Shared spaces | |
39 PermanentGenerationSpec* _spec; | |
40 size_t _shared_space_size; | |
41 VirtualSpace _ro_vs; | |
42 VirtualSpace _rw_vs; | |
43 VirtualSpace _md_vs; | |
44 VirtualSpace _mc_vs; | |
45 BlockOffsetSharedArray* _ro_bts; | |
46 BlockOffsetSharedArray* _rw_bts; | |
47 OffsetTableContigSpace* _ro_space; | |
48 OffsetTableContigSpace* _rw_space; | |
49 | |
50 // With shared spaces there is a dicotomy in the use of the | |
51 // _virtual_space of the generation. There is a portion of the | |
52 // _virtual_space that is used for the unshared part of the | |
53 // permanent generation and a portion that is reserved for the shared part. | |
54 // The _reserved field in the generation represents both the | |
55 // unshared and shared parts of the generation. The _reserved | |
56 // variable is initialized for only the unshared part but is | |
57 // later extended to include the shared part during initialization | |
58 // if shared spaces are being used. | |
59 // The reserved size for the _virtual_space for CompactingPermGenGen | |
60 // is the size of the space for the permanent generation including the | |
61 // the shared spaces. This can be seen by the use of MaxPermSize | |
62 // in the allocation of PermanentGenerationSpec. The space for the | |
63 // shared spaces is committed separately (???). | |
64 // In general at initialization only a part of the | |
65 // space for the unshared part of the permanent generation is | |
66 // committed and more is committed as the permanent generation is | |
67 // grown. In growing the permanent generation the capacity() and | |
68 // max_capacity() of the generation are used. For the permanent | |
69 // generation (implemented with a CompactingPermGenGen) the capacity() | |
70 // is taken from the capacity of the space (_the_space variable used for the | |
71 // unshared part of the generation) and the max_capacity() is based | |
72 // on the size of the _reserved variable (which includes the size of the | |
73 // shared spaces) minus the size of the shared spaces. | |
74 | |
75 // These values are redundant, but are called out separately to avoid | |
76 // going through heap/space/gen pointers for performance. | |
77 static HeapWord* unshared_bottom; | |
78 static HeapWord* unshared_end; | |
79 static HeapWord* shared_bottom; | |
80 static HeapWord* readonly_bottom; | |
81 static HeapWord* readonly_end; | |
82 static HeapWord* readwrite_bottom; | |
83 static HeapWord* readwrite_end; | |
84 static HeapWord* miscdata_bottom; | |
85 static HeapWord* miscdata_end; | |
86 static HeapWord* misccode_bottom; | |
87 static HeapWord* misccode_end; | |
88 static HeapWord* shared_end; | |
89 | |
90 // List of klassOops whose vtbl entries are used to patch others. | |
91 static void** _vtbl_list; | |
92 | |
93 // Performance Counters | |
94 GenerationCounters* _gen_counters; | |
95 CSpaceCounters* _space_counters; | |
96 | |
97 void initialize_performance_counters(); | |
98 | |
99 public: | |
100 | |
101 enum { | |
102 vtbl_list_size = 16, // number of entries in the shared space vtable list. | |
103 num_virtuals = 100 // number of virtual methods in Klass (or | |
104 // subclass) objects, or greater. | |
105 }; | |
106 | |
107 enum { | |
108 ro = 0, // read-only shared space in the heap | |
109 rw = 1, // read-write shared space in the heap | |
110 md = 2, // miscellaneous data for initializing tables, etc. | |
111 mc = 3, // miscellaneous code - vtable replacement. | |
112 n_regions = 4 | |
113 }; | |
114 | |
115 CompactingPermGenGen(ReservedSpace rs, ReservedSpace shared_rs, | |
116 size_t initial_byte_size, int level, GenRemSet* remset, | |
117 ContiguousSpace* space, | |
118 PermanentGenerationSpec* perm_spec); | |
119 | |
120 const char* name() const { | |
121 return "compacting perm gen"; | |
122 } | |
123 | |
124 const char* short_name() const { | |
125 return "Perm"; | |
126 } | |
127 | |
128 // Return the maximum capacity for the object space. This | |
129 // explicitly does not include the shared spaces. | |
130 size_t max_capacity() const; | |
131 | |
132 void update_counters(); | |
133 | |
134 void compute_new_size() { | |
135 assert(false, "Should not call this -- handled at PermGen level."); | |
136 } | |
137 | |
138 bool must_be_youngest() const { return false; } | |
139 bool must_be_oldest() const { return false; } | |
140 | |
141 OffsetTableContigSpace* ro_space() const { return _ro_space; } | |
142 OffsetTableContigSpace* rw_space() const { return _rw_space; } | |
143 VirtualSpace* md_space() { return &_md_vs; } | |
144 VirtualSpace* mc_space() { return &_mc_vs; } | |
145 ContiguousSpace* unshared_space() const { return _the_space; } | |
146 | |
147 static bool inline is_shared(const oopDesc* p) { | |
148 return (HeapWord*)p >= shared_bottom && (HeapWord*)p < shared_end; | |
149 } | |
150 // RedefineClasses note: this tester is used to check residence of | |
151 // the specified oop in the shared readonly space and not whether | |
152 // the oop is readonly. | |
153 static bool inline is_shared_readonly(const oopDesc* p) { | |
154 return (HeapWord*)p >= readonly_bottom && (HeapWord*)p < readonly_end; | |
155 } | |
156 // RedefineClasses note: this tester is used to check residence of | |
157 // the specified oop in the shared readwrite space and not whether | |
158 // the oop is readwrite. | |
159 static bool inline is_shared_readwrite(const oopDesc* p) { | |
160 return (HeapWord*)p >= readwrite_bottom && (HeapWord*)p < readwrite_end; | |
161 } | |
162 | |
163 bool is_in_unshared(const void* p) const { | |
164 return OneContigSpaceCardGeneration::is_in(p); | |
165 } | |
166 | |
167 bool is_in_shared(const void* p) const { | |
168 return p >= shared_bottom && p < shared_end; | |
169 } | |
170 | |
171 inline bool is_in(const void* p) const { | |
172 return is_in_unshared(p) || is_in_shared(p); | |
173 } | |
174 | |
175 inline PermanentGenerationSpec* spec() const { return _spec; } | |
176 inline void set_spec(PermanentGenerationSpec* spec) { _spec = spec; } | |
177 | |
178 void pre_adjust_pointers(); | |
179 void adjust_pointers(); | |
180 void space_iterate(SpaceClosure* blk, bool usedOnly = false); | |
181 void print_on(outputStream* st) const; | |
182 void younger_refs_iterate(OopsInGenClosure* blk); | |
183 void compact(); | |
184 void post_compact(); | |
185 size_t contiguous_available() const; | |
186 bool grow_by(size_t bytes); | |
187 void grow_to_reserved(); | |
188 | |
189 void clear_remembered_set(); | |
190 void invalidate_remembered_set(); | |
191 | |
192 inline bool block_is_obj(const HeapWord* addr) const { | |
193 if (addr < the_space()->top()) return true; | |
194 else if (addr < the_space()->end()) return false; | |
195 else if (addr < ro_space()->top()) return true; | |
196 else if (addr < ro_space()->end()) return false; | |
197 else if (addr < rw_space()->top()) return true; | |
198 else return false; | |
199 } | |
200 | |
201 | |
202 inline size_t block_size(const HeapWord* addr) const { | |
203 if (addr < the_space()->top()) { | |
204 return oop(addr)->size(); | |
205 } | |
206 else if (addr < the_space()->end()) { | |
207 assert(addr == the_space()->top(), "non-block head arg to block_size"); | |
208 return the_space()->end() - the_space()->top(); | |
209 } | |
210 | |
211 else if (addr < ro_space()->top()) { | |
212 return oop(addr)->size(); | |
213 } | |
214 else if (addr < ro_space()->end()) { | |
215 assert(addr == ro_space()->top(), "non-block head arg to block_size"); | |
216 return ro_space()->end() - ro_space()->top(); | |
217 } | |
218 | |
219 else if (addr < rw_space()->top()) { | |
220 return oop(addr)->size(); | |
221 } | |
222 else { | |
223 assert(addr == rw_space()->top(), "non-block head arg to block_size"); | |
224 return rw_space()->end() - rw_space()->top(); | |
225 } | |
226 } | |
227 | |
228 static void generate_vtable_methods(void** vtbl_list, | |
229 void** vtable, | |
230 char** md_top, char* md_end, | |
231 char** mc_top, char* mc_end); | |
232 | |
233 void verify(bool allow_dirty); | |
234 | |
235 // Serialization | |
236 static void initialize_oops() KERNEL_RETURN; | |
237 static void serialize_oops(SerializeOopClosure* soc); | |
238 void serialize_bts(SerializeOopClosure* soc); | |
239 | |
240 // Initiate dumping of shared file. | |
241 static jint dump_shared(GrowableArray<oop>* class_promote_order, TRAPS); | |
242 | |
243 // JVM/TI RedefineClasses() support: | |
244 // Remap the shared readonly space to shared readwrite, private if | |
245 // sharing is enabled. Simply returns true if sharing is not enabled | |
246 // or if the remapping has already been done by a prior call. | |
247 static bool remap_shared_readonly_as_readwrite(); | |
248 }; |