Improper usage of CHECK macros generates unreachable code
David Holmes - Sun Microsystems
David.Holmes at Sun.COM
Wed Oct 7 17:02:40 PDT 2009
Tom Rodriguez said the following on 10/08/09 02:33:
>> 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.
>
> If all the places where this happens are for allocation then it's
> because they will always return null if an exception is thrown. I
> you're calling something that uses CHECK_NULL then the return value will
> already agree with HAS_PENDING_EXCEPTION.
>
>> 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 believe this is the right solution as well.
I third the motion for fixing this properly rather than just removing
the compiler warning. It may be that some of the uses of CHECK are
redundant anyway once you peek inside the method being CHECKed - and
those can then be replaced by THREAD (or perhaps even elided completely).
In some cases though it will be a thousand times faster to use the
temporary result than to try to figure out if the check is needed - eg
ObjectLocker::complete_exit :)
David
> tom
>
>>
>> Regards,
>> Volker
>>
>>>
>>> -- Christian
>>>
>>>
>
More information about the hotspot-dev
mailing list