X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/4df352a81ba92beb6467d6dafdf988d8aba963c4..c8321e06185aa02d661de31e6bb8bf811e513fab:/pp_sort.c diff --git a/pp_sort.c b/pp_sort.c index 3bd9f2a..c91aab0 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -1476,7 +1476,7 @@ PP(pp_sort) AV* av = NULL; GV *gv; CV *cv = NULL; - I32 gimme = GIMME_V; + U8 gimme = GIMME_V; OP* const nextop = PL_op->op_next; I32 overloading = 0; bool hasargs = FALSE; @@ -1668,17 +1668,15 @@ PP(pp_sort) } gimme = G_SCALAR; - PUSHBLOCK(cx, CXt_NULL, PL_stack_base); + cx = cx_pushblock(CXt_NULL, gimme, PL_stack_base, old_savestack_ix); if (!(flags & OPf_SPECIAL)) { - cx->cx_type = CXt_SUB; - PUSHSUB(cx); + cx->cx_type = CXt_SUB|CXp_MULTICALL; + cx_pushsub(cx, cv, NULL, hasargs); if (!is_xsub) { PADLIST * const padlist = CvPADLIST(cv); - if (++CvDEPTH(cv) >= 2) { - PERL_STACK_OVERFLOW_CHECK(); + if (++CvDEPTH(cv) >= 2) pad_push(padlist, CvDEPTH(cv)); - } PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv)); if (hasargs) { @@ -1691,37 +1689,28 @@ PP(pp_sort) } } - else { - /* mimic PUSHSUB. Note that we're cheating and using a - * CXt_NULL block as a CXt_SUB block */ - cx->cx_u.cx_blk.blku_old_tmpsfloor = PL_tmps_floor; - PL_tmps_floor = PL_tmps_ix; - } - cx->cx_u.cx_blk.blku_old_savestack_ix = old_savestack_ix; - cx->cx_type |= CXp_MULTICALL; - start = p1 - max; sortsvp(aTHX_ start, max, (is_xsub ? S_sortcv_xsub : hasargs ? S_sortcv_stacked : S_sortcv), sort_flags); /* Reset cx, in case the context stack has been reallocated. */ - cx = &cxstack[cxstack_ix]; + cx = CX_CUR(); PL_stack_sp = PL_stack_base + cx->blk_oldsp; + CX_LEAVE_SCOPE(cx); if (!(flags & OPf_SPECIAL)) { assert(CxTYPE(cx) == CXt_SUB); - POPSUB(cx); + cx_popsub(cx); } else assert(CxTYPE(cx) == CXt_NULL); - /* mimic POPSUB */ - PL_tmps_floor = cx->cx_u.cx_blk.blku_old_tmpsfloor; + /* there isn't a POPNULL ! */ - POPBLOCK(cx,PL_curpm); - cxstack_ix--; + cx_popblock(cx); + CX_POP(cx); POPSTACK; CATCH_SET(oldcatch); } @@ -1781,7 +1770,6 @@ static I32 S_sortcv(pTHX_ SV *const a, SV *const b) { const I32 oldsaveix = PL_savestack_ix; - const I32 oldscopeix = PL_scopestack_ix; I32 result; PMOP * const pm = PL_curpm; COP * const cop = PL_curcop; @@ -1799,10 +1787,7 @@ S_sortcv(pTHX_ SV *const a, SV *const b) assert(PL_stack_sp > PL_stack_base || *PL_stack_base == &PL_sv_undef); result = SvIV(*PL_stack_sp); - while (PL_scopestack_ix > oldscopeix) { - LEAVE; - } - leave_scope(oldsaveix); + LEAVE_SCOPE(oldsaveix); PL_curpm = pm; return result; } @@ -1811,7 +1796,6 @@ static I32 S_sortcv_stacked(pTHX_ SV *const a, SV *const b) { const I32 oldsaveix = PL_savestack_ix; - const I32 oldscopeix = PL_scopestack_ix; I32 result; AV * const av = GvAV(PL_defgv); PMOP * const pm = PL_curpm; @@ -1850,10 +1834,7 @@ S_sortcv_stacked(pTHX_ SV *const a, SV *const b) assert(PL_stack_sp > PL_stack_base || *PL_stack_base == &PL_sv_undef); result = SvIV(*PL_stack_sp); - while (PL_scopestack_ix > oldscopeix) { - LEAVE; - } - leave_scope(oldsaveix); + LEAVE_SCOPE(oldsaveix); PL_curpm = pm; return result; } @@ -1863,7 +1844,6 @@ S_sortcv_xsub(pTHX_ SV *const a, SV *const b) { dSP; const I32 oldsaveix = PL_savestack_ix; - const I32 oldscopeix = PL_scopestack_ix; CV * const cv=MUTABLE_CV(PL_sortcop); I32 result; PMOP * const pm = PL_curpm; @@ -1882,10 +1862,7 @@ S_sortcv_xsub(pTHX_ SV *const a, SV *const b) assert(PL_stack_sp > PL_stack_base || *PL_stack_base == &PL_sv_undef); result = SvIV(*PL_stack_sp); - while (PL_scopestack_ix > oldscopeix) { - LEAVE; - } - leave_scope(oldsaveix); + LEAVE_SCOPE(oldsaveix); PL_curpm = pm; return result; }