< prev index next >

src/hotspot/share/memory/metaspaceShared.cpp

Print this page
rev 50951 : 8202035: Archive the set of ModuleDescriptor and ModuleReference objects for observable system modules with unnamed initial module.
Summary: Support system module archiving with unnamed initial module at dump time.
Reviewed-by: erikj, coleenp, mchung, iklam, ccheung
Contributed-by: alan.bateman@oracle.com, jiangli.zhou@oracle.com


  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/classListParser.hpp"
  28 #include "classfile/classLoaderExt.hpp"
  29 #include "classfile/dictionary.hpp"
  30 #include "classfile/loaderConstraints.hpp"
  31 #include "classfile/placeholders.hpp"
  32 #include "classfile/symbolTable.hpp"
  33 #include "classfile/stringTable.hpp"
  34 #include "classfile/systemDictionary.hpp"
  35 #include "classfile/systemDictionaryShared.hpp"
  36 #include "code/codeCache.hpp"
  37 #include "interpreter/bytecodeStream.hpp"
  38 #include "interpreter/bytecodes.hpp"
  39 #include "logging/log.hpp"
  40 #include "logging/logMessage.hpp"
  41 #include "memory/filemap.hpp"

  42 #include "memory/metaspace.hpp"
  43 #include "memory/metaspaceClosure.hpp"
  44 #include "memory/metaspaceShared.hpp"
  45 #include "memory/resourceArea.hpp"
  46 #include "oops/compressedOops.inline.hpp"
  47 #include "oops/instanceClassLoaderKlass.hpp"
  48 #include "oops/instanceMirrorKlass.hpp"
  49 #include "oops/instanceRefKlass.hpp"
  50 #include "oops/objArrayKlass.hpp"
  51 #include "oops/objArrayOop.hpp"
  52 #include "oops/oop.inline.hpp"
  53 #include "oops/typeArrayKlass.hpp"
  54 #include "prims/jvmtiRedefineClasses.hpp"
  55 #include "runtime/handles.inline.hpp"
  56 #include "runtime/os.hpp"
  57 #include "runtime/safepointVerifiers.hpp"
  58 #include "runtime/signature.hpp"
  59 #include "runtime/timerTrace.hpp"
  60 #include "runtime/vmThread.hpp"
  61 #include "runtime/vm_operations.hpp"


 190       next->_end = MetaspaceShared::shared_rs()->end();
 191     }
 192   }
 193   bool contains(char* p) {
 194     return base() <= p && p < top();
 195   }
 196 };
 197 
 198 
 199 DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _md_region("md"), _od_region("od");
 200 size_t _total_string_region_size = 0, _total_open_archive_region_size = 0;
 201 
 202 char* MetaspaceShared::misc_code_space_alloc(size_t num_bytes) {
 203   return _mc_region.allocate(num_bytes);
 204 }
 205 
 206 char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) {
 207   return _ro_region.allocate(num_bytes);
 208 }
 209 




 210 void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
 211   assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled");
 212 
 213   // If using shared space, open the file that contains the shared space
 214   // and map in the memory before initializing the rest of metaspace (so
 215   // the addresses don't conflict)
 216   address cds_address = NULL;
 217   FileMapInfo* mapinfo = new FileMapInfo();
 218 
 219   // Open the shared archive file, read and validate the header. If
 220   // initialization fails, shared spaces [UseSharedSpaces] are
 221   // disabled and the file is closed.
 222   // Map in spaces now also
 223   if (mapinfo->initialize() && map_shared_spaces(mapinfo)) {
 224     size_t cds_total = core_spaces_size();
 225     cds_address = (address)mapinfo->header()->region_addr(0);
 226 #ifdef _LP64
 227     if (Metaspace::using_class_space()) {
 228       char* cds_end = (char*)(cds_address + cds_total);
 229       cds_end = (char *)align_up(cds_end, Metaspace::reserve_alignment());


 439   java_lang_invoke_MemberName::serialize(soc);
 440   java_lang_invoke_ResolvedMethodName::serialize(soc);
 441   java_lang_invoke_LambdaForm::serialize(soc);
 442   java_lang_invoke_MethodType::serialize(soc);
 443   java_lang_invoke_CallSite::serialize(soc);
 444   java_lang_invoke_MethodHandleNatives_CallSiteContext::serialize(soc);
 445   java_security_AccessControlContext::serialize(soc);
 446   java_lang_reflect_AccessibleObject::serialize(soc);
 447   java_lang_reflect_Method::serialize(soc);
 448   java_lang_reflect_Constructor::serialize(soc);
 449   java_lang_reflect_Field::serialize(soc);
 450   java_nio_Buffer::serialize(soc);
 451   reflect_ConstantPool::serialize(soc);
 452   reflect_UnsafeStaticFieldAccessorImpl::serialize(soc);
 453   java_lang_reflect_Parameter::serialize(soc);
 454   java_lang_Module::serialize(soc);
 455   java_lang_StackTraceElement::serialize(soc);
 456   java_lang_StackFrameInfo::serialize(soc);
 457   java_lang_LiveStackFrameInfo::serialize(soc);
 458   java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(soc);

 459 }
 460 
 461 address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) {
 462   if (DumpSharedSpaces) {
 463     if (_cds_i2i_entry_code_buffers == NULL) {
 464       _cds_i2i_entry_code_buffers = (address)misc_code_space_alloc(total_size);
 465       _cds_i2i_entry_code_buffers_size = total_size;
 466     }
 467   } else if (UseSharedSpaces) {
 468     assert(_cds_i2i_entry_code_buffers != NULL, "must already been initialized");
 469   } else {
 470     return NULL;
 471   }
 472 
 473   assert(_cds_i2i_entry_code_buffers_size == total_size, "must not change");
 474   return _cds_i2i_entry_code_buffers;
 475 }
 476 
 477 // CDS code for dumping shared archive.
 478 


1333   // Reorder the system dictionary. Moving the symbols affects
1334   // how the hash table indices are calculated.
1335   SystemDictionary::reorder_dictionary_for_sharing();
1336 
1337   tty->print("Removing java_mirror ... ");
1338   if (!MetaspaceShared::is_heap_object_archiving_allowed()) {
1339     clear_basic_type_mirrors();
1340   }
1341   remove_java_mirror_in_classes();
1342   tty->print_cr("done. ");
1343   NOT_PRODUCT(SystemDictionary::verify();)
1344 
1345   size_t buckets_bytes = SystemDictionary::count_bytes_for_buckets();
1346   char* buckets_top = _ro_region.allocate(buckets_bytes, sizeof(intptr_t));
1347   SystemDictionary::copy_buckets(buckets_top, _ro_region.top());
1348 
1349   size_t table_bytes = SystemDictionary::count_bytes_for_table();
1350   char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t));
1351   SystemDictionary::copy_table(table_top, _ro_region.top());
1352 





1353   // Write the other data to the output array.
1354   WriteClosure wc(&_ro_region);
1355   MetaspaceShared::serialize(&wc);
1356 
1357   char* newtop = _ro_region.top();
1358   ArchiveCompactor::alloc_stats()->record_other_type(int(newtop - oldtop), true);
1359   return buckets_top;
1360 }
1361 
1362 void VM_PopulateDumpSharedSpace::doit() {
1363   Thread* THREAD = VMThread::vm_thread();
1364 
1365   FileMapInfo::check_nonempty_dir_in_shared_path_table();
1366 
1367   NOT_PRODUCT(SystemDictionary::verify();)
1368   // The following guarantee is meant to ensure that no loader constraints
1369   // exist yet, since the constraints table is not shared.  This becomes
1370   // more important now that we don't re-initialize vtables/itables for
1371   // shared classes at runtime, where constraints were previously created.
1372   guarantee(SystemDictionary::constraints()->number_of_entries() == 0,


1844   // Archive interned string objects
1845   StringTable::write_to_archive();
1846 
1847   G1CollectedHeap::heap()->end_archive_alloc_range(closed_archive,
1848                                                    os::vm_allocation_granularity());
1849 }
1850 
1851 void MetaspaceShared::dump_open_archive_heap_objects(
1852                                     GrowableArray<MemRegion> * open_archive) {
1853   assert(UseG1GC, "Only support G1 GC");
1854   assert(UseCompressedOops && UseCompressedClassPointers,
1855          "Only support UseCompressedOops and UseCompressedClassPointers enabled");
1856 
1857   Thread* THREAD = Thread::current();
1858   G1CollectedHeap::heap()->begin_archive_alloc_range(true /* open */);
1859 
1860   java_lang_Class::archive_basic_type_mirrors(THREAD);
1861 
1862   MetaspaceShared::archive_klass_objects(THREAD);
1863 


1864   G1CollectedHeap::heap()->end_archive_alloc_range(open_archive,
1865                                                    os::vm_allocation_granularity());
1866 }
1867 
1868 unsigned MetaspaceShared::obj_hash(oop const& p) {
1869   assert(!p->mark()->has_bias_pattern(),
1870          "this object should never have been locked");  // so identity_hash won't safepoin
1871   unsigned hash = (unsigned)p->identity_hash();
1872   return hash;
1873 }
1874 
1875 MetaspaceShared::ArchivedObjectCache* MetaspaceShared::_archive_object_cache = NULL;
1876 oop MetaspaceShared::find_archived_heap_object(oop obj) {
1877   assert(DumpSharedSpaces, "dump-time only");
1878   ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1879   oop* p = cache->get(obj);
1880   if (p != NULL) {
1881     return *p;
1882   } else {
1883     return NULL;


1889 
1890   oop ao = find_archived_heap_object(obj);
1891   if (ao != NULL) {
1892     // already archived
1893     return ao;
1894   }
1895 
1896   int len = obj->size();
1897   if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {
1898     return NULL;
1899   }
1900 
1901   int hash = obj->identity_hash();
1902   oop archived_oop = (oop)G1CollectedHeap::heap()->archive_mem_allocate(len);
1903   if (archived_oop != NULL) {
1904     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
1905     relocate_klass_ptr(archived_oop);
1906     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1907     cache->put(obj, archived_oop);
1908   }
1909   log_debug(cds)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
1910                  p2i(obj), p2i(archived_oop));
1911   return archived_oop;
1912 }
1913 
1914 oop MetaspaceShared::materialize_archived_object(oop obj) {
1915   assert(obj != NULL, "sanity");
1916   return G1CollectedHeap::heap()->materialize_archived_object(obj);


1917 }
1918 
1919 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
1920   int i;
1921   for (i = 0; i < _global_klass_objects->length(); i++) {
1922     Klass* k = _global_klass_objects->at(i);
1923 
1924     // archive mirror object
1925     java_lang_Class::archive_mirror(k, CHECK);
1926 
1927     // archive the resolved_referenes array
1928     if (k->is_instance_klass()) {
1929       InstanceKlass* ik = InstanceKlass::cast(k);
1930       ik->constants()->archive_resolved_references(THREAD);
1931     }
1932   }
1933 }
1934 
1935 bool MetaspaceShared::is_archive_object(oop p) {
1936   return (p == NULL) ? false : G1ArchiveAllocator::is_archive_object(p);


2103   char* buffer = mapinfo->misc_data_patching_start();
2104   clone_cpp_vtables((intptr_t*)buffer);
2105 
2106   // The rest of the data is now stored in the RW region
2107   buffer = mapinfo->read_only_tables_start();
2108   int sharedDictionaryLen = *(intptr_t*)buffer;
2109   buffer += sizeof(intptr_t);
2110   int number_of_entries = *(intptr_t*)buffer;
2111   buffer += sizeof(intptr_t);
2112   SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer,
2113                                           sharedDictionaryLen,
2114                                           number_of_entries);
2115   buffer += sharedDictionaryLen;
2116 
2117   // The following data are the linked list elements
2118   // (HashtableEntry objects) for the shared dictionary table.
2119 
2120   int len = *(intptr_t*)buffer;     // skip over shared dictionary entries
2121   buffer += sizeof(intptr_t);
2122   buffer += len;



2123 
2124   // Verify various attributes of the archive, plus initialize the
2125   // shared string/symbol tables
2126   intptr_t* array = (intptr_t*)buffer;
2127   ReadClosure rc(&array);
2128   serialize(&rc);
2129 
2130   // Initialize the run-time symbol table.
2131   SymbolTable::create_table();
2132 
2133   // Close the mapinfo file
2134   mapinfo->close();
2135 
2136   if (PrintSharedArchiveAndExit) {
2137     if (PrintSharedDictionary) {
2138       tty->print_cr("\nShared classes:\n");
2139       SystemDictionary::print_shared(tty);
2140     }
2141     if (_archive_loading_failed) {
2142       tty->print_cr("archive is invalid");




  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "jvm.h"
  27 #include "classfile/classListParser.hpp"
  28 #include "classfile/classLoaderExt.hpp"
  29 #include "classfile/dictionary.hpp"
  30 #include "classfile/loaderConstraints.hpp"
  31 #include "classfile/placeholders.hpp"
  32 #include "classfile/symbolTable.hpp"
  33 #include "classfile/stringTable.hpp"
  34 #include "classfile/systemDictionary.hpp"
  35 #include "classfile/systemDictionaryShared.hpp"
  36 #include "code/codeCache.hpp"
  37 #include "interpreter/bytecodeStream.hpp"
  38 #include "interpreter/bytecodes.hpp"
  39 #include "logging/log.hpp"
  40 #include "logging/logMessage.hpp"
  41 #include "memory/filemap.hpp"
  42 #include "memory/heapShared.hpp"
  43 #include "memory/metaspace.hpp"
  44 #include "memory/metaspaceClosure.hpp"
  45 #include "memory/metaspaceShared.hpp"
  46 #include "memory/resourceArea.hpp"
  47 #include "oops/compressedOops.inline.hpp"
  48 #include "oops/instanceClassLoaderKlass.hpp"
  49 #include "oops/instanceMirrorKlass.hpp"
  50 #include "oops/instanceRefKlass.hpp"
  51 #include "oops/objArrayKlass.hpp"
  52 #include "oops/objArrayOop.hpp"
  53 #include "oops/oop.inline.hpp"
  54 #include "oops/typeArrayKlass.hpp"
  55 #include "prims/jvmtiRedefineClasses.hpp"
  56 #include "runtime/handles.inline.hpp"
  57 #include "runtime/os.hpp"
  58 #include "runtime/safepointVerifiers.hpp"
  59 #include "runtime/signature.hpp"
  60 #include "runtime/timerTrace.hpp"
  61 #include "runtime/vmThread.hpp"
  62 #include "runtime/vm_operations.hpp"


 191       next->_end = MetaspaceShared::shared_rs()->end();
 192     }
 193   }
 194   bool contains(char* p) {
 195     return base() <= p && p < top();
 196   }
 197 };
 198 
 199 
 200 DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _md_region("md"), _od_region("od");
 201 size_t _total_string_region_size = 0, _total_open_archive_region_size = 0;
 202 
 203 char* MetaspaceShared::misc_code_space_alloc(size_t num_bytes) {
 204   return _mc_region.allocate(num_bytes);
 205 }
 206 
 207 char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) {
 208   return _ro_region.allocate(num_bytes);
 209 }
 210 
 211 char* MetaspaceShared::read_only_space_top() {
 212   return _ro_region.top();
 213 }
 214 
 215 void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
 216   assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled");
 217 
 218   // If using shared space, open the file that contains the shared space
 219   // and map in the memory before initializing the rest of metaspace (so
 220   // the addresses don't conflict)
 221   address cds_address = NULL;
 222   FileMapInfo* mapinfo = new FileMapInfo();
 223 
 224   // Open the shared archive file, read and validate the header. If
 225   // initialization fails, shared spaces [UseSharedSpaces] are
 226   // disabled and the file is closed.
 227   // Map in spaces now also
 228   if (mapinfo->initialize() && map_shared_spaces(mapinfo)) {
 229     size_t cds_total = core_spaces_size();
 230     cds_address = (address)mapinfo->header()->region_addr(0);
 231 #ifdef _LP64
 232     if (Metaspace::using_class_space()) {
 233       char* cds_end = (char*)(cds_address + cds_total);
 234       cds_end = (char *)align_up(cds_end, Metaspace::reserve_alignment());


 444   java_lang_invoke_MemberName::serialize(soc);
 445   java_lang_invoke_ResolvedMethodName::serialize(soc);
 446   java_lang_invoke_LambdaForm::serialize(soc);
 447   java_lang_invoke_MethodType::serialize(soc);
 448   java_lang_invoke_CallSite::serialize(soc);
 449   java_lang_invoke_MethodHandleNatives_CallSiteContext::serialize(soc);
 450   java_security_AccessControlContext::serialize(soc);
 451   java_lang_reflect_AccessibleObject::serialize(soc);
 452   java_lang_reflect_Method::serialize(soc);
 453   java_lang_reflect_Constructor::serialize(soc);
 454   java_lang_reflect_Field::serialize(soc);
 455   java_nio_Buffer::serialize(soc);
 456   reflect_ConstantPool::serialize(soc);
 457   reflect_UnsafeStaticFieldAccessorImpl::serialize(soc);
 458   java_lang_reflect_Parameter::serialize(soc);
 459   java_lang_Module::serialize(soc);
 460   java_lang_StackTraceElement::serialize(soc);
 461   java_lang_StackFrameInfo::serialize(soc);
 462   java_lang_LiveStackFrameInfo::serialize(soc);
 463   java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(soc);
 464   jdk_internal_module_ArchivedModuleGraph::serialize(soc);
 465 }
 466 
 467 address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) {
 468   if (DumpSharedSpaces) {
 469     if (_cds_i2i_entry_code_buffers == NULL) {
 470       _cds_i2i_entry_code_buffers = (address)misc_code_space_alloc(total_size);
 471       _cds_i2i_entry_code_buffers_size = total_size;
 472     }
 473   } else if (UseSharedSpaces) {
 474     assert(_cds_i2i_entry_code_buffers != NULL, "must already been initialized");
 475   } else {
 476     return NULL;
 477   }
 478 
 479   assert(_cds_i2i_entry_code_buffers_size == total_size, "must not change");
 480   return _cds_i2i_entry_code_buffers;
 481 }
 482 
 483 // CDS code for dumping shared archive.
 484 


1339   // Reorder the system dictionary. Moving the symbols affects
1340   // how the hash table indices are calculated.
1341   SystemDictionary::reorder_dictionary_for_sharing();
1342 
1343   tty->print("Removing java_mirror ... ");
1344   if (!MetaspaceShared::is_heap_object_archiving_allowed()) {
1345     clear_basic_type_mirrors();
1346   }
1347   remove_java_mirror_in_classes();
1348   tty->print_cr("done. ");
1349   NOT_PRODUCT(SystemDictionary::verify();)
1350 
1351   size_t buckets_bytes = SystemDictionary::count_bytes_for_buckets();
1352   char* buckets_top = _ro_region.allocate(buckets_bytes, sizeof(intptr_t));
1353   SystemDictionary::copy_buckets(buckets_top, _ro_region.top());
1354 
1355   size_t table_bytes = SystemDictionary::count_bytes_for_table();
1356   char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t));
1357   SystemDictionary::copy_table(table_top, _ro_region.top());
1358 
1359   // Write the archived object sub-graph infos. For each klass with sub-graphs,
1360   // the info includes the static fields (sub-graph entry points) and Klasses
1361   // of objects included in the sub-graph.
1362   HeapShared::write_archived_subgraph_infos();
1363 
1364   // Write the other data to the output array.
1365   WriteClosure wc(&_ro_region);
1366   MetaspaceShared::serialize(&wc);
1367 
1368   char* newtop = _ro_region.top();
1369   ArchiveCompactor::alloc_stats()->record_other_type(int(newtop - oldtop), true);
1370   return buckets_top;
1371 }
1372 
1373 void VM_PopulateDumpSharedSpace::doit() {
1374   Thread* THREAD = VMThread::vm_thread();
1375 
1376   FileMapInfo::check_nonempty_dir_in_shared_path_table();
1377 
1378   NOT_PRODUCT(SystemDictionary::verify();)
1379   // The following guarantee is meant to ensure that no loader constraints
1380   // exist yet, since the constraints table is not shared.  This becomes
1381   // more important now that we don't re-initialize vtables/itables for
1382   // shared classes at runtime, where constraints were previously created.
1383   guarantee(SystemDictionary::constraints()->number_of_entries() == 0,


1855   // Archive interned string objects
1856   StringTable::write_to_archive();
1857 
1858   G1CollectedHeap::heap()->end_archive_alloc_range(closed_archive,
1859                                                    os::vm_allocation_granularity());
1860 }
1861 
1862 void MetaspaceShared::dump_open_archive_heap_objects(
1863                                     GrowableArray<MemRegion> * open_archive) {
1864   assert(UseG1GC, "Only support G1 GC");
1865   assert(UseCompressedOops && UseCompressedClassPointers,
1866          "Only support UseCompressedOops and UseCompressedClassPointers enabled");
1867 
1868   Thread* THREAD = Thread::current();
1869   G1CollectedHeap::heap()->begin_archive_alloc_range(true /* open */);
1870 
1871   java_lang_Class::archive_basic_type_mirrors(THREAD);
1872 
1873   MetaspaceShared::archive_klass_objects(THREAD);
1874 
1875   HeapShared::archive_module_graph_objects(THREAD);
1876 
1877   G1CollectedHeap::heap()->end_archive_alloc_range(open_archive,
1878                                                    os::vm_allocation_granularity());
1879 }
1880 
1881 unsigned MetaspaceShared::obj_hash(oop const& p) {
1882   assert(!p->mark()->has_bias_pattern(),
1883          "this object should never have been locked");  // so identity_hash won't safepoin
1884   unsigned hash = (unsigned)p->identity_hash();
1885   return hash;
1886 }
1887 
1888 MetaspaceShared::ArchivedObjectCache* MetaspaceShared::_archive_object_cache = NULL;
1889 oop MetaspaceShared::find_archived_heap_object(oop obj) {
1890   assert(DumpSharedSpaces, "dump-time only");
1891   ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1892   oop* p = cache->get(obj);
1893   if (p != NULL) {
1894     return *p;
1895   } else {
1896     return NULL;


1902 
1903   oop ao = find_archived_heap_object(obj);
1904   if (ao != NULL) {
1905     // already archived
1906     return ao;
1907   }
1908 
1909   int len = obj->size();
1910   if (G1CollectedHeap::heap()->is_archive_alloc_too_large(len)) {
1911     return NULL;
1912   }
1913 
1914   int hash = obj->identity_hash();
1915   oop archived_oop = (oop)G1CollectedHeap::heap()->archive_mem_allocate(len);
1916   if (archived_oop != NULL) {
1917     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
1918     relocate_klass_ptr(archived_oop);
1919     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
1920     cache->put(obj, archived_oop);
1921   }
1922   log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
1923                        p2i(obj), p2i(archived_oop));
1924   return archived_oop;
1925 }
1926 
1927 oop MetaspaceShared::materialize_archived_object(oop obj) {
1928   if (obj != NULL) {
1929     return G1CollectedHeap::heap()->materialize_archived_object(obj);
1930   }
1931   return NULL;
1932 }
1933 
1934 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
1935   int i;
1936   for (i = 0; i < _global_klass_objects->length(); i++) {
1937     Klass* k = _global_klass_objects->at(i);
1938 
1939     // archive mirror object
1940     java_lang_Class::archive_mirror(k, CHECK);
1941 
1942     // archive the resolved_referenes array
1943     if (k->is_instance_klass()) {
1944       InstanceKlass* ik = InstanceKlass::cast(k);
1945       ik->constants()->archive_resolved_references(THREAD);
1946     }
1947   }
1948 }
1949 
1950 bool MetaspaceShared::is_archive_object(oop p) {
1951   return (p == NULL) ? false : G1ArchiveAllocator::is_archive_object(p);


2118   char* buffer = mapinfo->misc_data_patching_start();
2119   clone_cpp_vtables((intptr_t*)buffer);
2120 
2121   // The rest of the data is now stored in the RW region
2122   buffer = mapinfo->read_only_tables_start();
2123   int sharedDictionaryLen = *(intptr_t*)buffer;
2124   buffer += sizeof(intptr_t);
2125   int number_of_entries = *(intptr_t*)buffer;
2126   buffer += sizeof(intptr_t);
2127   SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer,
2128                                           sharedDictionaryLen,
2129                                           number_of_entries);
2130   buffer += sharedDictionaryLen;
2131 
2132   // The following data are the linked list elements
2133   // (HashtableEntry objects) for the shared dictionary table.
2134 
2135   int len = *(intptr_t*)buffer;     // skip over shared dictionary entries
2136   buffer += sizeof(intptr_t);
2137   buffer += len;
2138 
2139   // The table of archived java heap object sub-graph infos
2140   buffer = HeapShared::read_archived_subgraph_infos(buffer);
2141 
2142   // Verify various attributes of the archive, plus initialize the
2143   // shared string/symbol tables
2144   intptr_t* array = (intptr_t*)buffer;
2145   ReadClosure rc(&array);
2146   serialize(&rc);
2147 
2148   // Initialize the run-time symbol table.
2149   SymbolTable::create_table();
2150 
2151   // Close the mapinfo file
2152   mapinfo->close();
2153 
2154   if (PrintSharedArchiveAndExit) {
2155     if (PrintSharedDictionary) {
2156       tty->print_cr("\nShared classes:\n");
2157       SystemDictionary::print_shared(tty);
2158     }
2159     if (_archive_loading_failed) {
2160       tty->print_cr("archive is invalid");


< prev index next >