Request for review (S): JDK-8011009: Use do-while(0) instead of while(0) in EC_TRACE and RC_TRACE* macros
Krystal Mo
krystal.mo at oracle.com
Fri Mar 29 04:12:07 PDT 2013
Thanks John, you're the man! Yes, in general the reason is about
variable capturing and composing code.
If we can use C++11 lambdas ew might get rid of some of these macros and
turn them into functions...well I'm just saying.
- Kris
On 03/28/2013 04:55 PM, John Rose wrote:
> On Mar 28, 2013, at 4:22 PM, Krystal Mo <krystal.mo at oracle.com
> <mailto: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