diff options
author | Steffen Mueller <smueller@cpan.org> | 2013-07-02 19:33:53 +0200 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2013-07-02 19:33:53 +0200 |
commit | 3dbcc5e0ae2d584501e47a0ca58e6f7a2888e02e (patch) | |
tree | 7ac6622815bfc4cfcd25d844722b7c2c7fe99261 /pp.c | |
parent | 75d476e24a01b66c507ec2d7c2c99d3f810f625e (diff) | |
download | perl-3dbcc5e0ae2d584501e47a0ca58e6f7a2888e02e.tar.gz |
Very few PAD[HA]Vs are "LVALUE": branch predictor hints
In a nutshell, very few PADHV and PADAV OPs are executed that have
the OPpLVAL_INTRO flag set. To wit, "my %h" does whereas "$h{foo}" and
similar (also "$h{foo} = 1") do not. Also, traditional lexicals greatly
outnumber state variables, so pessimize "state" slightly.
This was determined with a nifty new trick. With a Perl compiled with
-DPERL_TRACE_OPS, we get a summary of all executed op counts by type at
the end of the program execution. The above was figured out (naively) by
adding the following:
--- a/dump.c
+++ b/dump.c
@@ -2215,6 +2215,8 @@ Perl_runops_debug(pTHX)
do {
#ifdef PERL_TRACE_OPS
++PL_op_exec_cnt[PL_op->op_type];
+ if (PL_op->op_type == OP_PADHV && PL_op->op_private & OPpLVAL_INTRO)
+ ++PL_op_exec_cnt[OP_max+1];
#endif
if (PL_debug) {
if (PL_watchaddr && (*PL_watchaddr != PL_watchok))
Which adds a special case (OP_max+1) to the OP report. Dividing that
count by the total PADHV count gives a diminishingly small percentage.
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -68,8 +68,8 @@ PP(pp_padav) dVAR; dSP; dTARGET; I32 gimme; assert(SvTYPE(TARG) == SVt_PVAV); - if (PL_op->op_private & OPpLVAL_INTRO) - if (!(PL_op->op_private & OPpPAD_STATE)) + if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO )) + if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) )) SAVECLEARSV(PAD_SVl(PL_op->op_targ)); EXTEND(SP, 1); if (PL_op->op_flags & OPf_REF) { @@ -118,8 +118,8 @@ PP(pp_padhv) assert(SvTYPE(TARG) == SVt_PVHV); XPUSHs(TARG); - if (PL_op->op_private & OPpLVAL_INTRO) - if (!(PL_op->op_private & OPpPAD_STATE)) + if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO )) + if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) )) SAVECLEARSV(PAD_SVl(PL_op->op_targ)); if (PL_op->op_flags & OPf_REF) RETURN; |