Mercurial > hg > graal-compiler
annotate src/share/vm/memory/compactingPermGenGen.hpp @ 6038:8bafad97cd26
7158552: The instanceKlsss::_host_klass is only needed for anonymous class for JSR 292 support.
Summary: Change the _host_klass to be conditionally created embedded instanceKlass field.
Reviewed-by: jrose, coleenp, dholmes
author | jiangli |
---|---|
date | Wed, 02 May 2012 13:21:36 -0400 |
parents | b632e80fc9dc |
children |
rev | line source |
---|---|
0 | 1 /* |
6008 | 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 #ifndef SHARE_VM_MEMORY_COMPACTINGPERMGENGEN_HPP |
26 #define SHARE_VM_MEMORY_COMPACTINGPERMGENGEN_HPP | |
27 | |
28 #include "gc_implementation/shared/generationCounters.hpp" | |
29 #include "memory/space.hpp" | |
30 | |
0 | 31 // All heaps contains a "permanent generation," containing permanent |
32 // (reflective) objects. This is like a regular generation in some ways, | |
33 // but unlike one in others, and so is split apart. | |
34 | |
35 class PermanentGenerationSpec; | |
36 | |
37 // This is the "generation" view of a CompactingPermGen. | |
1051
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
409
diff
changeset
|
38 // NOTE: the shared spaces used for CDS are here handled in |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
409
diff
changeset
|
39 // a somewhat awkward and potentially buggy fashion, see CR 6801625. |
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
409
diff
changeset
|
40 // This infelicity should be fixed, see CR 6897789. |
0 | 41 class CompactingPermGenGen: public OneContigSpaceCardGeneration { |
42 friend class VMStructs; | |
43 // Abstractly, this is a subtype that gets access to protected fields. | |
44 friend class CompactingPermGen; | |
45 | |
46 private: | |
47 // Shared spaces | |
48 PermanentGenerationSpec* _spec; | |
49 size_t _shared_space_size; | |
50 VirtualSpace _ro_vs; | |
51 VirtualSpace _rw_vs; | |
52 VirtualSpace _md_vs; | |
53 VirtualSpace _mc_vs; | |
54 BlockOffsetSharedArray* _ro_bts; | |
55 BlockOffsetSharedArray* _rw_bts; | |
56 OffsetTableContigSpace* _ro_space; | |
57 OffsetTableContigSpace* _rw_space; | |
58 | |
1051
26f1542097f1
6801625: CDS: HeapDump tests crash with internal error in compactingPermGenGen.cpp
ysr
parents:
409
diff
changeset
|
59 // With shared spaces there is a dichotomy in the use of the |
0 | 60 // _virtual_space of the generation. There is a portion of the |
61 // _virtual_space that is used for the unshared part of the | |
62 // permanent generation and a portion that is reserved for the shared part. | |
63 // The _reserved field in the generation represents both the | |
64 // unshared and shared parts of the generation. The _reserved | |
65 // variable is initialized for only the unshared part but is | |
66 // later extended to include the shared part during initialization | |
67 // if shared spaces are being used. | |
68 // The reserved size for the _virtual_space for CompactingPermGenGen | |
69 // is the size of the space for the permanent generation including the | |
70 // the shared spaces. This can be seen by the use of MaxPermSize | |
71 // in the allocation of PermanentGenerationSpec. The space for the | |
72 // shared spaces is committed separately (???). | |
73 // In general at initialization only a part of the | |
74 // space for the unshared part of the permanent generation is | |
75 // committed and more is committed as the permanent generation is | |
76 // grown. In growing the permanent generation the capacity() and | |
77 // max_capacity() of the generation are used. For the permanent | |
78 // generation (implemented with a CompactingPermGenGen) the capacity() | |
79 // is taken from the capacity of the space (_the_space variable used for the | |
80 // unshared part of the generation) and the max_capacity() is based | |
81 // on the size of the _reserved variable (which includes the size of the | |
82 // shared spaces) minus the size of the shared spaces. | |
83 | |
84 // These values are redundant, but are called out separately to avoid | |
85 // going through heap/space/gen pointers for performance. | |
86 static HeapWord* unshared_bottom; | |
87 static HeapWord* unshared_end; | |
88 static HeapWord* shared_bottom; | |
89 static HeapWord* readonly_bottom; | |
90 static HeapWord* readonly_end; | |
91 static HeapWord* readwrite_bottom; | |
92 static HeapWord* readwrite_end; | |
93 static HeapWord* miscdata_bottom; | |
94 static HeapWord* miscdata_end; | |
95 static HeapWord* misccode_bottom; | |
96 static HeapWord* misccode_end; | |
97 static HeapWord* shared_end; | |
98 | |
99 // Performance Counters | |
100 GenerationCounters* _gen_counters; | |
101 CSpaceCounters* _space_counters; | |
102 | |
103 void initialize_performance_counters(); | |
104 | |
105 public: | |
106 | |
107 enum { | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2177
diff
changeset
|
108 vtbl_list_size = 17, // number of entries in the shared space vtable list. |
408 | 109 num_virtuals = 200 // number of virtual methods in Klass (or |
0 | 110 // subclass) objects, or greater. |
111 }; | |
112 | |
113 enum { | |
114 ro = 0, // read-only shared space in the heap | |
115 rw = 1, // read-write shared space in the heap | |
116 md = 2, // miscellaneous data for initializing tables, etc. | |
117 mc = 3, // miscellaneous code - vtable replacement. | |
118 n_regions = 4 | |
119 }; | |
120 | |
121 CompactingPermGenGen(ReservedSpace rs, ReservedSpace shared_rs, | |
122 size_t initial_byte_size, int level, GenRemSet* remset, | |
123 ContiguousSpace* space, | |
124 PermanentGenerationSpec* perm_spec); | |
125 | |
126 const char* name() const { | |
127 return "compacting perm gen"; | |
128 } | |
129 | |
130 const char* short_name() const { | |
131 return "Perm"; | |
132 } | |
133 | |
134 // Return the maximum capacity for the object space. This | |
135 // explicitly does not include the shared spaces. | |
136 size_t max_capacity() const; | |
137 | |
138 void update_counters(); | |
139 | |
140 void compute_new_size() { | |
141 assert(false, "Should not call this -- handled at PermGen level."); | |
142 } | |
143 | |
144 bool must_be_youngest() const { return false; } | |
145 bool must_be_oldest() const { return false; } | |
146 | |
147 OffsetTableContigSpace* ro_space() const { return _ro_space; } | |
148 OffsetTableContigSpace* rw_space() const { return _rw_space; } | |
149 VirtualSpace* md_space() { return &_md_vs; } | |
150 VirtualSpace* mc_space() { return &_mc_vs; } | |
151 ContiguousSpace* unshared_space() const { return _the_space; } | |
152 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
153 static bool inline is_shared(const void* p) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
154 return p >= shared_bottom && p < shared_end; |
0 | 155 } |
156 // RedefineClasses note: this tester is used to check residence of | |
157 // the specified oop in the shared readonly space and not whether | |
158 // the oop is readonly. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
159 static bool inline is_shared_readonly(const void* p) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
160 return p >= readonly_bottom && p < readonly_end; |
0 | 161 } |
162 // RedefineClasses note: this tester is used to check residence of | |
163 // the specified oop in the shared readwrite space and not whether | |
164 // the oop is readwrite. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
165 static bool inline is_shared_readwrite(const void* p) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
166 return p >= readwrite_bottom && p < readwrite_end; |
0 | 167 } |
168 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
169 // Checks if the pointer is either in unshared space or in shared space |
0 | 170 inline bool is_in(const void* p) const { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
171 return OneContigSpaceCardGeneration::is_in(p) || is_shared(p); |
0 | 172 } |
173 | |
174 inline PermanentGenerationSpec* spec() const { return _spec; } | |
175 inline void set_spec(PermanentGenerationSpec* spec) { _spec = spec; } | |
176 | |
177 void pre_adjust_pointers(); | |
178 void adjust_pointers(); | |
179 void space_iterate(SpaceClosure* blk, bool usedOnly = false); | |
180 void print_on(outputStream* st) const; | |
181 void younger_refs_iterate(OopsInGenClosure* blk); | |
182 void compact(); | |
183 void post_compact(); | |
184 size_t contiguous_available() const; | |
185 | |
186 void clear_remembered_set(); | |
187 void invalidate_remembered_set(); | |
188 | |
189 inline bool block_is_obj(const HeapWord* addr) const { | |
190 if (addr < the_space()->top()) return true; | |
191 else if (addr < the_space()->end()) return false; | |
192 else if (addr < ro_space()->top()) return true; | |
193 else if (addr < ro_space()->end()) return false; | |
194 else if (addr < rw_space()->top()) return true; | |
195 else return false; | |
196 } | |
197 | |
198 | |
199 inline size_t block_size(const HeapWord* addr) const { | |
200 if (addr < the_space()->top()) { | |
201 return oop(addr)->size(); | |
202 } | |
203 else if (addr < the_space()->end()) { | |
204 assert(addr == the_space()->top(), "non-block head arg to block_size"); | |
205 return the_space()->end() - the_space()->top(); | |
206 } | |
207 | |
208 else if (addr < ro_space()->top()) { | |
209 return oop(addr)->size(); | |
210 } | |
211 else if (addr < ro_space()->end()) { | |
212 assert(addr == ro_space()->top(), "non-block head arg to block_size"); | |
213 return ro_space()->end() - ro_space()->top(); | |
214 } | |
215 | |
216 else if (addr < rw_space()->top()) { | |
217 return oop(addr)->size(); | |
218 } | |
219 else { | |
220 assert(addr == rw_space()->top(), "non-block head arg to block_size"); | |
221 return rw_space()->end() - rw_space()->top(); | |
222 } | |
223 } | |
224 | |
225 static void generate_vtable_methods(void** vtbl_list, | |
226 void** vtable, | |
227 char** md_top, char* md_end, | |
228 char** mc_top, char* mc_end); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
229 static void* find_matching_vtbl_ptr(void** vtbl_list, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
230 void* new_vtable_start, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
231 void* obj); |
0 | 232 |
6008 | 233 void verify(); |
0 | 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 }; | |
1972 | 249 |
250 #endif // SHARE_VM_MEMORY_COMPACTINGPERMGENGEN_HPP |