Overview
This is a design document for JDK-8236988 - VM flags: replace ALL_FLAGS macro with a modular design
- Lots of files have changed. Please read this document first before heading over to the webrev
- Preliminary webrev: http://cr.openjdk.java.net/~iklam/jdk15/vm_flags_overhaul.008/
Goals
Improve the implementation of JVM command-line flags (such as -XX:+UseCompressedOops)
Break up monolithic globals.hpp
- Before:
- #include "runtime/globals.hpp" + globals_shared.hpp = declare all possible flags
- After:
- #include "gc/z/z_globals.hpp" (see also gc/z/z_globals.flags.hpp)
- Future: subdivide globals.hpp into individual components:
- (Not in this patch, but possible)
- #include "memory/metaspaceShared_globals.hpp" (just flags related to CDS).
- Remove complex macros for flags manipulation
- Hotspot command line switches should have multiple type attributes
- See JDK-7123237
E.g., one can have a "manageable" switch and an "experimental" switch, but not a "manageable_experimental" switch.
- See JDK-7123237
- Templatize duplicated flag processing code:
- E.g., .(link to attachment)
- Speed up range/constraint checking for flags
- Avoid linear search for every -XX:NumericFlag=value argument in the command-line (jvmFlagRangeList.cpp)
Proposal
(Design contribution by Erik Österlund, Stefan Karlsson, Coleen Phillimore)
NOTE:
- Most of the current patch is generated by a script, so it's easy to change the design
- Summary of changes: 14748 lines changed: 6837 ins; 6204 del; 1707 mod; 33867 unchg
Before
|
Declaration Example: c2_globals.hpp (macros such as PRODUCT_FLAG are defined in jvmFlag.hpp)
|
Macros are expanded to
|
Definition Example: c2_globals.cpp (macros such as DEFN_PRODUCT_FLAG are defined jvmFlag.inline.hpp)
|
Macros are expanded to
|
Iterating over all flags:
|
Alternatives
- Declare flags in template files with custom syntax
flag type = bool, name = UseCompressedOops, default = false, help = "Use 32-bit object references in 64-bit VM.", type = product | lp64;
Or XML, or ....
Auto-generation of header files from templates
- Pros:
- Can generate more compact code that current proposal (see below)
- Flags can be pre-sorted, hashed, etc
- Cons:
- More complex build (nowhere as bad as .ad files, but affects all developers, not just JIT compiler geeks)
- Not understood by IDE tools