RFR: 8255416: Investigate err_msg to detect unnecessary uses [v2]

Anton Kozlov akozlov at openjdk.java.net
Wed Oct 28 21:57:57 UTC 2020


On Wed, 28 Oct 2020 18:15:47 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/mode/shenandoahMode.hpp line 35:
>> 
>>> 33:   do {                                                                      \
>>> 34:     if (!(name)) {                                                          \
>>> 35:       const char *msg = "GC mode needs -XX:+" #name " to work correctly";   \
>> 
>> Please decide which way the `*` leans in this change. I prefer `const char* msg`, like in the change below.
>
> In fact, maybe just inline this literal down in `vm_exit_during_initialization` invocation.

Of course it should align to the left, like in the rest of hotspot. Thanks for noticing!

As for inlining of the message, there are pros and cons. The arguments should be aligned, so it would become
  do {                                                                      \
    if (!(name)) {                                                          \
      vm_exit_during_initialization("Error", msg);                          \
                                    "GC mode needs -XX:+" #name " to work correctly"; \
    }                                                                       \
  } while (0)

(not pretty at all, you see).

After that, there is an option to split the string into multiple lines in attempt to shrink the length, but then the line would become ungreppable (much bigger evil).

Among options, I decided to respect intention and style of original author, who introduced a variable for err_msg, which is unusual and should have some valid rationale behind, like the one above.

-------------

PR: https://git.openjdk.java.net/jdk/pull/905


More information about the shenandoah-dev mailing list