Skip to content

Commit 98edb03

Browse files
committed
8320382: Remove CompressedKlassPointers::is_valid_base()
Reviewed-by: rkennke, aph
1 parent 2c31ca5 commit 98edb03

File tree

3 files changed

+10
-35
lines changed

3 files changed

+10
-35
lines changed

src/hotspot/share/cds/metaspaceShared.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,16 @@ size_t MetaspaceShared::core_region_alignment() {
141141
}
142142

143143
static bool shared_base_valid(char* shared_base) {
144-
#ifdef _LP64
145-
return CompressedKlassPointers::is_valid_base((address)shared_base);
146-
#else
147-
return true;
148-
#endif
144+
// We check user input for SharedBaseAddress at dump time. We must weed out values
145+
// we already know to be invalid later.
146+
147+
// At CDS runtime, "shared_base" will be the (attempted) mapping start. It will also
148+
// be the encoding base, since the the headers of archived base objects (and with Lilliput,
149+
// the prototype mark words) carry pre-computed narrow Klass IDs that refer to the mapping
150+
// start as base.
151+
//
152+
// Therefore, "shared_base" must be later usable as encoding base.
153+
return AARCH64_ONLY(is_aligned(shared_base, 4 * G)) NOT_AARCH64(true);
149154
}
150155

151156
class DumpClassListCLDClosure : public CLDClosure {
@@ -1257,12 +1262,6 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma
12571262
if (base_address != nullptr) {
12581263
assert(is_aligned(base_address, archive_space_alignment),
12591264
"Archive base address invalid: " PTR_FORMAT ".", p2i(base_address));
1260-
#ifdef _LP64
1261-
if (Metaspace::using_class_space()) {
1262-
assert(CompressedKlassPointers::is_valid_base(base_address),
1263-
"Archive base address invalid: " PTR_FORMAT ".", p2i(base_address));
1264-
}
1265-
#endif
12661265
}
12671266

12681267
if (!Metaspace::using_class_space()) {
@@ -1348,7 +1347,6 @@ char* MetaspaceShared::reserve_address_space_for_archives(FileMapInfo* static_ma
13481347
"Sanity (" PTR_FORMAT " vs " PTR_FORMAT ")", p2i(base_address), p2i(total_space_rs.base()));
13491348
assert(is_aligned(total_space_rs.base(), archive_space_alignment), "Sanity");
13501349
assert(total_space_rs.size() == total_range_size, "Sanity");
1351-
assert(CompressedKlassPointers::is_valid_base((address)total_space_rs.base()), "Sanity");
13521350

13531351
// Now split up the space into ccs and cds archive. For simplicity, just leave
13541352
// the gap reserved at the end of the archive space. Do not do real splitting.

src/hotspot/share/oops/compressedKlass.cpp

-18
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ size_t CompressedKlassPointers::_range = 0;
3939
// set this encoding scheme. Used by CDS at runtime to re-instate the scheme used to pre-compute klass ids for
4040
// archived heap objects.
4141
void CompressedKlassPointers::initialize_for_given_encoding(address addr, size_t len, address requested_base, int requested_shift) {
42-
assert(is_valid_base(requested_base), "Address must be a valid encoding base");
4342
address const end = addr + len;
4443

4544
const int narrow_klasspointer_bits = sizeof(narrowKlass) * 8;
@@ -89,23 +88,6 @@ void CompressedKlassPointers::initialize(address addr, size_t len) {
8988
set_base(base);
9089
set_shift(shift);
9190
set_range(range);
92-
93-
assert(is_valid_base(_base), "Address must be a valid encoding base");
94-
}
95-
96-
// Given an address p, return true if p can be used as an encoding base.
97-
// (Some platforms have restrictions of what constitutes a valid base address).
98-
bool CompressedKlassPointers::is_valid_base(address p) {
99-
#ifdef AARCH64
100-
// Below 32G, base must be aligned to 4G.
101-
// Above that point, base must be aligned to 32G
102-
if (p < (address)(32 * G)) {
103-
return is_aligned(p, 4 * G);
104-
}
105-
return is_aligned(p, (4 << LogKlassAlignmentInBytes) * G);
106-
#else
107-
return true;
108-
#endif
10991
}
11092

11193
void CompressedKlassPointers::print_mode(outputStream* st) {

src/hotspot/share/oops/compressedKlass.hpp

-5
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ class CompressedKlassPointers : public AllStatic {
6262

6363
public:
6464

65-
// Given an address p, return true if p can be used as an encoding base.
66-
// (Some platforms have restrictions of what constitutes a valid base
67-
// address).
68-
static bool is_valid_base(address p);
69-
7065
// Given a klass range [addr, addr+len) and a given encoding scheme, assert that this scheme covers the range, then
7166
// set this encoding scheme. Used by CDS at runtime to re-instate the scheme used to pre-compute klass ids for
7267
// archived heap objects.

0 commit comments

Comments
 (0)