!PRODUCT vs ASSERT?
Thomas Stüfe
thomas.stuefe at gmail.com
Tue Jul 18 12:22:52 UTC 2017
Hi Mikael,
On Tue, Jul 18, 2017 at 2:19 PM, Mikael Gerdin <mikael.gerdin at oracle.com>
wrote:
> Hi Thomas,
>
> On 2017-07-18 11:35, Thomas Stüfe wrote:
>
>> Hi all,
>>
>> a short and maybe stupid question, what is the precise difference between:
>>
>> #ifndef PRODUCT
>>
>> vs
>>
>> #ifdef ASSERT
>>
>> ?
>>
>> I assume:
>>
>> optimized: !PRODUCT && !ASSERT
>> xxxdebug: !PRODUCT && ASSERT
>> release: PRODUCT && !ASSERT
>>
>
> Correct.
>
>
>> is this true?
>>
>> Also, when guarding pieces of performance-costly sanity checks, which one
>> should be used?
>>
>
> My thinking is that the performance of "optimized" should be close to
> "release" checks should be kept out of the hottest paths.
>
>
That was my assumption too. So, I'll guard expensive checks with #ifdef
ASSERT.
>
>> (I see both used sometimes. For example, MetaChunk::mangle()
>> implementation
>> is guarded by !PRODUCT but its call is guarded once by ASSERT, once by
>> !PRODUCT, is that deliberate?)
>>
>
> I think it's a mix between judgment calls and misunderstandings :)
> I don't consider metaspace allocations such a hot path so it's not
> completely unreasonable I think.
>
/Mikael
>
>
>> Thanks, Thomas
>>
>>
..Thomas
More information about the hotspot-dev
mailing list