< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page


 956   if (_heap_pointers_need_patching) {
 957     //   dumptime heap end  ------------v
 958     //   [      |archived heap regions| ]         runtime heap end ------v
 959     //                                       [   |archived heap regions| ]
 960     //                                  |<-----delta-------------------->|
 961     //
 962     // At dump time, the archived heap regions were near the top of the heap.
 963     // At run time, they may not be inside the heap, so we move them so
 964     // that they are now near the top of the runtime time. This can be done by
 965     // the simple math of adding the delta as shown above.
 966     address dumptime_heap_end = (address)_header->_heap_reserved.end();
 967     address runtime_heap_end = (address)heap_reserved.end();
 968     delta = runtime_heap_end - dumptime_heap_end;
 969   }
 970 
 971   log_info(cds)("CDS heap data relocation delta = " INTX_FORMAT " bytes", delta);
 972   HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift());
 973 
 974   CDSFileMapRegion* si = space_at(MetaspaceShared::first_string);
 975   address relocated_strings_bottom = start_address_with_archived_oop_encoding_mode(si);
 976   if (!is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes)) {
 977     // Align the bottom of the string regions at G1 region boundary. This will avoid
 978     // the situation where the highest open region and the lowest string region sharing
 979     // the same G1 region. Otherwise we will fail to map the open regions.
 980     size_t align = size_t(relocated_strings_bottom) % HeapRegion::GrainBytes;
 981     delta -= align;
 982     assert(is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes), "must be");
 983 
 984     log_info(cds)("CDS heap data need to be relocated lower by a further " SIZE_FORMAT
 985                   " bytes to be aligned with HeapRegion::GrainBytes", align);
 986 
 987     HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift());
 988     _heap_pointers_need_patching = true;

 989   }

 990 
 991   // First, map string regions as closed archive heap regions.
 992   // GC does not write into the regions.
 993   if (map_heap_data(&string_ranges,
 994                     MetaspaceShared::first_string,
 995                     MetaspaceShared::max_strings,
 996                     &num_string_ranges)) {
 997     StringTable::set_shared_string_mapped();
 998 
 999     // Now, map open_archive heap regions, GC can write into the regions.
1000     if (map_heap_data(&open_archive_heap_ranges,
1001                       MetaspaceShared::first_open_archive_heap_region,
1002                       MetaspaceShared::max_open_archive_heap_region,
1003                       &num_open_archive_heap_ranges,
1004                       true /* open */)) {
1005       MetaspaceShared::set_open_archive_heap_region_mapped();
1006     }
1007   }
1008 }
1009 




 956   if (_heap_pointers_need_patching) {
 957     //   dumptime heap end  ------------v
 958     //   [      |archived heap regions| ]         runtime heap end ------v
 959     //                                       [   |archived heap regions| ]
 960     //                                  |<-----delta-------------------->|
 961     //
 962     // At dump time, the archived heap regions were near the top of the heap.
 963     // At run time, they may not be inside the heap, so we move them so
 964     // that they are now near the top of the runtime time. This can be done by
 965     // the simple math of adding the delta as shown above.
 966     address dumptime_heap_end = (address)_header->_heap_reserved.end();
 967     address runtime_heap_end = (address)heap_reserved.end();
 968     delta = runtime_heap_end - dumptime_heap_end;
 969   }
 970 
 971   log_info(cds)("CDS heap data relocation delta = " INTX_FORMAT " bytes", delta);
 972   HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift());
 973 
 974   CDSFileMapRegion* si = space_at(MetaspaceShared::first_string);
 975   address relocated_strings_bottom = start_address_with_archived_oop_encoding_mode(si);
 976   if (!is_aligned(relocated_strings_bottom, HeapRegion::GrainBytes)) {
 977     // Align the bottom of the string regions at G1 region boundary. This will avoid
 978     // the situation where the highest open region and the lowest string region sharing
 979     // the same G1 region. Otherwise we will fail to map the open regions.
 980     size_t align = size_t(relocated_strings_bottom) % HeapRegion::GrainBytes;
 981     delta -= align;


 982     log_info(cds)("CDS heap data need to be relocated lower by a further " SIZE_FORMAT
 983                   " bytes to " INTX_FORMAT " to be aligned with HeapRegion::GrainBytes", align, delta);

 984     HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift());
 985     _heap_pointers_need_patching = true;
 986     relocated_strings_bottom = start_address_with_archived_oop_encoding_mode(si);
 987   }
 988   assert(is_aligned(relocated_strings_bottom, HeapRegion::GrainBytes), "must be");
 989 
 990   // First, map string regions as closed archive heap regions.
 991   // GC does not write into the regions.
 992   if (map_heap_data(&string_ranges,
 993                     MetaspaceShared::first_string,
 994                     MetaspaceShared::max_strings,
 995                     &num_string_ranges)) {
 996     StringTable::set_shared_string_mapped();
 997 
 998     // Now, map open_archive heap regions, GC can write into the regions.
 999     if (map_heap_data(&open_archive_heap_ranges,
1000                       MetaspaceShared::first_open_archive_heap_region,
1001                       MetaspaceShared::max_open_archive_heap_region,
1002                       &num_open_archive_heap_ranges,
1003                       true /* open */)) {
1004       MetaspaceShared::set_open_archive_heap_region_mapped();
1005     }
1006   }
1007 }
1008 


< prev index next >