static_cast<void>(0) vs do while

Julian Waters tanksherman27 at gmail.com
Fri Jan 12 05:24:09 UTC 2024


Hi all,

In my personal fork of HotSpot I have the following commit
https://github.com/TheShermanTanker/jdk/commit/54131b70d40a88ab4176d23821f4c32044c0043d
which replaces some occurrences of do while with a discarding
static_cast (static_cast<void>(0) is a nop), to avoid inefficiencies
in the compiled code for debug mode, when optimizations are turned off
(Namely a compare and jump back to the start of the loop on a
condition that is always false). Is this minor optimization worth
committing upstream to HotSpot? It should also mean that the compiled
code is clearer when the methods containing asserts are disassembled.

best regards,
Julian


More information about the hotspot-dev mailing list