< prev index next >

src/hotspot/share/cds/metaspaceShared.cpp

Print this page

1141       }
1142     } else if (static_result == MAP_ARCHIVE_OTHER_FAILURE) {
1143       result = MAP_ARCHIVE_OTHER_FAILURE;
1144     } else {
1145       result = MAP_ARCHIVE_MMAP_FAILURE;
1146     }
1147   }
1148 
1149   if (result == MAP_ARCHIVE_SUCCESS) {
1150     SharedBaseAddress = (size_t)mapped_base_address;
1151 #ifdef _LP64
1152         if (Metaspace::using_class_space()) {
1153           // Set up ccs in metaspace.
1154           Metaspace::initialize_class_space(class_space_rs);
1155 
1156           // Set up compressed Klass pointer encoding: the encoding range must
1157           //  cover both archive and class space.
1158           address cds_base = (address)static_mapinfo->mapped_base();
1159           address ccs_end = (address)class_space_rs.end();
1160           assert(ccs_end > cds_base, "Sanity check");
1161 #if INCLUDE_CDS_JAVA_HEAP
1162           // We archived objects with pre-computed narrow Klass id. Set up encoding such that these Ids stay valid.
1163           address precomputed_narrow_klass_base = cds_base;
1164           const int precomputed_narrow_klass_shift = ArchiveHeapWriter::precomputed_narrow_klass_shift;
1165           CompressedKlassPointers::initialize_for_given_encoding(
1166             cds_base, ccs_end - cds_base, // Klass range
1167             precomputed_narrow_klass_base, precomputed_narrow_klass_shift // precomputed encoding, see ArchiveHeapWriter
1168             );
1169 #else
1170           CompressedKlassPointers::initialize (
1171             cds_base, ccs_end - cds_base // Klass range

1172             );
1173 #endif // INCLUDE_CDS_JAVA_HEAP





1174           // map_or_load_heap_region() compares the current narrow oop and klass encodings
1175           // with the archived ones, so it must be done after all encodings are determined.
1176           static_mapinfo->map_or_load_heap_region();
1177         }
1178 #endif // _LP64
1179     log_info(cds)("initial optimized module handling: %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
1180     log_info(cds)("initial full module graph: %s", CDSConfig::is_loading_full_module_graph() ? "enabled" : "disabled");
1181   } else {
1182     unmap_archive(static_mapinfo);
1183     unmap_archive(dynamic_mapinfo);
1184     release_reserved_spaces(total_space_rs, archive_space_rs, class_space_rs);
1185   }
1186 
1187   return result;
1188 }
1189 
1190 
1191 // This will reserve two address spaces suitable to house Klass structures, one
1192 //  for the cds archives (static archive and optionally dynamic archive) and
1193 //  optionally one move for ccs.

1141       }
1142     } else if (static_result == MAP_ARCHIVE_OTHER_FAILURE) {
1143       result = MAP_ARCHIVE_OTHER_FAILURE;
1144     } else {
1145       result = MAP_ARCHIVE_MMAP_FAILURE;
1146     }
1147   }
1148 
1149   if (result == MAP_ARCHIVE_SUCCESS) {
1150     SharedBaseAddress = (size_t)mapped_base_address;
1151 #ifdef _LP64
1152         if (Metaspace::using_class_space()) {
1153           // Set up ccs in metaspace.
1154           Metaspace::initialize_class_space(class_space_rs);
1155 
1156           // Set up compressed Klass pointer encoding: the encoding range must
1157           //  cover both archive and class space.
1158           address cds_base = (address)static_mapinfo->mapped_base();
1159           address ccs_end = (address)class_space_rs.end();
1160           assert(ccs_end > cds_base, "Sanity check");
1161           if (INCLUDE_CDS_JAVA_HEAP || UseCompactObjectHeaders) {
1162             // The CDS archive may contain narrow Klass IDs that were precomputed at archive generation time:
1163             // - every archived java object header (only if INCLUDE_CDS_JAVA_HEAP)
1164             // - every archived Klass' prototype   (only if +UseCompactObjectHeaders)
1165             //
1166             // In order for those IDs to still be valid, we need to dictate base and shift: base should be the
1167             // mapping start, shift the shift used at archive generation time.
1168             address precomputed_narrow_klass_base = cds_base;
1169             const int precomputed_narrow_klass_shift = ArchiveBuilder::precomputed_narrow_klass_shift;
1170             CompressedKlassPointers::initialize_for_given_encoding(
1171               cds_base, ccs_end - cds_base, // Klass range
1172               precomputed_narrow_klass_base, precomputed_narrow_klass_shift // precomputed encoding, see ArchiveBuilder
1173             );
1174           } else {
1175             // Let JVM freely chose encoding base and shift
1176             CompressedKlassPointers::initialize (
1177               cds_base, ccs_end - cds_base // Klass range
1178               );
1179           }
1180           // map_or_load_heap_region() compares the current narrow oop and klass encodings
1181           // with the archived ones, so it must be done after all encodings are determined.
1182           static_mapinfo->map_or_load_heap_region();
1183         }
1184 #endif // _LP64
1185     log_info(cds)("initial optimized module handling: %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
1186     log_info(cds)("initial full module graph: %s", CDSConfig::is_loading_full_module_graph() ? "enabled" : "disabled");
1187   } else {
1188     unmap_archive(static_mapinfo);
1189     unmap_archive(dynamic_mapinfo);
1190     release_reserved_spaces(total_space_rs, archive_space_rs, class_space_rs);
1191   }
1192 
1193   return result;
1194 }
1195 
1196 
1197 // This will reserve two address spaces suitable to house Klass structures, one
1198 //  for the cds archives (static archive and optionally dynamic archive) and
1199 //  optionally one move for ccs.
< prev index next >