JDK-8243208 : Clean up JVMFlag implementation
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-20
  • Updated: 2024-11-22
  • Resolved: 2020-09-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 16
16 b16Fixed
Related Reports
Blocks :  
Blocks :  
Blocks :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Description
Many of the proposals below depend on constexpr -- see JDK-8208089 (JEP347:  Enable C++14 Language Features).

(1) Reduce the complexity of ALL_FLAGS and other macros

The current code conflates "availability" (product/develop/notproduct) with "attribute" (diagnostic, experimental, manageable). It has a limited number of a cross-product of these two:

    #define ALL_FLAGS(            \
        develop,                  \
        develop_pd,               \
        product,                  \
        product_pd,               \
        diagnostic,               \   == product + diagnostic
        diagnostic_pd,            \
        experimental,             \   == product + experimental
        notproduct,               \
        manageable,               \   == product + manageable
        product_rw,               \
        lp64_product,             \
        range,                    \
        constraint)               \

We should moved the attributes to a new "attr" parameter of the iterator macro, so now we have only 7 iterators:

    #define ALL_FLAGS(develop,    \
                      develop_pd, \
                      product,    \
                      product_pd, \
                      notproduct, \
                      range, \
                      constraint) \

So this will make it easy to have combinations like manageable+experimental flags (JDK-7123237).

  product(bool, HeapDumpBeforeFullGC, false, MANAGEABLE | EXPERIMENTAL,                    \
          "Dump heap to file before any major stop-the-world GC")           \
                                                                            \
(2) Each flag can optionally belong to a group. We have 5 such groups (C1, C2, JVMCI, ARCH, and LP64). The grouping is done by an excessively large macro: 

http://hg.openjdk.java.net/jdk/jdk/file/4a5a7dc9d05c/src/hotspot/share/runtime/flags/jvmFlag.cpp#l635

This can be simplified by counting the size of each group using constexpr.

(3) Constant-time access from JVMFlag to JVMFlagLimit (i.e., range/constraint).

Currently, each time a flag is specified in the command-line, we do a linear search of ~250 elements in JVMFlagRangeList::find().

In the new design, going from JVMFlag to JVMFlagLimit is a simple operation:

    JVMFlag* f = ...;
    int flag_enum = f - flagTable;
    JVMFlagLimit* limit = flagLimitTable[flag_enum]

The flagLimitTable, as well as all JVMFlagLimit structures, are initialized at compile time with constexpr.

(4) compile-time generation of hashtable of flags for quick searching in arguments.cpp
Comments
Changeset: 5144190e Author: Ioi Lam <iklam@openjdk.org> Date: 2020-09-11 04:05:18 +0000 URL: https://git.openjdk.java.net/jdk/commit/5144190e
11-09-2020

First public review: http://cr.openjdk.java.net/~iklam/jdk16/8243208-cleanup-jvmflag-impl.v01/
02-09-2020