JDK-8140322 : Per-method usage of the DisableIntrinsic flags does not permit value accumulation
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9,10
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2015-10-22
  • Updated: 2018-10-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
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).

Comments
My 2 cents, Several -XX:DisableIntrinsic does accumulate, And several -XX:CompileCommand=option,sun.misc.Unsafe::putChar,ccstrlist,DisableIntrinsic,... should accumulate (if not adding too much complexity) But I don't think -XX:DisableIntrinsic should accumulate with -XX:CompileCommand. It would make the compiler control backwards compatibility much more complex since it breaks the abstraction from how other flags work. Compiler control won't accumulate with the others since it is required to be able to override the default flags (whether a vmflag or a compilecommand)
23-10-2015