Skip to content

Commit

Permalink
dMULTICALL: remove unused vars
Browse files Browse the repository at this point in the history
dMULTICALL declares several vars that are used either to maintain
state across multiple calls, or to pass values to PUSHSUB etc, where
those macros expected to obtain some of their args by values being
implicitly passed via local vars. Since PUSHSUB has been replaced by
cx_pushsub() which now has all parameters explicitly passed, there is
no longer any need for those vars. So this commit eliminates them:

    newsp
    hasargs

There are also a couple vars which are no longer used due to changes to
the implementation over time; these can also be eliminated:

    cx multicall_cv

Finally, this branch introduced a new var, saveix_floor; rename it to
multicall_saveix_floor for consistency with other dMULTICALL vars.

Although none of these vars are listed in the documentation, its possible
that some code out there may rely on them in some way, and will need to be
fixed up.
  • Loading branch information
iabyn committed Feb 3, 2016
1 parent 2a7b7c6 commit 7950309
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 27 deletions.
26 changes: 9 additions & 17 deletions cop.h
Expand Up @@ -1081,13 +1081,9 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
*/

#define dMULTICALL \
SV **newsp; /* set by cx_popblock */ \
PERL_CONTEXT *cx; \
CV *multicall_cv; \
OP *multicall_cop; \
OP *multicall_cop; \
bool multicall_oldcatch; \
I32 saveix_floor; \
U8 hasargs = 0 /* used by CX_PUSHSUB */
I32 multicall_saveix_floor

#define PUSH_MULTICALL(the_cv) \
PUSH_MULTICALL_FLAGS(the_cv, 0)
Expand All @@ -1097,6 +1093,7 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.

#define PUSH_MULTICALL_FLAGS(the_cv, flags) \
STMT_START { \
PERL_CONTEXT *cx; \
CV * const _nOnclAshIngNamE_ = the_cv; \
CV * const cv = _nOnclAshIngNamE_; \
PADLIST * const padlist = CvPADLIST(cv); \
Expand All @@ -1105,35 +1102,31 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
PUSHSTACKi(PERLSI_MULTICALL); \
cx = cx_pushblock((CXt_SUB|CXp_MULTICALL|flags), gimme, \
PL_stack_sp, PL_savestack_ix); \
cx_pushsub(cx, cv, NULL, cBOOL(hasargs)); \
cx_pushsub(cx, cv, NULL, 0); \
SAVEOP(); \
saveix_floor = PL_savestack_ix; \
multicall_saveix_floor = PL_savestack_ix; \
if (!(flags & CXp_SUB_RE_FAKE)) \
CvDEPTH(cv)++; \
if (CvDEPTH(cv) >= 2) \
Perl_pad_push(aTHX_ padlist, CvDEPTH(cv)); \
PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv)); \
multicall_cv = cv; \
PERL_UNUSED_VAR(multicall_cv); /* for API */ \
multicall_cop = CvSTART(cv); \
} STMT_END

#define MULTICALL \
STMT_START { \
PL_op = multicall_cop; \
CALLRUNOPS(aTHX); \
cx = CX_CUR(); \
LEAVE_SCOPE(saveix_floor); \
LEAVE_SCOPE(multicall_saveix_floor); \
} STMT_END

#define POP_MULTICALL \
STMT_START { \
PERL_CONTEXT *cx; \
cx = CX_CUR(); \
CX_LEAVE_SCOPE(cx); \
cx_popsub_common(cx); \
newsp = PL_stack_base + cx->blk_oldsp; \
gimme = cx->blk_gimme; \
PERL_UNUSED_VAR(newsp); /* for API */ \
PERL_UNUSED_VAR(gimme); /* for API */ \
cx_popblock(cx); \
CX_POP(cx); \
Expand All @@ -1150,17 +1143,16 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
CV * const _nOnclAshIngNamE_ = the_cv; \
CV * const cv = _nOnclAshIngNamE_; \
PADLIST * const padlist = CvPADLIST(cv); \
cx = CX_CUR(); \
PERL_CONTEXT *cx = CX_CUR(); \
assert(CxMULTICALL(cx)); \
cx_popsub_common(cx); \
cx->cx_type = (CXt_SUB|CXp_MULTICALL|flags); \
cx_pushsub(cx, cv, NULL, cBOOL(hasargs)); \
cx_pushsub(cx, cv, NULL, 0); \
if (!(flags & CXp_SUB_RE_FAKE)) \
CvDEPTH(cv)++; \
if (CvDEPTH(cv) >= 2) \
Perl_pad_push(aTHX_ padlist, CvDEPTH(cv)); \
PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv)); \
multicall_cv = cv; \
multicall_cop = CvSTART(cv); \
} STMT_END
/*
Expand Down
3 changes: 0 additions & 3 deletions ext/XS-APItest/APItest.xs
Expand Up @@ -3640,7 +3640,6 @@ CODE:
MULTICALL;
}
POP_MULTICALL;
PERL_UNUSED_VAR(newsp);
XSRETURN_UNDEF;
}

Expand Down Expand Up @@ -3698,8 +3697,6 @@ CODE:

POP_MULTICALL;

PERL_UNUSED_VAR(newsp);

size = AvFILLp(av) + 1;
EXTEND(SP, size);
for (i = 0; i < size; i++)
Expand Down
10 changes: 3 additions & 7 deletions regexec.c
Expand Up @@ -5197,11 +5197,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)

/* shut up 'may be used uninitialized' compiler warnings for dMULTICALL */
multicall_oldcatch = 0;
multicall_cv = NULL;
cx = NULL;
PERL_UNUSED_VAR(multicall_cop);
PERL_UNUSED_VAR(newsp);


PERL_ARGS_ASSERT_REGMATCH;

Expand Down Expand Up @@ -6608,7 +6604,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
/* these assignments are just to silence compiler
* warnings */
multicall_cop = NULL;
newsp = NULL;
}
last_pad = PL_comppad;

Expand Down Expand Up @@ -6660,11 +6655,12 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)

/* we don't use MULTICALL here as we want to call the
* first op of the block of interest, rather than the
* first op of the sub */
* first op of the sub. Also, we don't want to free
* the savestack frame */
before = (IV)(SP-PL_stack_base);
PL_op = nop;
CALLRUNOPS(aTHX); /* Scalar context. */
PERL_UNUSED_VAR(saveix_floor); /* used by MULTICALL */
PERL_UNUSED_VAR(multicall_saveix_floor); /* used by MULTICALL */
SPAGAIN;
if ((IV)(SP-PL_stack_base) == before)
ret = &PL_sv_undef; /* protect against empty (?{}) blocks. */
Expand Down

0 comments on commit 7950309

Please sign in to comment.