JDK-8243205 : Modularize JVM flags declaration
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-20
  • Updated: 2022-06-27
  • Resolved: 2020-12-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b02Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
The purpose of this RFE is to improve modularization of the source code and speed up compilation of HotSpot C++ source code.

Today all global variables generated by the JVM XXX_FLAGS macros are declared at the end of globals.hpp.

http://hg.openjdk.java.net/jdk/jdk/file/4a5a7dc9d05c/src/hotspot/share/runtime/globals.hpp#l2498

As a result, any file that needs just one of such globals will need to include a large number of header files, with a total of over 1000 global declarations.

We should modularize this by doing the variable declaration in each individual header that has a XXX_FLAGS specification. E.g.,

c1_globals.hpp:

    #define C1_FLAGS(develop, develop_pd, product, .........) \
        develop(intx, C1FlagA, 123, "some flag A for C1) \
        product(intx, C1FlagB, 456, "some flag B for C1)
   DECLARE_FLAGS(C1_FLAGS)

The DECLARE_FLAGS macro will expand to this (in product build)
    extern intx C1FlagA;
    const intx C1FlagB = 456;

Most of the HotSpot files that reference C1FlagA/C1FlagB can simply include c1_globals.hpp, without including the other unrelated xxx_globals.hpp file.

DECLARE_FLAGS would be something like:

#define DECLARE_FLAGS(FLAG_SPECIFIER) \
    FLAG_SPECIFIER( 
          DECLARE_DEVELOPER_FLAG, \
          DECLARE_PD_DEVELOPER_FLAG, \
          DECLARE_PRODUCT_FLAG, \
          DECLARE_PD_PRODUCT_FLAG, \
          DECLARE_NOTPRODUCT_FLAG, \
          IGNORE_RANGE, \
          IGNORE_CONSTRAINT)
Comments
Changeset: 1d15ebe1 Author: Ioi Lam <iklam@openjdk.org> Date: 2020-12-11 04:18:54 +0000 URL: https://git.openjdk.java.net/jdk/commit/1d15ebe1
11-12-2020

Note, this approach is current not possible because the flag macros do not have the same number of parameters. E.g., http://hg.openjdk.java.net/jdk/jdk/file/4a5a7dc9d05c/src/hotspot/share/runtime/globals.hpp#l115 define RUNTIME_FLAGS(develop, \ develop_pd, \ product, \ product_pd, \ diagnostic, \ diagnostic_pd, \ experimental, \ notproduct, \ manageable, \ product_rw, \ lp64_product, \ range, \ constraint) \ http://hg.openjdk.java.net/jdk/jdk/file/4a5a7dc9d05c/src/hotspot/share/c1/c1_globals.hpp#l37 #define C1_FLAGS(develop, \ develop_pd, \ product, \ product_pd, \ diagnostic, \ diagnostic_pd, \ notproduct, \ range, \ constraint) \ So this RFE needs to be done after JDK-8243208, which will unify/simplify the parameters to the XXX_FLAGS macros so we always have 7 parameters.
23-08-2020