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