< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page




 200 void FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
 201   if (DynamicDumpSharedSpaces) {
 202     _magic = CDS_DYNAMIC_ARCHIVE_MAGIC;
 203   } else {
 204     _magic = CDS_ARCHIVE_MAGIC;
 205   }
 206   _version = CURRENT_CDS_ARCHIVE_VERSION;
 207   _alignment = alignment;
 208   _obj_alignment = ObjectAlignmentInBytes;
 209   _compact_strings = CompactStrings;
 210   if (HeapShared::is_heap_object_archiving_allowed()) {
 211     _narrow_oop_mode = CompressedOops::mode();
 212     _narrow_oop_base = CompressedOops::base();
 213     _narrow_oop_shift = CompressedOops::shift();
 214     _heap_end = CompressedOops::end();
 215   }
 216   _compressed_oops = UseCompressedOops;
 217   _compressed_class_ptrs = UseCompressedClassPointers;
 218   _max_heap_size = MaxHeapSize;
 219   _narrow_klass_shift = CompressedKlassPointers::shift();

 220 
 221   // The following fields are for sanity checks for whether this archive
 222   // will function correctly with this JVM and the bootclasspath it's
 223   // invoked with.
 224 
 225   // JVM version string ... changes on each build.
 226   get_header_version(_jvm_ident);
 227 
 228   _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
 229   _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
 230   _num_module_paths = ClassLoader::num_module_path_entries();
 231   _max_used_path_index = ClassLoaderExt::max_used_path_index();
 232 
 233   _verify_local = BytecodeVerificationLocal;
 234   _verify_remote = BytecodeVerificationRemote;
 235   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 236   _requested_base_address = (char*)SharedBaseAddress;
 237   _mapped_base_address = (char*)SharedBaseAddress;
 238   _allow_archiving_with_java_agent = AllowArchivingWithJavaAgent;
 239   // the following 2 fields will be set in write_header for dynamic archive header


2123   // while AllowArchivingWithJavaAgent is set during the current run.
2124   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2125     FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2126                                "from the setting in the shared archive.");
2127     return false;
2128   }
2129 
2130   if (_allow_archiving_with_java_agent) {
2131     warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2132             "for testing purposes only and should not be used in a production environment");
2133   }
2134 
2135   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2136                           compressed_oops(), compressed_class_pointers());
2137   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2138     FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2139                                "different from runtime, CDS will be disabled.");
2140     return false;
2141   }
2142 





2143   return true;
2144 }
2145 
2146 bool FileMapInfo::validate_header() {
2147   return header()->validate();
2148 }
2149 
2150 // Check if a given address is within one of the shared regions
2151 bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
2152   assert(idx == MetaspaceShared::ro ||
2153          idx == MetaspaceShared::rw ||
2154          idx == MetaspaceShared::mc, "invalid region index");
2155   char* base = region_addr(idx);
2156   if (p >= base && p < base + space_at(idx)->used()) {
2157     return true;
2158   }
2159   return false;
2160 }
2161 
2162 // Unmap mapped regions of shared space.




 200 void FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
 201   if (DynamicDumpSharedSpaces) {
 202     _magic = CDS_DYNAMIC_ARCHIVE_MAGIC;
 203   } else {
 204     _magic = CDS_ARCHIVE_MAGIC;
 205   }
 206   _version = CURRENT_CDS_ARCHIVE_VERSION;
 207   _alignment = alignment;
 208   _obj_alignment = ObjectAlignmentInBytes;
 209   _compact_strings = CompactStrings;
 210   if (HeapShared::is_heap_object_archiving_allowed()) {
 211     _narrow_oop_mode = CompressedOops::mode();
 212     _narrow_oop_base = CompressedOops::base();
 213     _narrow_oop_shift = CompressedOops::shift();
 214     _heap_end = CompressedOops::end();
 215   }
 216   _compressed_oops = UseCompressedOops;
 217   _compressed_class_ptrs = UseCompressedClassPointers;
 218   _max_heap_size = MaxHeapSize;
 219   _narrow_klass_shift = CompressedKlassPointers::shift();
 220   _use_optimized_module_handling = MetaspaceShared::use_optimized_module_handling();
 221 
 222   // The following fields are for sanity checks for whether this archive
 223   // will function correctly with this JVM and the bootclasspath it's
 224   // invoked with.
 225 
 226   // JVM version string ... changes on each build.
 227   get_header_version(_jvm_ident);
 228 
 229   _app_class_paths_start_index = ClassLoaderExt::app_class_paths_start_index();
 230   _app_module_paths_start_index = ClassLoaderExt::app_module_paths_start_index();
 231   _num_module_paths = ClassLoader::num_module_path_entries();
 232   _max_used_path_index = ClassLoaderExt::max_used_path_index();
 233 
 234   _verify_local = BytecodeVerificationLocal;
 235   _verify_remote = BytecodeVerificationRemote;
 236   _has_platform_or_app_classes = ClassLoaderExt::has_platform_or_app_classes();
 237   _requested_base_address = (char*)SharedBaseAddress;
 238   _mapped_base_address = (char*)SharedBaseAddress;
 239   _allow_archiving_with_java_agent = AllowArchivingWithJavaAgent;
 240   // the following 2 fields will be set in write_header for dynamic archive header


2124   // while AllowArchivingWithJavaAgent is set during the current run.
2125   if (_allow_archiving_with_java_agent && !AllowArchivingWithJavaAgent) {
2126     FileMapInfo::fail_continue("The setting of the AllowArchivingWithJavaAgent is different "
2127                                "from the setting in the shared archive.");
2128     return false;
2129   }
2130 
2131   if (_allow_archiving_with_java_agent) {
2132     warning("This archive was created with AllowArchivingWithJavaAgent. It should be used "
2133             "for testing purposes only and should not be used in a production environment");
2134   }
2135 
2136   log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
2137                           compressed_oops(), compressed_class_pointers());
2138   if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
2139     FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
2140                                "different from runtime, CDS will be disabled.");
2141     return false;
2142   }
2143 
2144   if (!_use_optimized_module_handling) {
2145     MetaspaceShared::disable_optimized_module_handling();
2146     log_info(cds)("use_optimized_module_handling disabled: archive was created without optimized module handling");
2147   }
2148  
2149   return true;
2150 }
2151 
2152 bool FileMapInfo::validate_header() {
2153   return header()->validate();
2154 }
2155 
2156 // Check if a given address is within one of the shared regions
2157 bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
2158   assert(idx == MetaspaceShared::ro ||
2159          idx == MetaspaceShared::rw ||
2160          idx == MetaspaceShared::mc, "invalid region index");
2161   char* base = region_addr(idx);
2162   if (p >= base && p < base + space_at(idx)->used()) {
2163     return true;
2164   }
2165   return false;
2166 }
2167 
2168 // Unmap mapped regions of shared space.


< prev index next >