Improper usage of CHECK macros generates unreachable code
John Rose
John.Rose at Sun.COM
Wed Oct 7 21:23:24 PDT 2009
On Oct 7, 2009, at 8:45 AM, Volker Simonis wrote:
> That's exactly my point. Changing CHECK to THREAD would just keep the
> current behaviour without the creation of unreachable code.
I've been doing this already, personally; look for "return.*THREAD" in
files I've touched.
This style allows compilers to emit tail calls. And allows humans to
understand them that way.
I think making a temporary variable here is often waste motion and
noise. (Sometimes it clarifies things, especially if the variable has
an informative name.)
There's no issue of failing to catch the exception, since the caller
is also required to poll for exceptions.
> If we want or need a more elaborate solution (and this was what I was
> actually asking in my first mail), we should store the result of a
> call which uses the check macro into a temporary variable and return
> that one. This will actually trigger the check in the CHECK macro as
> expected.
>
> My impression is that just replacing CHECK with THREAD would work
> because usually the caller of the method which does the call with the
> CHECK macro also checks for pending exception such that invalid return
> values do no harm. At least this is my only explanation for why this
> has not lead to any serious problems until now.
>
> But personally I would vote for the much cleaner solution with the
> temporary variable because it's not more overhead and there's still a
> small chance to catch some undiscovered errors.
I don't see useless variables and duplicated tests as producing
cleanliness.
-- John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-dev/attachments/20091007/b197c848/attachment.html
More information about the hotspot-dev
mailing list