hotspot/src/share/vm/memory/metaspaceShared.cpp
changeset 37439 e8970711113b
parent 37248 11a660dbbb8e
child 37995 92aec042a43b
equal deleted inserted replaced
37438:873c4aea8d1b 37439:e8970711113b
    57 
    57 
    58 bool MetaspaceShared::_link_classes_made_progress;
    58 bool MetaspaceShared::_link_classes_made_progress;
    59 bool MetaspaceShared::_check_classes_made_progress;
    59 bool MetaspaceShared::_check_classes_made_progress;
    60 bool MetaspaceShared::_has_error_classes;
    60 bool MetaspaceShared::_has_error_classes;
    61 bool MetaspaceShared::_archive_loading_failed = false;
    61 bool MetaspaceShared::_archive_loading_failed = false;
       
    62 address MetaspaceShared::_cds_i2i_entry_code_buffers = NULL;
       
    63 size_t MetaspaceShared::_cds_i2i_entry_code_buffers_size = 0;
    62 SharedMiscRegion MetaspaceShared::_mc;
    64 SharedMiscRegion MetaspaceShared::_mc;
    63 SharedMiscRegion MetaspaceShared::_md;
    65 SharedMiscRegion MetaspaceShared::_md;
    64 
    66 
    65 void SharedMiscRegion::initialize(ReservedSpace rs, size_t committed_byte_size,  SharedSpaceType space_type) {
    67 void SharedMiscRegion::initialize(ReservedSpace rs, size_t committed_byte_size,  SharedSpaceType space_type) {
    66   _vs.initialize(rs, committed_byte_size);
    68   _vs.initialize(rs, committed_byte_size);
   127   soc->do_tag(--tag);
   129   soc->do_tag(--tag);
   128 
   130 
   129   soc->do_tag(666);
   131   soc->do_tag(666);
   130 }
   132 }
   131 
   133 
       
   134 address MetaspaceShared::cds_i2i_entry_code_buffers(size_t total_size) {
       
   135   if (DumpSharedSpaces) {
       
   136     if (_cds_i2i_entry_code_buffers == NULL) {
       
   137       _cds_i2i_entry_code_buffers = (address)misc_data_space_alloc(total_size);
       
   138       _cds_i2i_entry_code_buffers_size = total_size;
       
   139     }
       
   140   } else if (UseSharedSpaces) {
       
   141     assert(_cds_i2i_entry_code_buffers != NULL, "must already been initialized");
       
   142   } else {
       
   143     return NULL;
       
   144   }
       
   145 
       
   146   assert(_cds_i2i_entry_code_buffers_size == total_size, "must not change");
       
   147   return _cds_i2i_entry_code_buffers;
       
   148 }
   132 
   149 
   133 // CDS code for dumping shared archive.
   150 // CDS code for dumping shared archive.
   134 
   151 
   135 // Global object for holding classes that have been loaded.  Since this
   152 // Global object for holding classes that have been loaded.  Since this
   136 // is run at a safepoint just before exit, this is the entire set of classes.
   153 // is run at a safepoint just before exit, this is the entire set of classes.
   574 
   591 
   575   MetaspaceShared::generate_vtable_methods(vtbl_list, &vtable,
   592   MetaspaceShared::generate_vtable_methods(vtbl_list, &vtable,
   576                                      &md_top, md_end,
   593                                      &md_top, md_end,
   577                                      &mc_top, mc_end);
   594                                      &mc_top, mc_end);
   578 
   595 
       
   596   guarantee(md_top <= md_end, "Insufficient space for vtables.");
       
   597 
   579   // Reorder the system dictionary.  (Moving the symbols affects
   598   // Reorder the system dictionary.  (Moving the symbols affects
   580   // how the hash table indices are calculated.)
   599   // how the hash table indices are calculated.)
   581   // Not doing this either.
   600   // Not doing this either.
   582 
   601 
   583   SystemDictionary::reorder_dictionary();
   602   SystemDictionary::reorder_dictionary();
   666   // Create and write the archive file that maps the shared spaces.
   685   // Create and write the archive file that maps the shared spaces.
   667 
   686 
   668   FileMapInfo* mapinfo = new FileMapInfo();
   687   FileMapInfo* mapinfo = new FileMapInfo();
   669   mapinfo->populate_header(MetaspaceShared::max_alignment());
   688   mapinfo->populate_header(MetaspaceShared::max_alignment());
   670   mapinfo->set_misc_data_patching_start((char*)vtbl_list);
   689   mapinfo->set_misc_data_patching_start((char*)vtbl_list);
       
   690   mapinfo->set_cds_i2i_entry_code_buffers(MetaspaceShared::cds_i2i_entry_code_buffers());
       
   691   mapinfo->set_cds_i2i_entry_code_buffers_size(MetaspaceShared::cds_i2i_entry_code_buffers_size());
   671 
   692 
   672   for (int pass=1; pass<=2; pass++) {
   693   for (int pass=1; pass<=2; pass++) {
   673     if (pass == 1) {
   694     if (pass == 1) {
   674       // The first pass doesn't actually write the data to disk. All it
   695       // The first pass doesn't actually write the data to disk. All it
   675       // does is to update the fields in the mapinfo->_header.
   696       // does is to update the fields in the mapinfo->_header.
   684     mapinfo->write_space(MetaspaceShared::ro, _loader_data->ro_metaspace(), true);
   705     mapinfo->write_space(MetaspaceShared::ro, _loader_data->ro_metaspace(), true);
   685     mapinfo->write_space(MetaspaceShared::rw, _loader_data->rw_metaspace(), false);
   706     mapinfo->write_space(MetaspaceShared::rw, _loader_data->rw_metaspace(), false);
   686     mapinfo->write_region(MetaspaceShared::md, _md_vs.low(),
   707     mapinfo->write_region(MetaspaceShared::md, _md_vs.low(),
   687                           pointer_delta(md_top, _md_vs.low(), sizeof(char)),
   708                           pointer_delta(md_top, _md_vs.low(), sizeof(char)),
   688                           SharedMiscDataSize,
   709                           SharedMiscDataSize,
   689                           false, false);
   710                           false, true);
   690     mapinfo->write_region(MetaspaceShared::mc, _mc_vs.low(),
   711     mapinfo->write_region(MetaspaceShared::mc, _mc_vs.low(),
   691                           pointer_delta(mc_top, _mc_vs.low(), sizeof(char)),
   712                           pointer_delta(mc_top, _mc_vs.low(), sizeof(char)),
   692                           SharedMiscCodeSize,
   713                           SharedMiscCodeSize,
   693                           true, true);
   714                           true, true);
   694     mapinfo->write_string_regions(_string_regions);
   715     mapinfo->write_string_regions(_string_regions);
   978 // Return true if given address is in the mapped shared space.
   999 // Return true if given address is in the mapped shared space.
   979 bool MetaspaceShared::is_in_shared_space(const void* p) {
  1000 bool MetaspaceShared::is_in_shared_space(const void* p) {
   980   return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_space(p);
  1001   return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_space(p);
   981 }
  1002 }
   982 
  1003 
       
  1004 // Return true if given address is in the misc data region
       
  1005 bool MetaspaceShared::is_in_shared_region(const void* p, int idx) {
       
  1006   return UseSharedSpaces && FileMapInfo::current_info()->is_in_shared_region(p, idx);
       
  1007 }
       
  1008 
   983 bool MetaspaceShared::is_string_region(int idx) {
  1009 bool MetaspaceShared::is_string_region(int idx) {
   984   return (idx >= MetaspaceShared::first_string &&
  1010   return (idx >= MetaspaceShared::first_string &&
   985           idx < MetaspaceShared::first_string + MetaspaceShared::max_strings);
  1011           idx < MetaspaceShared::first_string + MetaspaceShared::max_strings);
   986 }
  1012 }
   987 
  1013 
  1051 // Read the miscellaneous data from the shared file, and
  1077 // Read the miscellaneous data from the shared file, and
  1052 // serialize it out to its various destinations.
  1078 // serialize it out to its various destinations.
  1053 
  1079 
  1054 void MetaspaceShared::initialize_shared_spaces() {
  1080 void MetaspaceShared::initialize_shared_spaces() {
  1055   FileMapInfo *mapinfo = FileMapInfo::current_info();
  1081   FileMapInfo *mapinfo = FileMapInfo::current_info();
       
  1082   _cds_i2i_entry_code_buffers = mapinfo->cds_i2i_entry_code_buffers();
       
  1083   _cds_i2i_entry_code_buffers_size = mapinfo->cds_i2i_entry_code_buffers_size();
  1056   char* buffer = mapinfo->misc_data_patching_start();
  1084   char* buffer = mapinfo->misc_data_patching_start();
  1057 
  1085 
  1058   // Skip over (reserve space for) a list of addresses of C++ vtables
  1086   // Skip over (reserve space for) a list of addresses of C++ vtables
  1059   // for Klass objects.  They get filled in later.
  1087   // for Klass objects.  They get filled in later.
  1060 
  1088