JDK-8068688 : Clean up CDS conditionals in metaspace.cpp
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2015-01-08
  • Updated: 2015-04-28
  • Resolved: 2015-04-28
Related Reports
Relates :  
Description
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.
Comments
Fixes in JDK-8072061 should remove the need for MetaspaceShared::estimate_regions_size().
28-04-2015

This is being fixed with another enhancement. Closing as WNF.
28-04-2015

So does the fix for JDK-8072061 move the size calculation inside metaspaceShared? If so, we can close this if you've already addressed the technical debt with these new changes.
28-04-2015

estimate_regions_size will no longer be needed after JDK-8072061 (Use exact size for the four regions in the CDS archive) is fixed.
02-04-2015