Skip to content

Commit 164d036

Browse files
committed
8364202: CDS without G1 gives build error in slowdebug, asserts in fastdebug
Reviewed-by: ccheung, iklam
1 parent c671089 commit 164d036

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

src/hotspot/share/cds/metaspaceShared.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,8 +1603,7 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File
16031603

16041604
// Set up compressed Klass pointer encoding: the encoding range must
16051605
// cover both archive and class space.
1606-
const address encoding_base = (address)mapped_base_address;
1607-
const address klass_range_start = encoding_base + prot_zone_size;
1606+
const address klass_range_start = (address)mapped_base_address;
16081607
const size_t klass_range_size = (address)class_space_rs.end() - klass_range_start;
16091608
if (INCLUDE_CDS_JAVA_HEAP || UseCompactObjectHeaders) {
16101609
// The CDS archive may contain narrow Klass IDs that were precomputed at archive generation time:
@@ -1615,13 +1614,19 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File
16151614
// mapping start (including protection zone), shift should be the shift used at archive generation time.
16161615
CompressedKlassPointers::initialize_for_given_encoding(
16171616
klass_range_start, klass_range_size,
1618-
encoding_base, ArchiveBuilder::precomputed_narrow_klass_shift() // precomputed encoding, see ArchiveBuilder
1617+
klass_range_start, ArchiveBuilder::precomputed_narrow_klass_shift() // precomputed encoding, see ArchiveBuilder
16191618
);
1619+
assert(CompressedKlassPointers::base() == klass_range_start, "must be");
16201620
} else {
16211621
// Let JVM freely choose encoding base and shift
16221622
CompressedKlassPointers::initialize(klass_range_start, klass_range_size);
1623+
assert(CompressedKlassPointers::base() == nullptr ||
1624+
CompressedKlassPointers::base() == klass_range_start, "must be");
1625+
}
1626+
// Establish protection zone, but only if we need one
1627+
if (CompressedKlassPointers::base() == klass_range_start) {
1628+
CompressedKlassPointers::establish_protection_zone(klass_range_start, prot_zone_size);
16231629
}
1624-
CompressedKlassPointers::establish_protection_zone(encoding_base, prot_zone_size);
16251630

16261631
// map_or_load_heap_region() compares the current narrow oop and klass encodings
16271632
// with the archived ones, so it must be done after all encodings are determined.

src/hotspot/share/classfile/classLoaderDataShared.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ class SerializeClosure;
3535

3636
class ClassLoaderDataShared : AllStatic {
3737
static bool _full_module_graph_loaded;
38-
static void ensure_module_entry_table_exists(oop class_loader);
38+
CDS_JAVA_HEAP_ONLY(static void ensure_module_entry_table_exists(oop class_loader);)
3939
public:
40+
#if INCLUDE_CDS_JAVA_HEAP
4041
static void ensure_module_entry_tables_exist();
4142
static void allocate_archived_tables();
4243
static void iterate_symbols(MetaspaceClosure* closure);
@@ -49,6 +50,7 @@ class ClassLoaderDataShared : AllStatic {
4950
static void restore_java_system_loader_from_archive(ClassLoaderData* loader_data);
5051
static ModuleEntry* archived_boot_unnamed_module();
5152
static ModuleEntry* archived_unnamed_module(ClassLoaderData* loader_data);
53+
#endif // INCLUDE_CDS_JAVA_HEAP
5254
static bool is_full_module_graph_loaded() { return _full_module_graph_loaded; }
5355
};
5456

src/hotspot/share/memory/universe.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,11 @@ jint universe_init() {
909909
ClassLoaderData::init_null_class_loader_data();
910910

911911
#if INCLUDE_CDS
912+
#if INCLUDE_CDS_JAVA_HEAP
912913
if (CDSConfig::is_using_full_module_graph()) {
913914
ClassLoaderDataShared::restore_archived_entries_for_null_class_loader_data();
914915
}
916+
#endif // INCLUDE_CDS_JAVA_HEAP
915917
if (CDSConfig::is_dumping_archive()) {
916918
CDSConfig::prepare_for_dumping();
917919
}

src/hotspot/share/oops/compressedKlass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ void CompressedKlassPointers::calc_lowest_highest_narrow_klass_id() {
141141
address lowest_possible_klass_location = _klass_range_start;
142142

143143
// A Klass will never be placed at the Encoding range start, since that would translate to a narrowKlass=0, which
144-
// is disallowed. Note that both Metaspace and CDS prvent allocation at the first address for this reason.
144+
// is disallowed. If the encoding range starts at the klass range start, both Metaspace and CDS establish an
145+
// mprotected zone for this reason (see establish_protection_zone).
145146
if (lowest_possible_klass_location == _base) {
146147
lowest_possible_klass_location += klass_alignment_in_bytes();
147148
}

src/hotspot/share/oops/compressedKlass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class CompressedKlassPointers : public AllStatic {
124124
static address _base;
125125
static int _shift;
126126

127-
// Start and end of the Klass Range.
127+
// Start and end of the Klass Range. Start includes the protection zone if one exists.
128128
// Note: guaranteed to be aligned to 1<<shift (klass_alignment_in_bytes)
129129
static address _klass_range_start;
130130
static address _klass_range_end;

0 commit comments

Comments
 (0)