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

Flags should be set using the proper macro



    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:


      The tracing framework has events that reports all flags in the VM, similar to -XX:+PrintFlagsFinal. These events contains the origin of the value of each flag, that is if it is set on the command line, if it has been changed by ergonomics or if it has the default value. In some places in the code we change the value of a flag using plain assignment. This means that we change the value but doesn't update the origin of the value. The result is that the flags will be reported as having default values when they don't, or maybe more confusing for the user, as being set on the command line but having a different value then what was set on the command line.

      We should make sure all flag changes use the proper macros so that the origin is updated as well. Also we should make sure no ergonomic updates are made using the FLAG_SET_CMDLINE macro. Only the user should set the command line.

      We also have the case where a flag is set on the command line and later changed by the ergonomics (FLAG_SET_ERGO). After this, the question FLAG_IS_CMDLINE will reply false. This makes the policy code more difficult to write and maintain since we will have to use a separate variable to remember that the flag was set on the command line in cases where the value is not really changed by the ergonomics, only slightly adjusted. For instance if a memory size is aligned to a page size or similar.
      In some cases we have chosen to update a flag variable without using the proper macro for doing so which will have other consequences.

      Another similar problem is the command line flags that we put in the gc log file when using -Xloggc. Here we print all flags that are not labeled as default as if they were specified on the command line. This is not true since lots of flags are changed by ergonomics. To print the proper flags we need to save which flags was specified on the command line. We should also add another line to the log file and print the flags that was not specified on the command line but changed by ergonomics, so that we don't remove information that is present in the log file today.

      To clean up the initialization code and fix the bug in the log file we should change the flag implementation to store its state in a persistent manner so that we can ask if a flag was set on the command line and if it was set by the ergonomics and get truthful answers in all cases.


          Issue Links



              jwilhelm Jesper Wilhelmsson
              jwilhelm Jesper Wilhelmsson
              0 Vote for this issue
              6 Start watching this issue