X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Upper.xs;h=450945a184be2cc46baad9598cbd4bb5d47eccc1;hb=eef3f2764e7018e3eaf2f1d11f249b510d023a2d;hp=f1a3e2491b8a13ff1dd59bc49ce625a695c3831e;hpb=4229b39e5533bbe91f1c56d47401b8602ed62dbc;p=perl%2Fmodules%2FScope-Upper.git diff --git a/Upper.xs b/Upper.xs index f1a3e24..450945a 100644 --- a/Upper.xs +++ b/Upper.xs @@ -653,9 +653,9 @@ static void su_save_helem(pTHX_ HV *hv, SV *keysv, SV *val) { return; } - if (preeminent) + if (preeminent) { save_helem(hv, keysv, svp); - else { + } else { STRLEN keylen; const char * const key = SvPV_const(keysv, keylen); SAVEDELETE(hv, savepvn(key, keylen), @@ -938,15 +938,17 @@ static void su_localize(pTHX_ void *ud_) { if (elem) { su_save_aelem(GvAV(gv), elem, val); return; - } else + } else { save_ary(gv); + } break; case SVt_PVHV: if (elem) { su_save_helem(GvHV(gv), elem, val); return; - } else + } else { save_hash(gv); + } break; case SVt_PVGV: save_gp(gv, 1); /* hide previous entry in symtab */ @@ -1050,6 +1052,8 @@ static const char *su_block_type[] = { #define SU_CXNAME(C) SU_CX_TYPENAME(CxTYPE(C)) +#if XSH_DEBUG + /* for debugging. These indicate how many ENTERs each context type * does before the PUSHBLOCK */ @@ -1069,9 +1073,12 @@ static const int su_cxt_enter_count[] = { # endif }; +#endif /* XSH_DEBUG */ + /* push at least 'size' slots worth of padding onto the savestack */ static void su_ss_push_padding(pTHX_ void *ud, I32 size) { +#define su_ss_push_padding(U, S) su_ss_push_padding(aTHX_ (U), (S)) if (size <= 0) return; if (size < SU_SAVE_ALLOC_SIZE + 1) /* minimum possible SAVEt_ALLOC */ @@ -1088,10 +1095,11 @@ static void su_pop(pTHX_ void *ud); * first indicates that this is the first push of a destructor */ static void su_ss_push_destructor(pTHX_ void *ud, I32 depth, bool first) { +#define su_ss_push_destructor(U, D, F) su_ss_push_destructor(aTHX_ (U), (D), (F)) su_ud_origin_elem *origin = SU_UD_ORIGIN(ud); assert(first || origin[depth+1].orig_ix == PL_savestack_ix); - su_ss_push_padding(aTHX_ ud, + su_ss_push_padding(ud, (origin[depth].orig_ix + origin[depth].offset) - PL_savestack_ix); XSH_D(su_debug_log( "%p: push destructor at save_ix=%d depth=%d scope_ix=%d\n", @@ -1129,7 +1137,7 @@ static void su_pop(pTHX_ void *ud) { SU_UD_DEPTH(ud) = depth; if (depth > 0) { - su_ss_push_destructor(aTHX_ ud, depth-1, 0); + su_ss_push_destructor(ud, depth-1, 0); } else { I32 offset = origin[0].offset; /* grab value before origin is freed */ switch (SU_UD_TYPE(ud)) { @@ -1153,7 +1161,7 @@ static void su_pop(pTHX_ void *ud) { if (PL_savestack_ix < base + offset) { I32 gap = (base + offset) - PL_savestack_ix; assert(gap >= SU_SAVE_ALLOC_SIZE + 1); - su_ss_push_padding(aTHX_ ud, gap); + su_ss_push_padding(ud, gap); } assert(PL_savestack_ix == base + offset); } @@ -1263,9 +1271,9 @@ static void su_init(pTHX_ void *ud, I32 cxix, I32 size) { #endif - if (i == 0) + if (i == 0) { offset = size; - else { + } else { /* we have three constraints to satisfy: * 1) Each adjusted offset must be at least SU_SAVE_DESTRUCTOR_SIZE * above its unadjusted boundary, so that there is space to inject a @@ -1318,7 +1326,7 @@ static void su_init(pTHX_ void *ud, I32 cxix, I32 size) { SU_UD_DEPTH(ud) = depth; SU_UD_ORIGIN(ud) = origin; - su_ss_push_destructor(aTHX_ ud, depth-1, 1); + su_ss_push_destructor(ud, depth-1, 1); } /* --- Unwind stack -------------------------------------------------------- */ @@ -1388,8 +1396,6 @@ static void su_yield(pTHX_ void *ud_) { U8 flags = 0; OP *next; - PERL_UNUSED_VAR(ud_); - cx = cxstack + cxix; switch (CxTYPE(cx)) { case CXt_BLOCK: { @@ -2016,6 +2022,7 @@ static int su_uplevel_runops_hook_entersub(pTHX) { } static I32 su_uplevel_new(pTHX_ CV *callback, I32 cxix, I32 args) { +#define su_uplevel_new(CB, CX, A) su_uplevel_new(aTHX_ (CB), (CX), (A)) su_uplevel_ud *sud; U8 *saved_cxtypes; I32 i, ret; @@ -2085,6 +2092,7 @@ static I32 su_uplevel_new(pTHX_ CV *callback, I32 cxix, I32 args) { #else static I32 su_uplevel_old(pTHX_ CV *callback, I32 cxix, I32 args) { +#define su_uplevel_old(CB, CX, A) su_uplevel_old(aTHX_ (CB), (CX), (A)) su_uplevel_ud *sud; const PERL_CONTEXT *cx = cxstack + cxix; PERL_SI *si; @@ -3243,9 +3251,9 @@ PPCODE: } /* su_uplevel() takes care of extending the stack if needed. */ #if SU_HAS_NEW_CXT - ret = su_uplevel_new(aTHX_ (CV *) code, cxix, args); + ret = su_uplevel_new((CV *) code, cxix, args); #else - ret = su_uplevel_old(aTHX_ (CV *) code, cxix, args); + ret = su_uplevel_old((CV *) code, cxix, args); #endif XSRETURN(ret); default: