src/share/vm/memory/filemap.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/memory

src/share/vm/memory/filemap.cpp

Print this page




 162 }
 163 
 164 size_t FileMapInfo::FileMapHeader::data_size() {
 165   return SharedClassUtil::file_map_header_size() - sizeof(FileMapInfo::FileMapHeaderBase);
 166 }
 167 
 168 void FileMapInfo::FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
 169   _magic = 0xf00baba2;
 170   _version = _current_version;
 171   _alignment = alignment;
 172   _obj_alignment = ObjectAlignmentInBytes;
 173   _compact_strings = CompactStrings;
 174   _narrow_oop_mode = Universe::narrow_oop_mode();
 175   _narrow_oop_shift = Universe::narrow_oop_shift();
 176   _max_heap_size = MaxHeapSize;
 177   _narrow_klass_base = Universe::narrow_klass_base();
 178   _narrow_klass_shift = Universe::narrow_klass_shift();
 179   _classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
 180   _classpath_entry_table = mapinfo->_classpath_entry_table;
 181   _classpath_entry_size = mapinfo->_classpath_entry_size;

 182 
 183   // The following fields are for sanity checks for whether this archive
 184   // will function correctly with this JVM and the bootclasspath it's
 185   // invoked with.
 186 
 187   // JVM version string ... changes on each build.
 188   get_header_version(_jvm_ident);
 189 }
 190 
 191 void FileMapInfo::allocate_classpath_entry_table() {
 192   int bytes = 0;
 193   int count = 0;
 194   char* strptr = NULL;
 195   char* strptr_max = NULL;
 196   Thread* THREAD = Thread::current();
 197 
 198   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 199   size_t entry_size = SharedClassUtil::shared_class_path_entry_size();
 200 
 201   for (int pass=0; pass<2; pass++) {


 894   } else {
 895     return _space[idx]._addr._base;
 896   }
 897 }
 898 
 899 int FileMapInfo::FileMapHeader::compute_crc() {
 900   char* header = data();
 901   // start computing from the field after _crc
 902   char* buf = (char*)&_crc + sizeof(int);
 903   size_t sz = data_size() - (buf - header);
 904   int crc = ClassLoader::crc32(0, buf, (jint)sz);
 905   return crc;
 906 }
 907 
 908 bool FileMapInfo::FileMapHeader::validate() {
 909   if (VerifySharedSpaces && compute_crc() != _crc) {
 910     fail_continue("Header checksum verification failed.");
 911     return false;
 912   }
 913 
 914   if (Arguments::get_patch_mod_prefix() != NULL) {
 915     FileMapInfo::fail_continue("The shared archive file cannot be used with --patch-module.");
 916     return false;
 917   }
 918 
 919   if (!Arguments::has_jimage()) {
 920     FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
 921     return false;
 922   }
 923 
 924   if (_version != current_version()) {
 925     FileMapInfo::fail_continue("The shared archive file is the wrong version.");
 926     return false;
 927   }
 928   if (_magic != (int)0xf00baba2) {
 929     FileMapInfo::fail_continue("The shared archive file has a bad magic number.");
 930     return false;
 931   }
 932   char header_version[JVM_IDENT_MAX];
 933   get_header_version(header_version);
 934   if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
 935     log_info(class, path)("expected: %s", header_version);
 936     log_info(class, path)("actual:   %s", _jvm_ident);
 937     FileMapInfo::fail_continue("The shared archive file was created by a different"
 938                   " version or build of HotSpot");
 939     return false;
 940   }
 941   if (_obj_alignment != ObjectAlignmentInBytes) {
 942     FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
 943                   " does not equal the current ObjectAlignmentInBytes of " INTX_FORMAT ".",
 944                   _obj_alignment, ObjectAlignmentInBytes);
 945     return false;
 946   }
 947   if (_compact_strings != CompactStrings) {
 948     FileMapInfo::fail_continue("The shared archive file's CompactStrings setting (%s)"
 949                   " does not equal the current CompactStrings setting (%s).",
 950                   _compact_strings ? "enabled" : "disabled",
 951                   CompactStrings   ? "enabled" : "disabled");
 952     return false;
 953   }
 954 

















 955   return true;
 956 }
 957 
 958 bool FileMapInfo::validate_header() {
 959   bool status = _header->validate();
 960 
 961   if (status) {
 962     if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
 963       if (!PrintSharedArchiveAndExit) {
 964         fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)");
 965         status = false;
 966       }
 967     }
 968   }
 969 
 970   if (_paths_misc_info != NULL) {
 971     FREE_C_HEAP_ARRAY(char, _paths_misc_info);
 972     _paths_misc_info = NULL;
 973   }
 974   return status;




 162 }
 163 
 164 size_t FileMapInfo::FileMapHeader::data_size() {
 165   return SharedClassUtil::file_map_header_size() - sizeof(FileMapInfo::FileMapHeaderBase);
 166 }
 167 
 168 void FileMapInfo::FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
 169   _magic = 0xf00baba2;
 170   _version = _current_version;
 171   _alignment = alignment;
 172   _obj_alignment = ObjectAlignmentInBytes;
 173   _compact_strings = CompactStrings;
 174   _narrow_oop_mode = Universe::narrow_oop_mode();
 175   _narrow_oop_shift = Universe::narrow_oop_shift();
 176   _max_heap_size = MaxHeapSize;
 177   _narrow_klass_base = Universe::narrow_klass_base();
 178   _narrow_klass_shift = Universe::narrow_klass_shift();
 179   _classpath_entry_table_size = mapinfo->_classpath_entry_table_size;
 180   _classpath_entry_table = mapinfo->_classpath_entry_table;
 181   _classpath_entry_size = mapinfo->_classpath_entry_size;
 182   _num_patch_mod_prefixes = ClassLoader::num_patch_mod_prefixes();
 183 
 184   // The following fields are for sanity checks for whether this archive
 185   // will function correctly with this JVM and the bootclasspath it's
 186   // invoked with.
 187 
 188   // JVM version string ... changes on each build.
 189   get_header_version(_jvm_ident);
 190 }
 191 
 192 void FileMapInfo::allocate_classpath_entry_table() {
 193   int bytes = 0;
 194   int count = 0;
 195   char* strptr = NULL;
 196   char* strptr_max = NULL;
 197   Thread* THREAD = Thread::current();
 198 
 199   ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
 200   size_t entry_size = SharedClassUtil::shared_class_path_entry_size();
 201 
 202   for (int pass=0; pass<2; pass++) {


 895   } else {
 896     return _space[idx]._addr._base;
 897   }
 898 }
 899 
 900 int FileMapInfo::FileMapHeader::compute_crc() {
 901   char* header = data();
 902   // start computing from the field after _crc
 903   char* buf = (char*)&_crc + sizeof(int);
 904   size_t sz = data_size() - (buf - header);
 905   int crc = ClassLoader::crc32(0, buf, (jint)sz);
 906   return crc;
 907 }
 908 
 909 bool FileMapInfo::FileMapHeader::validate() {
 910   if (VerifySharedSpaces && compute_crc() != _crc) {
 911     fail_continue("Header checksum verification failed.");
 912     return false;
 913   }
 914 





 915   if (!Arguments::has_jimage()) {
 916     FileMapInfo::fail_continue("The shared archive file cannot be used with an exploded module build.");
 917     return false;
 918   }
 919 
 920   if (_version != current_version()) {
 921     FileMapInfo::fail_continue("The shared archive file is the wrong version.");
 922     return false;
 923   }
 924   if (_magic != (int)0xf00baba2) {
 925     FileMapInfo::fail_continue("The shared archive file has a bad magic number.");
 926     return false;
 927   }
 928   char header_version[JVM_IDENT_MAX];
 929   get_header_version(header_version);
 930   if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) {
 931     log_info(class, path)("expected: %s", header_version);
 932     log_info(class, path)("actual:   %s", _jvm_ident);
 933     FileMapInfo::fail_continue("The shared archive file was created by a different"
 934                   " version or build of HotSpot");
 935     return false;
 936   }
 937   if (_obj_alignment != ObjectAlignmentInBytes) {
 938     FileMapInfo::fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
 939                   " does not equal the current ObjectAlignmentInBytes of " INTX_FORMAT ".",
 940                   _obj_alignment, ObjectAlignmentInBytes);
 941     return false;
 942   }
 943   if (_compact_strings != CompactStrings) {
 944     FileMapInfo::fail_continue("The shared archive file's CompactStrings setting (%s)"
 945                   " does not equal the current CompactStrings setting (%s).",
 946                   _compact_strings ? "enabled" : "disabled",
 947                   CompactStrings   ? "enabled" : "disabled");
 948     return false;
 949   }
 950 
 951   // Check if there is a mismatch in --patch-module entry counts between dump time and run time.
 952   // More checks will be performed on individual --patch-module entry in the
 953   // SharedPathsMiscInfo::check() function.
 954   GrowableArray<ModulePatchPath*>* patch_mod_args = Arguments::get_patch_mod_prefix();
 955   if (patch_mod_args != NULL) {
 956     if (_num_patch_mod_prefixes == 0) {
 957       FileMapInfo::fail_stop("--patch-module found in run time but none was specified in dump time");
 958     }
 959     if (patch_mod_args->length() != _num_patch_mod_prefixes) {
 960       FileMapInfo::fail_stop("mismatched --patch-module entry counts between dump time and run time");
 961     }
 962   } else {
 963     if (_num_patch_mod_prefixes > 0) {
 964       FileMapInfo::fail_stop("--patch-module specified in dump time but none was specified in run time");
 965     }
 966   }
 967 
 968   return true;
 969 }
 970 
 971 bool FileMapInfo::validate_header() {
 972   bool status = _header->validate();
 973 
 974   if (status) {
 975     if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) {
 976       if (!PrintSharedArchiveAndExit) {
 977         fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)");
 978         status = false;
 979       }
 980     }
 981   }
 982 
 983   if (_paths_misc_info != NULL) {
 984     FREE_C_HEAP_ARRAY(char, _paths_misc_info);
 985     _paths_misc_info = NULL;
 986   }
 987   return status;


src/share/vm/memory/filemap.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File