JDK-8236606 : Generate source code for the JVMFlag::flags table
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2020-01-02
  • Updated: 2020-01-13
  • Resolved: 2020-01-13
Related Reports
Relates :  
Relates :  
Relates :  
Description
The following three functions dynamically build up growable arrays to implement constraint checks for JVM options

  JVMFlagRangeList::init();
  JVMFlagConstraintList::init();
  JVMFlagWriteableList::init();

The code that builds up the arrays is complex

   text	   data	    bss	    dec	    hex	filename
  26055	    616	     12	  26683	   683b	./hotspot/variant-server/libjvm/objs/jvmFlagRangeList.o
   4606	      0	     12	   4618	   120a	./hotspot/variant-server/libjvm/objs/jvmFlagWriteableList.o
  21811	    704	     20	  22535	   5807	./hotspot/variant-server/libjvm/objs/jvmFlagConstraintList.o

Also, looking up of the constraint info requires a linear search. See JVMFlagRangeList::find:

http://hg.openjdk.java.net/jdk/jdk/file/2fbc66ef1a1d/src/hotspot/share/runtime/flags/jvmFlagRangeList.cpp#l340

There are only 809 flags in the product build, and less than half of them have constraints. The constraint information should be part of the JVMFlag structure. However, due to the way that the flags are declared (in globals.hpp), it's not easy to get the constraint info into JVMFlag using C macros.

Also, JVMFlag::find_flag does a linear search, and computes the string lengths of all the option names at JVM start-up.

The best solution is to generate the C source code for JVMFlags::flags during the JDK build. We can sort the flags alphabetically so we can use binary search (or even use a hashtable).
Comments
A better design exists (JDK-8236988). Closing this RFE as will-not-fix.
13-01-2020

Prototypes: (Generate the table using a build tool) http://cr.openjdk.java.net/~iklam/jdk15/8236606-generate-jvmFlags.hpp.preview.0/ (No table generation, but reorganize the C macros to avoid building GrowableArrays for range/constraint). http://cr.openjdk.java.net/~iklam/jdk15/8236606-generate-jvmFlags.hpp.preview.1/ These webrevs are based on http://hg.openjdk.java.net/jdk/jdk/rev/6411242023f9
08-01-2020