Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros (original) (raw)
Vitaly Davidovich vitalyd at gmail.com
Thu Mar 28 17:01:53 PDT 2013
- Previous message: Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros
- Next message: Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
John, with lambdas that capture variables there's still the issue of allocating the holder class isn't there? So you remove the overhead of deriving the message but you still get GC churn (unless JIT inlines and escape analyzes out the alloc, but I don't think it's very reliable).
Sent from my phone On Mar 28, 2013 7:56 PM, "John Rose" <john.r.rose at oracle.com> wrote:
On Mar 28, 2013, at 4:22 PM, Krystal Mo <krystal.mo at oracle.com> wrote:
> I'd say it has to do with the way ResourceMark works. This is a common feature with all sorts of conditional coprocessing facilities. The pattern is: x = somevalue; if (loggingisenabled) { x' = deriveinterestingdetailsforlogging(x); printtologger(x'); } One would like to capture it in a subroutine: x = somevalue; maybelog(deriveinterestingdetailsforlogging(x)); But this transfers the expense of digging out the "details" (or the formatted detail string) outside of the guard, adding an expense even when the logging is disabled. Assertions can also be thought of as a sort of conditional processing. Java works around the expense of computing assertion parameters by making the whole thing a special language feature under a keyword. In JDK 8 with lambdas, there will be new options for conditional execution of expressions: x = somevalue; maybelog(()->deriveinterestingdetailsforlogging(x)); In C, we get to use macros for this sort of thing. — John
- Previous message: Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros
- Next message: Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]