45 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
45 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
46 |
46 |
47 int MetaspaceShared::_max_alignment = 0; |
47 int MetaspaceShared::_max_alignment = 0; |
48 |
48 |
49 ReservedSpace* MetaspaceShared::_shared_rs = NULL; |
49 ReservedSpace* MetaspaceShared::_shared_rs = NULL; |
|
50 |
|
51 MetaspaceSharedStats MetaspaceShared::_stats; |
50 |
52 |
51 bool MetaspaceShared::_link_classes_made_progress; |
53 bool MetaspaceShared::_link_classes_made_progress; |
52 bool MetaspaceShared::_check_classes_made_progress; |
54 bool MetaspaceShared::_check_classes_made_progress; |
53 bool MetaspaceShared::_has_error_classes; |
55 bool MetaspaceShared::_has_error_classes; |
54 bool MetaspaceShared::_archive_loading_failed = false; |
56 bool MetaspaceShared::_archive_loading_failed = false; |
257 |
259 |
258 // Here's poor man's enum inheritance |
260 // Here's poor man's enum inheritance |
259 #define SHAREDSPACE_OBJ_TYPES_DO(f) \ |
261 #define SHAREDSPACE_OBJ_TYPES_DO(f) \ |
260 METASPACE_OBJ_TYPES_DO(f) \ |
262 METASPACE_OBJ_TYPES_DO(f) \ |
261 f(SymbolHashentry) \ |
263 f(SymbolHashentry) \ |
262 f(SymbolBuckets) \ |
264 f(SymbolBucket) \ |
263 f(Other) |
265 f(Other) |
264 |
266 |
265 #define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type, |
267 #define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type, |
266 #define SHAREDSPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; |
268 #define SHAREDSPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name; |
267 |
269 |
313 void DumpAllocClosure::dump_stats(int ro_all, int rw_all, int md_all, int mc_all) { |
315 void DumpAllocClosure::dump_stats(int ro_all, int rw_all, int md_all, int mc_all) { |
314 rw_all += (md_all + mc_all); // md and mc are all mapped Read/Write |
316 rw_all += (md_all + mc_all); // md and mc are all mapped Read/Write |
315 int other_bytes = md_all + mc_all; |
317 int other_bytes = md_all + mc_all; |
316 |
318 |
317 // Calculate size of data that was not allocated by Metaspace::allocate() |
319 // Calculate size of data that was not allocated by Metaspace::allocate() |
318 int symbol_count = _counts[RO][MetaspaceObj::SymbolType]; |
320 MetaspaceSharedStats *stats = MetaspaceShared::stats(); |
319 int symhash_bytes = symbol_count * sizeof (HashtableEntry<Symbol*, mtSymbol>); |
321 |
320 int symbuck_count = SymbolTable::the_table()->table_size(); |
322 // symbols |
321 int symbuck_bytes = symbuck_count * sizeof(HashtableBucket<mtSymbol>); |
323 _counts[RW][SymbolHashentryType] = stats->symbol.hashentry_count; |
322 |
324 _bytes [RW][SymbolHashentryType] = stats->symbol.hashentry_bytes; |
323 _counts[RW][SymbolHashentryType] = symbol_count; |
325 other_bytes -= stats->symbol.hashentry_bytes; |
324 _bytes [RW][SymbolHashentryType] = symhash_bytes; |
326 |
325 other_bytes -= symhash_bytes; |
327 _counts[RW][SymbolBucketType] = stats->symbol.bucket_count; |
326 |
328 _bytes [RW][SymbolBucketType] = stats->symbol.bucket_bytes; |
327 _counts[RW][SymbolBucketsType] = symbuck_count; |
329 other_bytes -= stats->symbol.bucket_bytes; |
328 _bytes [RW][SymbolBucketsType] = symbuck_bytes; |
|
329 other_bytes -= symbuck_bytes; |
|
330 |
330 |
331 // TODO: count things like dictionary, vtable, etc |
331 // TODO: count things like dictionary, vtable, etc |
332 _bytes[RW][OtherType] = other_bytes; |
332 _bytes[RW][OtherType] = other_bytes; |
333 |
333 |
334 // prevent divide-by-zero |
334 // prevent divide-by-zero |
422 _class_promote_order = class_promote_order; |
422 _class_promote_order = class_promote_order; |
423 } |
423 } |
424 |
424 |
425 VMOp_Type type() const { return VMOp_PopulateDumpSharedSpace; } |
425 VMOp_Type type() const { return VMOp_PopulateDumpSharedSpace; } |
426 void doit(); // outline because gdb sucks |
426 void doit(); // outline because gdb sucks |
|
427 |
|
428 private: |
|
429 void handle_misc_data_space_failure(bool success) { |
|
430 if (!success) { |
|
431 report_out_of_shared_space(SharedMiscData); |
|
432 } |
|
433 } |
427 }; // class VM_PopulateDumpSharedSpace |
434 }; // class VM_PopulateDumpSharedSpace |
428 |
435 |
429 |
436 |
430 void VM_PopulateDumpSharedSpace::doit() { |
437 void VM_PopulateDumpSharedSpace::doit() { |
431 Thread* THREAD = VMThread::vm_thread(); |
438 Thread* THREAD = VMThread::vm_thread(); |
515 // Copy the the symbol table, and the system dictionary to the shared |
522 // Copy the the symbol table, and the system dictionary to the shared |
516 // space in usable form. Copy the hashtable |
523 // space in usable form. Copy the hashtable |
517 // buckets first [read-write], then copy the linked lists of entries |
524 // buckets first [read-write], then copy the linked lists of entries |
518 // [read-only]. |
525 // [read-only]. |
519 |
526 |
520 SymbolTable::reverse(md_top); |
|
521 NOT_PRODUCT(SymbolTable::verify()); |
527 NOT_PRODUCT(SymbolTable::verify()); |
522 SymbolTable::copy_buckets(&md_top, md_end); |
528 handle_misc_data_space_failure(SymbolTable::copy_compact_table(&md_top, md_end)); |
523 |
529 |
524 SystemDictionary::reverse(); |
530 SystemDictionary::reverse(); |
525 SystemDictionary::copy_buckets(&md_top, md_end); |
531 SystemDictionary::copy_buckets(&md_top, md_end); |
526 |
532 |
527 ClassLoader::verify(); |
533 ClassLoader::verify(); |
528 ClassLoader::copy_package_info_buckets(&md_top, md_end); |
534 ClassLoader::copy_package_info_buckets(&md_top, md_end); |
529 ClassLoader::verify(); |
535 ClassLoader::verify(); |
530 |
536 |
531 SymbolTable::copy_table(&md_top, md_end); |
|
532 SystemDictionary::copy_table(&md_top, md_end); |
537 SystemDictionary::copy_table(&md_top, md_end); |
533 ClassLoader::verify(); |
538 ClassLoader::verify(); |
534 ClassLoader::copy_package_info_table(&md_top, md_end); |
539 ClassLoader::copy_package_info_table(&md_top, md_end); |
535 ClassLoader::verify(); |
540 ClassLoader::verify(); |
536 |
541 |
998 |
1003 |
999 intptr_t vtable_size = *(intptr_t*)buffer; |
1004 intptr_t vtable_size = *(intptr_t*)buffer; |
1000 buffer += sizeof(intptr_t); |
1005 buffer += sizeof(intptr_t); |
1001 buffer += vtable_size; |
1006 buffer += vtable_size; |
1002 |
1007 |
1003 // Create the symbol table using the bucket array at this spot in the |
1008 // Create the shared symbol table using the bucket array at this spot in the |
1004 // misc data space. Since the symbol table is often modified, this |
1009 // misc data space. (Todo: move this to read-only space. Currently |
1005 // region (of mapped pages) will be copy-on-write. |
1010 // this is mapped copy-on-write but will never be written into). |
1006 |
1011 |
1007 int symbolTableLen = *(intptr_t*)buffer; |
1012 buffer = (char*)SymbolTable::init_shared_table(buffer); |
1008 buffer += sizeof(intptr_t); |
1013 SymbolTable::create_table(); |
1009 int number_of_entries = *(intptr_t*)buffer; |
|
1010 buffer += sizeof(intptr_t); |
|
1011 SymbolTable::create_table((HashtableBucket<mtSymbol>*)buffer, symbolTableLen, |
|
1012 number_of_entries); |
|
1013 buffer += symbolTableLen; |
|
1014 |
1014 |
1015 // Create the shared dictionary using the bucket array at this spot in |
1015 // Create the shared dictionary using the bucket array at this spot in |
1016 // the misc data space. Since the shared dictionary table is never |
1016 // the misc data space. Since the shared dictionary table is never |
1017 // modified, this region (of mapped pages) will be (effectively, if |
1017 // modified, this region (of mapped pages) will be (effectively, if |
1018 // not explicitly) read-only. |
1018 // not explicitly) read-only. |
1019 |
1019 |
1020 int sharedDictionaryLen = *(intptr_t*)buffer; |
1020 int sharedDictionaryLen = *(intptr_t*)buffer; |
1021 buffer += sizeof(intptr_t); |
1021 buffer += sizeof(intptr_t); |
1022 number_of_entries = *(intptr_t*)buffer; |
1022 int number_of_entries = *(intptr_t*)buffer; |
1023 buffer += sizeof(intptr_t); |
1023 buffer += sizeof(intptr_t); |
1024 SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer, |
1024 SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer, |
1025 sharedDictionaryLen, |
1025 sharedDictionaryLen, |
1026 number_of_entries); |
1026 number_of_entries); |
1027 buffer += sharedDictionaryLen; |
1027 buffer += sharedDictionaryLen; |
1039 number_of_entries); |
1039 number_of_entries); |
1040 buffer += pkgInfoLen; |
1040 buffer += pkgInfoLen; |
1041 ClassLoader::verify(); |
1041 ClassLoader::verify(); |
1042 |
1042 |
1043 // The following data in the shared misc data region are the linked |
1043 // The following data in the shared misc data region are the linked |
1044 // list elements (HashtableEntry objects) for the symbol table, string |
1044 // list elements (HashtableEntry objects) for the shared dictionary |
1045 // table, and shared dictionary. The heap objects referred to by the |
1045 // and package info table. |
1046 // symbol table, string table, and shared dictionary are permanent and |
1046 |
1047 // unmovable. Since new entries added to the string and symbol tables |
1047 int len = *(intptr_t*)buffer; // skip over shared dictionary entries |
1048 // are always added at the beginning of the linked lists, THESE LINKED |
|
1049 // LIST ELEMENTS ARE READ-ONLY. |
|
1050 |
|
1051 int len = *(intptr_t*)buffer; // skip over symbol table entries |
|
1052 buffer += sizeof(intptr_t); |
|
1053 buffer += len; |
|
1054 |
|
1055 len = *(intptr_t*)buffer; // skip over shared dictionary entries |
|
1056 buffer += sizeof(intptr_t); |
1048 buffer += sizeof(intptr_t); |
1057 buffer += len; |
1049 buffer += len; |
1058 |
1050 |
1059 len = *(intptr_t*)buffer; // skip over package info table entries |
1051 len = *(intptr_t*)buffer; // skip over package info table entries |
1060 buffer += sizeof(intptr_t); |
1052 buffer += sizeof(intptr_t); |