src/hotspot/share/memory/metaspaceShared.cpp
changeset 50951 b96466cdfc45
parent 50819 cf09f0b56efd
child 51371 3ab8b84e93cd
equal deleted inserted replaced
50950:fa2f93f99dbc 50951:b96466cdfc45
    37 #include "interpreter/bytecodeStream.hpp"
    37 #include "interpreter/bytecodeStream.hpp"
    38 #include "interpreter/bytecodes.hpp"
    38 #include "interpreter/bytecodes.hpp"
    39 #include "logging/log.hpp"
    39 #include "logging/log.hpp"
    40 #include "logging/logMessage.hpp"
    40 #include "logging/logMessage.hpp"
    41 #include "memory/filemap.hpp"
    41 #include "memory/filemap.hpp"
       
    42 #include "memory/heapShared.hpp"
    42 #include "memory/metaspace.hpp"
    43 #include "memory/metaspace.hpp"
    43 #include "memory/metaspaceClosure.hpp"
    44 #include "memory/metaspaceClosure.hpp"
    44 #include "memory/metaspaceShared.hpp"
    45 #include "memory/metaspaceShared.hpp"
    45 #include "memory/resourceArea.hpp"
    46 #include "memory/resourceArea.hpp"
    46 #include "oops/compressedOops.inline.hpp"
    47 #include "oops/compressedOops.inline.hpp"
   203   return _mc_region.allocate(num_bytes);
   204   return _mc_region.allocate(num_bytes);
   204 }
   205 }
   205 
   206 
   206 char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) {
   207 char* MetaspaceShared::read_only_space_alloc(size_t num_bytes) {
   207   return _ro_region.allocate(num_bytes);
   208   return _ro_region.allocate(num_bytes);
       
   209 }
       
   210 
       
   211 char* MetaspaceShared::read_only_space_top() {
       
   212   return _ro_region.top();
   208 }
   213 }
   209 
   214 
   210 void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
   215 void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
   211   assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled");
   216   assert(UseSharedSpaces, "Must be called when UseSharedSpaces is enabled");
   212 
   217 
   454   java_lang_Module::serialize(soc);
   459   java_lang_Module::serialize(soc);
   455   java_lang_StackTraceElement::serialize(soc);
   460   java_lang_StackTraceElement::serialize(soc);
   456   java_lang_StackFrameInfo::serialize(soc);
   461   java_lang_StackFrameInfo::serialize(soc);
   457   java_lang_LiveStackFrameInfo::serialize(soc);
   462   java_lang_LiveStackFrameInfo::serialize(soc);
   458   java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(soc);
   463   java_util_concurrent_locks_AbstractOwnableSynchronizer::serialize(soc);
       
   464   jdk_internal_module_ArchivedModuleGraph::serialize(soc);
   459 }
   465 }
   460 
   466 
   461 address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) {
   467 address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) {
   462   if (DumpSharedSpaces) {
   468   if (DumpSharedSpaces) {
   463     if (_cds_i2i_entry_code_buffers == NULL) {
   469     if (_cds_i2i_entry_code_buffers == NULL) {
  1347   SystemDictionary::copy_buckets(buckets_top, _ro_region.top());
  1353   SystemDictionary::copy_buckets(buckets_top, _ro_region.top());
  1348 
  1354 
  1349   size_t table_bytes = SystemDictionary::count_bytes_for_table();
  1355   size_t table_bytes = SystemDictionary::count_bytes_for_table();
  1350   char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t));
  1356   char* table_top = _ro_region.allocate(table_bytes, sizeof(intptr_t));
  1351   SystemDictionary::copy_table(table_top, _ro_region.top());
  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();
  1352 
  1363 
  1353   // Write the other data to the output array.
  1364   // Write the other data to the output array.
  1354   WriteClosure wc(&_ro_region);
  1365   WriteClosure wc(&_ro_region);
  1355   MetaspaceShared::serialize(&wc);
  1366   MetaspaceShared::serialize(&wc);
  1356 
  1367 
  1859 
  1870 
  1860   java_lang_Class::archive_basic_type_mirrors(THREAD);
  1871   java_lang_Class::archive_basic_type_mirrors(THREAD);
  1861 
  1872 
  1862   MetaspaceShared::archive_klass_objects(THREAD);
  1873   MetaspaceShared::archive_klass_objects(THREAD);
  1863 
  1874 
       
  1875   HeapShared::archive_module_graph_objects(THREAD);
       
  1876 
  1864   G1CollectedHeap::heap()->end_archive_alloc_range(open_archive,
  1877   G1CollectedHeap::heap()->end_archive_alloc_range(open_archive,
  1865                                                    os::vm_allocation_granularity());
  1878                                                    os::vm_allocation_granularity());
  1866 }
  1879 }
  1867 
  1880 
  1868 unsigned MetaspaceShared::obj_hash(oop const& p) {
  1881 unsigned MetaspaceShared::obj_hash(oop const& p) {
  1904     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
  1917     Copy::aligned_disjoint_words((HeapWord*)obj, (HeapWord*)archived_oop, len);
  1905     relocate_klass_ptr(archived_oop);
  1918     relocate_klass_ptr(archived_oop);
  1906     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
  1919     ArchivedObjectCache* cache = MetaspaceShared::archive_object_cache();
  1907     cache->put(obj, archived_oop);
  1920     cache->put(obj, archived_oop);
  1908   }
  1921   }
  1909   log_debug(cds)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
  1922   log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT,
  1910                  p2i(obj), p2i(archived_oop));
  1923                        p2i(obj), p2i(archived_oop));
  1911   return archived_oop;
  1924   return archived_oop;
  1912 }
  1925 }
  1913 
  1926 
  1914 oop MetaspaceShared::materialize_archived_object(oop obj) {
  1927 oop MetaspaceShared::materialize_archived_object(oop obj) {
  1915   assert(obj != NULL, "sanity");
  1928   if (obj != NULL) {
  1916   return G1CollectedHeap::heap()->materialize_archived_object(obj);
  1929     return G1CollectedHeap::heap()->materialize_archived_object(obj);
       
  1930   }
       
  1931   return NULL;
  1917 }
  1932 }
  1918 
  1933 
  1919 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
  1934 void MetaspaceShared::archive_klass_objects(Thread* THREAD) {
  1920   int i;
  1935   int i;
  1921   for (i = 0; i < _global_klass_objects->length(); i++) {
  1936   for (i = 0; i < _global_klass_objects->length(); i++) {
  2119 
  2134 
  2120   int len = *(intptr_t*)buffer;     // skip over shared dictionary entries
  2135   int len = *(intptr_t*)buffer;     // skip over shared dictionary entries
  2121   buffer += sizeof(intptr_t);
  2136   buffer += sizeof(intptr_t);
  2122   buffer += len;
  2137   buffer += len;
  2123 
  2138 
       
  2139   // The table of archived java heap object sub-graph infos
       
  2140   buffer = HeapShared::read_archived_subgraph_infos(buffer);
       
  2141 
  2124   // Verify various attributes of the archive, plus initialize the
  2142   // Verify various attributes of the archive, plus initialize the
  2125   // shared string/symbol tables
  2143   // shared string/symbol tables
  2126   intptr_t* array = (intptr_t*)buffer;
  2144   intptr_t* array = (intptr_t*)buffer;
  2127   ReadClosure rc(&array);
  2145   ReadClosure rc(&array);
  2128   serialize(&rc);
  2146   serialize(&rc);