RFR: 8193559: ugly DO_JAVA_THREADS macro should be replaced [v2]

Kim Barrett kbarrett at openjdk.java.net
Sun Jul 4 22:32:59 UTC 2021


On Sun, 4 Jul 2021 12:22:47 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> I wasn't expecting any change based on that comment, just pointing out that the code
>> *is* contrary to the style guide, in a place where I think the guide should be changed.
>
> I'm surprised that a declaration is even legal in that position - but then I should never be surprised at the crazy things C++ allows. :( I do think  it looks truly awful to have a declaration there. Surely we do not have to reduce this to being a single-line macro that emulates a for-loop? That said I can't make any sense out of the original macro so sure this is a less-ugly macro. But why does this have to be so obscure - aren't we just walking the current threads-list ??

I failed to notice previously that the new macro introduces the "iter" variable into the body scope.  The old macro used naming conventions to avoid adding any "simple" names that could inadvertently affect the meaning of the code.

Thinking about David's reply, I'm also wondering if it might be possible to do better by making use of range-based for.  It would involve defining a compliant iterator rather than the JavaThreadPrefetchedIterator, but that's not very hard.  (And I can help with that.)  Doing so would really simplify the macro, or perhaps even render it so trivial as to not be worth using any more.

So I'm rescinding my approval of this change.

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

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


More information about the hotspot-gc-dev mailing list