develooper Front page | perl.perl5.porters | Postings from June 2020

SvTRUE_common macro vs sv_true function

Thread Next
Karl Williamson
June 18, 2020 18:10
SvTRUE_common macro vs sv_true function
Message ID:
I'm working on changing some of the macros that evaluate their arguments 
more than once to do so only once.  SvTRUE is being changed in 5.32 to 
behave this way, but I'm working on getting its other flavors to behave 
the same way

In doing so, I notice some discrepancies, and I'm hoping I can get some 

The way we're accomplishing the single evaluation of parameters is to 
change macros to inline functions.  These should inline the simple, 
common parts, and hand off the complex uncommon parts to non-inlined 

The SvTRUE family call the macro SvTRUE_common.  The first thing that 
checks for is immortals.  In contrast, there is the function sv_true, 
which checks for many of the same things as SvTRUE does, and then calls 
another function to deal with the rest of the cases.  That doesn't deal 
directly with immortals.  I would think immortals would be less likely 
to be passed to these than regular SVs, so is there a reason they are in 
the macro?  I would guess that at the least, an UNLIKELY branch 
prediction would be warranted for them.

Similary, sv_true checks for truth in NVs, but not RVs, whereas SvTRUE 
does some checks for RVs, but not NVs.

What things are common that should be checked for inline vs. what things 
would be better deferred to the non-inline code?

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About