RFR: 8193559: ugly DO_JAVA_THREADS macro should be replaced

Kim Barrett kbarrett at openjdk.java.net
Fri Jul 2 21:59:52 UTC 2021


On Fri, 2 Jul 2021 16:03:57 GMT, Daniel D. Daugherty <dcubed at openjdk.org> wrote:

> This is a simple rewrite of what is "Possibly the ugliest for loop the world has seen."
> Thanks to @stefank for the draft proposed fix. Thanks to @fisk for providing this
> piece of history that I'm finally getting around to cleaning up. While this macro has
> been with us for a long time, its time has passed...
> 
> Tested with Mach5 Tier[1-3].

Changes requested by kbarrett (Reviewer).

src/hotspot/share/runtime/thread.cpp line 2470:

> 2468: 
> 2469:     JavaThreadPrefetchedIterator(ThreadsList* list) :
> 2470:       _list(list), _end(list->threads() + list->length()), _current(list->threads()) {}

I don't see any uses of the `_list` member.

src/hotspot/share/runtime/thread.cpp line 2484:

> 2482: 
> 2483: #define DO_JAVA_THREADS(LIST, X) \
> 2484:   for (JavaThreadPrefetchedIterator iter(LIST); JavaThread* X = iter.current(); iter.next())

The condition is an implicit conversion to bool, which is disallowed
by the style guide.  In fact, it's a declaration, which is
specifically called out by the style guide.  When I revised the style
guide I made explicit mention of that usage because I'd tried to use
that sort of thing several years ago and got several complaints.  So
it's not that I personally think that usage is bad; rather, I was
hoping someone would take on the little project of convincing the team
it was good.  I don't have any objection to this part of the change.

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

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



More information about the hotspot-gc-dev mailing list