This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
optimise save/restore of PL_delaymagic.
authorDavid Mitchell <davem@iabyn.com>
Tue, 13 Oct 2015 16:02:39 +0000 (17:02 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 18 Oct 2015 11:04:27 +0000 (12:04 +0100)
commita68090fe12f676d7c874585fc2727765c009ab06
tree977833cffdf360c5de9d2ec700ed78e7c2acb11d
parent395391414ee1260c2b34a5f6a353908cc9d48d3f
optimise save/restore of PL_delaymagic.

A few places (pp_push, pp_unshift, pp_aassign) have to
set PL_delaymagic on entry, and restore it on exit. These are hot
pieces of code. Rather than using  ENTER/SAVEI16(PL_delaymagic)/LEAVE,
add an extra field to the jumpenv struct, and make the JUMPENV_PUSH / POP
macros automatically save and restore this var.

This means that pp_push etc only need to do a local save:

    U16 old_delaymagic = PL_delaymagic;
    PL_delaymagic = DM_DELAY;
    ....
    PL_delaymagic = old_delaymagic;

and in case of an exception being raised, PL_delaymagic still gets
restored.

This transfers the cost of saving PL_delaymagic from each call to
pp_aassign etc to each time a new run level is invoked. The latter should
be much less frequent.

Note that prior to this commit, pp_aassign wasn't actually saving and
restoring PL_delaymagic; it was just setting it to 0 at the end. So this
commit also makes pp_aassign safe against PL_delaymagic re-entrancy like
pp_push and pp_unshift already were.
cop.h
intrpvar.h
pp.c
pp_hot.c