Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/metaspace.hpp @ 12056:740e263c80c6
8003424: Enable Class Data Sharing for CompressedOops
8016729: ObjectAlignmentInBytes=16 now forces the use of heap based compressed oops
8005933: The -Xshare:auto option is ignored for -server
Summary: Move klass metaspace above the heap and support CDS with compressed klass ptrs.
Reviewed-by: coleenp, kvn, mgerdin, tschatzl, stefank
author | hseigel |
---|---|
date | Thu, 15 Aug 2013 20:04:10 -0400 |
parents | f2110083203d |
children | 1a8fb39bdbc4 |
comparison
equal
deleted
inserted
replaced
12055:d96f52012aaa | 12056:740e263c80c6 |
---|---|
103 void initialize(Mutex* lock, MetaspaceType type); | 103 void initialize(Mutex* lock, MetaspaceType type); |
104 | 104 |
105 // Align up the word size to the allocation word size | 105 // Align up the word size to the allocation word size |
106 static size_t align_word_size_up(size_t); | 106 static size_t align_word_size_up(size_t); |
107 | 107 |
108 // Aligned size of the metaspace. | |
109 static size_t _class_metaspace_size; | |
110 | |
111 static size_t class_metaspace_size() { | |
112 return _class_metaspace_size; | |
113 } | |
114 static void set_class_metaspace_size(size_t metaspace_size) { | |
115 _class_metaspace_size = metaspace_size; | |
116 } | |
117 | |
108 static size_t _first_chunk_word_size; | 118 static size_t _first_chunk_word_size; |
109 static size_t _first_class_chunk_word_size; | 119 static size_t _first_class_chunk_word_size; |
110 | 120 |
111 SpaceManager* _vsm; | 121 SpaceManager* _vsm; |
112 SpaceManager* vsm() const { return _vsm; } | 122 SpaceManager* vsm() const { return _vsm; } |
128 static VirtualSpaceList* class_space_list() { return _class_space_list; } | 138 static VirtualSpaceList* class_space_list() { return _class_space_list; } |
129 | 139 |
130 // This is used by DumpSharedSpaces only, where only _vsm is used. So we will | 140 // This is used by DumpSharedSpaces only, where only _vsm is used. So we will |
131 // maintain a single list for now. | 141 // maintain a single list for now. |
132 void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); | 142 void record_allocation(void* ptr, MetaspaceObj::Type type, size_t word_size); |
143 | |
144 #ifdef _LP64 | |
145 static void set_narrow_klass_base_and_shift(address metaspace_base, address cds_base); | |
146 | |
147 // Returns true if can use CDS with metaspace allocated as specified address. | |
148 static bool can_use_cds_with_metaspace_addr(char* metaspace_base, address cds_base); | |
149 | |
150 static void allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base); | |
151 | |
152 static void initialize_class_space(ReservedSpace rs); | |
153 #endif | |
133 | 154 |
134 class AllocRecord : public CHeapObj<mtClass> { | 155 class AllocRecord : public CHeapObj<mtClass> { |
135 public: | 156 public: |
136 AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) | 157 AllocRecord(address ptr, MetaspaceObj::Type type, int byte_size) |
137 : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} | 158 : _next(NULL), _ptr(ptr), _type(type), _byte_size(byte_size) {} |
149 Metaspace(Mutex* lock, MetaspaceType type); | 170 Metaspace(Mutex* lock, MetaspaceType type); |
150 ~Metaspace(); | 171 ~Metaspace(); |
151 | 172 |
152 // Initialize globals for Metaspace | 173 // Initialize globals for Metaspace |
153 static void global_initialize(); | 174 static void global_initialize(); |
154 static void initialize_class_space(ReservedSpace rs); | |
155 | 175 |
156 static size_t first_chunk_word_size() { return _first_chunk_word_size; } | 176 static size_t first_chunk_word_size() { return _first_chunk_word_size; } |
157 static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } | 177 static size_t first_class_chunk_word_size() { return _first_class_chunk_word_size; } |
158 | 178 |
159 char* bottom() const; | 179 char* bottom() const; |
170 void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); | 190 void deallocate(MetaWord* ptr, size_t byte_size, bool is_class); |
171 | 191 |
172 MetaWord* expand_and_allocate(size_t size, | 192 MetaWord* expand_and_allocate(size_t size, |
173 MetadataType mdtype); | 193 MetadataType mdtype); |
174 | 194 |
175 static bool is_initialized() { return _class_space_list != NULL; } | |
176 | |
177 static bool contains(const void *ptr); | 195 static bool contains(const void *ptr); |
178 void dump(outputStream* const out) const; | 196 void dump(outputStream* const out) const; |
179 | 197 |
180 // Free empty virtualspaces | 198 // Free empty virtualspaces |
181 static void purge(); | 199 static void purge(); |
188 public: | 206 public: |
189 virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; | 207 virtual void doit(address ptr, MetaspaceObj::Type type, int byte_size) = 0; |
190 }; | 208 }; |
191 | 209 |
192 void iterate(AllocRecordClosure *closure); | 210 void iterate(AllocRecordClosure *closure); |
211 | |
212 // Return TRUE only if UseCompressedKlassPointers is True and DumpSharedSpaces is False. | |
213 static bool using_class_space() { | |
214 return NOT_LP64(false) LP64_ONLY(UseCompressedKlassPointers && !DumpSharedSpaces); | |
215 } | |
216 | |
193 }; | 217 }; |
194 | 218 |
195 class MetaspaceAux : AllStatic { | 219 class MetaspaceAux : AllStatic { |
196 static size_t free_chunks_total(Metaspace::MetadataType mdtype); | 220 static size_t free_chunks_total(Metaspace::MetadataType mdtype); |
197 static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); | 221 static size_t free_chunks_total_in_bytes(Metaspace::MetadataType mdtype); |
241 | 265 |
242 static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) { | 266 static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) { |
243 return _allocated_capacity_words[mdtype]; | 267 return _allocated_capacity_words[mdtype]; |
244 } | 268 } |
245 static size_t allocated_capacity_words() { | 269 static size_t allocated_capacity_words() { |
246 return _allocated_capacity_words[Metaspace::ClassType] + | 270 return _allocated_capacity_words[Metaspace::NonClassType] + |
247 _allocated_capacity_words[Metaspace::NonClassType]; | 271 (Metaspace::using_class_space() ? |
272 _allocated_capacity_words[Metaspace::ClassType] : 0); | |
248 } | 273 } |
249 static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) { | 274 static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) { |
250 return allocated_capacity_words(mdtype) * BytesPerWord; | 275 return allocated_capacity_words(mdtype) * BytesPerWord; |
251 } | 276 } |
252 static size_t allocated_capacity_bytes() { | 277 static size_t allocated_capacity_bytes() { |
255 | 280 |
256 static size_t allocated_used_words(Metaspace::MetadataType mdtype) { | 281 static size_t allocated_used_words(Metaspace::MetadataType mdtype) { |
257 return _allocated_used_words[mdtype]; | 282 return _allocated_used_words[mdtype]; |
258 } | 283 } |
259 static size_t allocated_used_words() { | 284 static size_t allocated_used_words() { |
260 return _allocated_used_words[Metaspace::ClassType] + | 285 return _allocated_used_words[Metaspace::NonClassType] + |
261 _allocated_used_words[Metaspace::NonClassType]; | 286 (Metaspace::using_class_space() ? |
287 _allocated_used_words[Metaspace::ClassType] : 0); | |
262 } | 288 } |
263 static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) { | 289 static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) { |
264 return allocated_used_words(mdtype) * BytesPerWord; | 290 return allocated_used_words(mdtype) * BytesPerWord; |
265 } | 291 } |
266 static size_t allocated_used_bytes() { | 292 static size_t allocated_used_bytes() { |
298 // Print change in used metadata. | 324 // Print change in used metadata. |
299 static void print_metaspace_change(size_t prev_metadata_used); | 325 static void print_metaspace_change(size_t prev_metadata_used); |
300 static void print_on(outputStream * out); | 326 static void print_on(outputStream * out); |
301 static void print_on(outputStream * out, Metaspace::MetadataType mdtype); | 327 static void print_on(outputStream * out, Metaspace::MetadataType mdtype); |
302 | 328 |
329 static void print_class_waste(outputStream* out); | |
303 static void print_waste(outputStream* out); | 330 static void print_waste(outputStream* out); |
304 static void dump(outputStream* out); | 331 static void dump(outputStream* out); |
305 static void verify_free_chunks(); | 332 static void verify_free_chunks(); |
306 // Checks that the values returned by allocated_capacity_bytes() and | 333 // Checks that the values returned by allocated_capacity_bytes() and |
307 // capacity_bytes_slow() are the same. | 334 // capacity_bytes_slow() are the same. |