For instance, the large conditional in metaspace.cpp here;
3153 if (DumpSharedSpaces) {
3154 #if INCLUDE_CDS
3155 MetaspaceShared::estimate_regions_size();
3156
...
3186 if (SharedMiscCodeSize < min_misc_code_size) {
3187 report_out_of_shared_space(SharedMiscCode);
3188 }
Belong in metaspaceShared::align_regions_sizes() or something like that because everything it does, it prefixes with MetaspaceShared::.
Also the macro that estimate_regions_size() use shouldn't be in the header file since it's only used in the .cpp file.
#define SET_ESTIMATED_SIZE(type, region) \
Shared ##region## Size = FLAG_IS_DEFAULT(Shared ##region## Size) ? \
(uintx)(type ## SharedArchiveSize * region ## RegionPercentage) : Shared ## region ## Size
These giant CDS conditionals make this code hard to understand and modify. This one can be trivially moved.