This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
eliminate cx->blk_sub.oldcomppad
authorDavid Mitchell <davem@iabyn.com>
Mon, 29 Jun 2015 11:02:18 +0000 (12:02 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:33 +0000 (08:59 +0000)
In the CXt_SUB sub-struct of the context struct, there is a field
called oldcomppad. Despite the "old" in its name, this field actually
stores the value of PL_comppad of the new sub, not of the caller.

It's only use currently is in POPSUB() when abandoning a reified @_, to
locate PL_curpad[0] of the current sub in order to stick a new empty AV
there.  This is a relatively rare occurrence, and the pad slot can be
found (slightly less efficiently) from the saved CV and its depth.

cop.h
pp_ctl.c
pp_hot.c
pp_sort.c
sv.c

diff --git a/cop.h b/cop.h
index 9867415..34c21f0 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -556,7 +556,6 @@ struct block_sub {
     AV *       savearray;
     AV *       argarray;
     I32                olddepth;
-    PAD                *oldcomppad; /* the *current* PL_comppad */
     PAD                *prevcomppad; /* the caller's PL_comppad */
 };
 
@@ -662,7 +661,10 @@ struct block_format {
                cx->blk_sub.argarray = newAV();                         \
                av_extend(cx->blk_sub.argarray, fill);                  \
                AvREIFY_only(cx->blk_sub.argarray);                     \
-               CX_CURPAD_SV(cx->blk_sub, 0) = MUTABLE_SV(cx->blk_sub.argarray); \
+                (AvARRAY(MUTABLE_AV(                                    \
+                    PadlistARRAY(CvPADLIST(cx->blk_sub.cv))[            \
+                            CvDEPTH(cx->blk_sub.cv)])))[0] =            \
+                    MUTABLE_SV(cx->blk_sub.argarray);                   \
            }                                                           \
            else {                                                      \
                CLEAR_ARGARRAY(cx->blk_sub.argarray);                   \
index 455b7cf..a89688a 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2844,8 +2844,6 @@ PP(pp_goto)
                PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
                if (CxHASARGS(cx))
                {
-                   CX_CURPAD_SAVE(cx->blk_sub);
-
                    /* cx->blk_sub.argarray has no reference count, so we
                       need something to hang on to our argument array so
                       that cx->blk_sub.argarray does not end up pointing
index 5b9c8a4..c7dfca1 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3490,7 +3490,6 @@ PP(pp_entersub)
            defavp = &GvAV(PL_defgv);
            cx->blk_sub.savearray = *defavp;
            *defavp = MUTABLE_AV(SvREFCNT_inc_simple_NN(av));
-           CX_CURPAD_SAVE(cx->blk_sub);
            cx->blk_sub.argarray = av;
             items = SP - MARK;
 
index ff76478..73f520d 100644 (file)
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1688,7 +1688,6 @@ PP(pp_sort)
 
                        cx->blk_sub.savearray = GvAV(PL_defgv);
                        GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
-                       CX_CURPAD_SAVE(cx->blk_sub);
                        cx->blk_sub.argarray = av;
                    }
 
diff --git a/sv.c b/sv.c
index 94f23ea..ac64dfb 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13950,8 +13950,6 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param)
                    ncx->blk_sub.argarray = NULL;
                    ncx->blk_sub.savearray = NULL;
                }
-               ncx->blk_sub.oldcomppad = (PAD*)ptr_table_fetch(PL_ptr_table,
-                                          ncx->blk_sub.oldcomppad);
                ncx->blk_sub.prevcomppad = (PAD*)ptr_table_fetch(PL_ptr_table,
                                           ncx->blk_sub.prevcomppad);
                break;