Skip to content

Commit e735376

Browse files
committed
8324523: Lilliput: if +UseCOH, always use the archive's encoding base and shift
Reviewed-by: rkennke
1 parent 89924ae commit e735376

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/hotspot/share/cds/metaspaceShared.cpp

+18-12
Original file line numberDiff line numberDiff line change
@@ -1158,19 +1158,25 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File
11581158
address cds_base = (address)static_mapinfo->mapped_base();
11591159
address ccs_end = (address)class_space_rs.end();
11601160
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 = ArchiveBuilder::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 ArchiveBuilder
1168-
);
1169-
#else
1170-
CompressedKlassPointers::initialize (
1171-
cds_base, ccs_end - cds_base // Klass range
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
11721173
);
1173-
#endif // INCLUDE_CDS_JAVA_HEAP
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+
}
11741180
// map_or_load_heap_region() compares the current narrow oop and klass encodings
11751181
// with the archived ones, so it must be done after all encodings are determined.
11761182
static_mapinfo->map_or_load_heap_region();

0 commit comments

Comments
 (0)