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

Per-method usage of the DisableIntrinsic flags does not permit value accumulation

    Details

      Description

      The DisableIntrinsic flag behaves differently when used globally and when it is used on a per-method level.

      Global usage (-XX:DisableIntrinsic=<comma-separated list of disabled intrinsic IDs>) supports accumulation, that is, flag values specified later on the command line do not overwrite flag values specified earlier. For example, the flags

      -XX:DisableIntrinsic=_hashCode,_getChar -XX:DisableIntrinsic=_putChar

      disable all intrinsics specified (_hashCode, _getChar, _putChar).

      DisableIntrinsic can be used on a per-method level as well. For example,

      -XX:CompileCommand=option,sun.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,_getCharVolatile,_getInt

      disables inlining of the intrinsics _getCharVolatile and _getInt into Unsafe::putChar, but allowes inlining of the intrinsics into any other method.

      However, the current implementation of CompileCommand does not permit accumulation of values. For example, specifying

      -XX:CompileCommand=option,sun.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,_getCharVolatile,_getInt -XX:CompileCommand=option,sun.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,_putInt

      on the command line will forbid only the inlining of the _putInt intrinsic into putChar, but not of _getCharVolatile and _getInt intrinsics.

      I filed this issue to track this problem.

      Here are some notes for the implementation.

      In compilerOracle.cpp in scan_flag_and_value(), if the type of a flag is 'ccstrlist', the value of that flag is registered with add_option_string for the current method. The add_option_string method overwrites previously registered values for the current method. Instead, add_option_string should check if a value is already defined for the current flag/method and concatenate the value of the current option to that value.

      Testing of the fix for this problem can be accomplished by modifying the IntrinsicDisabledTest.java test to run with multiple CompileCommand options, for example, also with

      -XX:CompileCommand=option,sun.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,_putInt

      and then verifying if the appropriate set of intrinsics is disabled.

      Another problem is the printing of ccstrlists in compilerDirectives.hpp. Currently, arguments of type ccstrlist are treated as a ccstr:

      void print_ccstrlist(outputStream* st, ccstr n, ccstr v, bool mod) { print_ccstr(st, n, v, mod); }

      That is correct from the point of the compiler (both types map to const char*), but from a software engineering point of view it is not the best thing to do. This implementation should update print_ccstrlist to use the correct argument type and also to print string list arguments in a more appropriate way (e.g., print all items on the list).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                zmajo Zoltan Majo (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: