Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros

Vitaly Davidovich vitalyd at gmail.com
Thu Mar 28 17:01:53 PDT 2013


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 = some_value;
>   if (logging_is_enabled) {
>     x' = derive_interesting_details_for_logging(x);
>     print_to_logger(x');
>   }
>
> One would like to capture it in a subroutine:
>
>   x = some_value;
>   maybe_log(derive_interesting_details_for_logging(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 = some_value;
>   maybe_log(()->derive_interesting_details_for_logging(x));
>
> In C, we get to use macros for this sort of thing.
>
> — John


More information about the hotspot-dev mailing list