!PRODUCT vs ASSERT?

Mikael Gerdin mikael.gerdin at oracle.com
Tue Jul 18 12:19:46 UTC 2017


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.

> 
> (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
> 


More information about the hotspot-dev mailing list