develooper Front page | perl.perl5.porters | Postings from March 2013

Re: Confusion about SvANY and Devel::Peek output

Thread Previous | Thread Next
March 24, 2013 19:45
Re: Confusion about SvANY and Devel::Peek output
Message ID:
Dave Mitchell wrote:
> On Wed, Mar 20, 2013 at 04:11:51PM +0100, demerphq wrote:
>> Ok, thanks for the explanation.
>>>> Another question this raises for me: why is SvANY _before_ the
>>>> refcount and flags? Id have expected the flags to be first, then the
>>>> refcount then the sv_any member.
>>> Why?
>> Well id expect the flags to be first because I would assume they are
>> used the most.
> Here's a perlbench of unthreaded blead. Columns A nd B are vanilla,
> columns C & D are with the SV reordered to sv_flags/sv_refcnt/sv_any.
> Possibly 1% faster. Maybe 2% faster. Probably just noise!

"if(*(registerSV) & 0x80000) " has a more compact machine instruction 
encoding than  "if(*(registerSV+8) & 0x80000) " on x86. It is 1 less 
instruction bytes since the +8 to reach sv_flags doesn't need to be 
written. On the other hand, SvANY is required for all strings (CUR/LEN) 
and IVs. Some compilers will test the flag as a byte ("registerSV+9"), 
with a byte constant/operand if the test mask can be a byte and not a 
short or long, to test (to avoid a bunch of extra nulls in the constant 
in machine code), and others as a 32 bit int to avoid unaligned memory, 
avoid extra cache fetches, or the CPU is cheap and synthesises byte 
arthritic in firmware. I would use size of the executable section in the 
image to figure which is best.

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