Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8243208

Clean up JVMFlag implementation

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b16

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              iklam Ioi Lam
              Reporter:
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: