- Loading...
Note: this proposal has been withdrawn. It has been superceded by JDK-8243208
This is a design document for JDK-8236988 - VM flags: replace ALL_FLAGS macro with a modular designModular Design for JVM Flags
Improve the implementation of JVM command-line flags (such as -XX:+UseCompressedOops)
Break up monolithic globals.hpp
#include "gc/z/z_globals.hpp" (see also gc/z/z_globals.flags.hpp)#include "memory/metaspaceShared_globals.hpp" ( // just flags related to CDS).E.g., one can have a "manageable" switch and an "experimental" switch, but not a "manageable_experimental" switch.
(Design contribution by Erik Österlund, Stefan Karlsson, Coleen Phillimore)
...
The main goal of the inline functions is to avoid duplicating the information between the HPP and CPP files, so the CPP files contains just boilerplate code:just boilerplate code.
| Code Block |
|---|
DEFN_PRODUCT_FLAG(StressLCM); DEFN_PRODUCT_FLAG(StressGCM); DEFN_PRODUCT_FLAG(MaxLoopPad); DEFN_PRODUCT_RANGE(MaxLoopPad); DEFN_PRODUCT_FLAG_PD(InteriorEntryAlignment); DEFN_PRODUCT_CONSTRAINT(InteriorEntryAlignment); |
Macros in the CPP files are expanded to
| Code Block |
|---|
// Definition of the flag itself FLAG_TYPE_StressLCM StressLCM = FLAG_DEFVAL_StressLCM(); // Definition of the flag's meta information ProductFlag<FLAG_TYPE_StressLCM> FLAG_StressLCM( FLAG_TYPE_NAME_StressLCM(), "StressLCM", (FLAG_ATTR_StressLCM() | JVMFlag::C2), &StressLCM, FLAG_DOCS_StressLCM()); <... the expansion of some macros are omitted for clarity> // Range check is implemented like this JVMFlagRange<FLAG_TYPE_MaxLoopPad> FLAG_RANGE_MaxLoopPad( &FLAG_MaxLoopPad, FLAG_MIN_MaxLoopPad(), FLAG_MAX_MaxLoopPad()); // Inside the constructor of FLAG_RANGE_MaxLoopPad, it essentially registers // itself as the range spec for FLAG_MaxLoopPad, FLAG_MaxLoopPad._range = &FLAG_RANGE_MaxLoopPad; |
...
However, it's possible to forget to put DEFN_PRODUCT_RANGE(MaxLoopPad) in c2_globals.cpp. I can't think of a way to statically check for that, so I added a runtime check (debug builds only). See JVMFlag::validate_flags().
...