RFR: 8286117: Remove unnecessary indirection and unused code in UL

Johan Sjölén duke at openjdk.java.net
Thu May 5 07:13:31 UTC 2022


On Wed, 4 May 2022 23:13:48 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> This PR cleans up some minor annoyances in the UL code.
>> 
>> Note that the change from `LogImpl` to `LogTagSet` is equivalent, we're essentially inlining the calls that `LogImpl` would have made. This simplifies understanding ("why do we need `LogImpl` here?" was my question, answer: We don't!)'
>
> src/hotspot/share/logging/logTagSet.hpp line 168:
> 
>> 166: // tagset. This _tagset contains the configuration for those tags.
>> 167: template <LogTagType T0, LogTagType T1, LogTagType T2, LogTagType T3, LogTagType T4, LogTagType GuardTag>
>> 168: LogTagSet LogTagSetMapping<T0, T1, T2, T3, T4, GuardTag>::_tagset{&LogPrefix<T0, T1, T2, T3, T4>::prefix, T0, T1, T2, T3, T4};
> 
> Is this a specialized initialization syntax? I'm not familiar with its significance.

This particular change I'm not very attached to, if it doesn't immediately improve the code to you then I suggest we skip it. This syntax is called "uniform initialization" syntax, I believe. Semantically it is *almost* equivalent to using `()` for initialization. Here I am only using it to make it very clear that we're initializing a static field for a specific class. I think it reads easier at the top-level since with parens it's syntactically similar to a strange function declaration.

Here's a good link: https://stackoverflow.com/questions/24953658/what-are-the-differences-between-c-like-constructor-and-uniform-initialization

Regarding your other comment: This line is what instantiates every single `LogTagSet` which is needed for the logging, and none are created at run time.

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

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


More information about the hotspot-runtime-dev mailing list