diff options
author | David Mitchell <davem@iabyn.com> | 2016-01-04 09:16:52 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-02-03 09:19:21 +0000 |
commit | 1c23e2bdad29ff1daf6392412fffae9341795834 (patch) | |
tree | 2870d0000ec000d13e363c8a74ed81f224e261fa | |
parent | 263e0548e81a5558c883eb43d9a72c5f20f67741 (diff) | |
download | perl-1c23e2bdad29ff1daf6392412fffae9341795834.tar.gz |
make gimme consistently U8
The value of gimme stored in the context stack is U8.
Make all other uses in the main core consistent with this.
My primary motivation on this was that the new function cx_pushblock(),
which I gave a 'U8 gimme' parameter, was generating warnings where callers
were passing I32 gimme vars to it. Rather than play whack-a-mole, it
seemed simpler to just uniformly use U8 everywhere.
Porting/bench.pl shows a consistent reduction of about 2 instructions on
the loop and sub benchmarks, so this change isn't harming performance.
-rw-r--r-- | cop.h | 2 | ||||
-rw-r--r-- | doop.c | 2 | ||||
-rw-r--r-- | embed.fnc | 8 | ||||
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | pod/perlcall.pod | 4 | ||||
-rw-r--r-- | pod/perlguts.pod | 4 | ||||
-rw-r--r-- | pp.c | 16 | ||||
-rw-r--r-- | pp.h | 2 | ||||
-rw-r--r-- | pp_ctl.c | 48 | ||||
-rw-r--r-- | pp_hot.c | 16 | ||||
-rw-r--r-- | pp_pack.c | 2 | ||||
-rw-r--r-- | pp_sort.c | 2 | ||||
-rw-r--r-- | pp_sys.c | 10 | ||||
-rw-r--r-- | proto.h | 8 | ||||
-rw-r--r-- | regexec.c | 2 | ||||
-rw-r--r-- | universal.c | 2 |
16 files changed, 65 insertions, 65 deletions
@@ -1100,7 +1100,7 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>. multicall_oldcatch = CATCH_GET; \ CATCH_SET(TRUE); \ PUSHSTACKi(PERLSI_MULTICALL); \ - cx = cx_pushblock((CXt_SUB|CXp_MULTICALL|flags), gimme, \ + cx = cx_pushblock((CXt_SUB|CXp_MULTICALL|flags), (U8)gimme, \ PL_stack_sp, PL_savestack_ix); \ cx_pushsub(cx, cv, NULL, 0); \ SAVEOP(); \ @@ -1238,7 +1238,7 @@ Perl_do_kv(pTHX) HV * const keys = MUTABLE_HV(POPs); HE *entry; SSize_t extend_size; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; const I32 dokv = (PL_op->op_type == OP_RV2HV || PL_op->op_type == OP_PADHV); /* op_type is OP_RKEYS/OP_RVALUES if pp_rkeys delegated to here */ const I32 dokeys = dokv || (PL_op->op_type == OP_KEYS); @@ -247,7 +247,7 @@ s |MAGIC* |get_aux_mg |NN AV *av pR |OP* |bind_match |I32 type|NN OP *left|NN OP *right : Used in perly.y ApdR |OP* |block_end |I32 floor|NULLOK OP* seq -ApR |I32 |block_gimme +ApR |U8 |block_gimme : Used in perly.y ApdR |int |block_start |int full Aodp |void |blockhook_register |NN BHK *hk @@ -443,7 +443,7 @@ p |void |do_vecset |NN SV* sv p |void |do_vop |I32 optype|NN SV* sv|NN SV* left|NN SV* right : Used in perly.y p |OP* |dofile |NN OP* term|I32 force_builtin -ApR |I32 |dowantarray +ApR |U8 |dowantarray Ap |void |dump_all p |void |dump_all_perl |bool justperl Ap |void |dump_eval @@ -2068,7 +2068,7 @@ sR |I32 |dopoptoloop |I32 startingblock sR |I32 |dopoptosub_at |NN const PERL_CONTEXT* cxstk|I32 startingblock sR |I32 |dopoptowhen |I32 startingblock s |void |save_lines |NULLOK AV *array|NN SV *sv -s |bool |doeval_compile |int gimme \ +s |bool |doeval_compile |U8 gimme \ |NULLOK CV* outside|U32 seq|NULLOK HV* hh sR |PerlIO *|check_type_and_open|NN SV *name #ifndef PERL_DISABLE_PMC @@ -2878,7 +2878,7 @@ EMpPX |SV* |_get_encoding Ap |void |clear_defarray |NN AV* av|bool abandon ApM |void |leave_adjust_stacks|NN SV **from_sp|NN SV **to_sp \ - |I32 gimme|int filter + |U8 gimme|int filter #ifndef PERL_NO_INLINE_FUNCTIONS AiM |PERL_CONTEXT * |cx_pushblock|U8 type|U8 gimme|NN SV** sp|I32 saveix @@ -3368,7 +3368,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) SV* res; const bool oldcatch = CATCH_GET; I32 oldmark, nret; - int gimme = force_scalar ? G_SCALAR : GIMME_V; + U8 gimme = force_scalar ? G_SCALAR : GIMME_V; CATCH_SET(TRUE); Zero(&myop, 1, BINOP); diff --git a/pod/perlcall.pod b/pod/perlcall.pod index 327e253346..c405153945 100644 --- a/pod/perlcall.pod +++ b/pod/perlcall.pod @@ -1339,7 +1339,7 @@ currently executing. void PrintContext() CODE: - I32 gimme = GIMME_V; + U8 gimme = GIMME_V; if (gimme == G_VOID) printf ("Context is Void\n"); else if (gimme == G_SCALAR) @@ -1947,7 +1947,7 @@ it. It's also inherently slower.) The pattern of macro calls is like this: dMULTICALL; /* Declare local variables */ - I32 gimme = G_SCALAR; /* context of the call: G_SCALAR, + U8 gimme = G_SCALAR; /* context of the call: G_SCALAR, * G_ARRAY, or G_VOID */ PUSH_MULTICALL(cv); /* Set up the context for calling cv, diff --git a/pod/perlguts.pod b/pod/perlguts.pod index 76c919f666..94cfadb8ed 100644 --- a/pod/perlguts.pod +++ b/pod/perlguts.pod @@ -3234,7 +3234,7 @@ following shows a simplified and stripped-down example of a non-XS call, along with comments showing roughly what each function does. dMARK; - I32 gimme = GIMME_V; + U8 gimme = GIMME_V; bool hasargs = cBOOL(PL_op->op_flags & OPf_STACKED); OP *retop = PL_op->op_next; I32 old_ss_ix = PL_savestack_ix; @@ -3342,7 +3342,7 @@ is capable of processing and popping all contexts above the target one. Here is a typical example of context popping, as found in C<pp_leavesub> (simplified slightly): - I32 gimme; + U8 gimme; PERL_CONTEXT *cx; SV **oldsp; OP *retop; @@ -66,7 +66,7 @@ PP(pp_stub) PP(pp_padav) { dSP; dTARGET; - I32 gimme; + U8 gimme; assert(SvTYPE(TARG) == SVt_PVAV); if (UNLIKELY( PL_op->op_private & OPpLVAL_INTRO )) if (LIKELY( !(PL_op->op_private & OPpPAD_STATE) )) @@ -121,7 +121,7 @@ PP(pp_padav) PP(pp_padhv) { dSP; dTARGET; - I32 gimme; + U8 gimme; assert(SvTYPE(TARG) == SVt_PVHV); XPUSHs(TARG); @@ -4855,7 +4855,7 @@ PP(pp_aeach) { dSP; AV *array = MUTABLE_AV(POPs); - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; IV *iterp = Perl_av_iter_p(aTHX_ array); const IV current = (*iterp)++; @@ -4881,7 +4881,7 @@ PP(pp_akeys) { dSP; AV *array = MUTABLE_AV(POPs); - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; *Perl_av_iter_p(aTHX_ array) = 0; @@ -4917,7 +4917,7 @@ PP(pp_each) dSP; HV * hash = MUTABLE_HV(POPs); HE *entry; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; entry = hv_iternext(hash); @@ -4941,7 +4941,7 @@ STATIC OP * S_do_delete_local(pTHX) { dSP; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; const MAGIC *mg; HV *stash; const bool sliced = !!(PL_op->op_private & OPpSLICE); @@ -5051,7 +5051,7 @@ S_do_delete_local(pTHX) PP(pp_delete) { dSP; - I32 gimme; + U8 gimme; I32 discard; if (PL_op->op_private & OPpLVAL_INTRO) @@ -5854,7 +5854,7 @@ PP(pp_split) const IV origlimit = limit; I32 realarray = 0; I32 base; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; bool gimme_scalar; const I32 oldsave = PL_savestack_ix; U32 make_mortal = SVs_TEMP; @@ -581,7 +581,7 @@ Does not use C<TARG>. See also C<L</XPUSHu>>, C<L</mPUSHu>> and C<L</PUSHu>>. dSP; \ SV *tmpsv; \ SV *arg= *sp; \ - int gimme = GIMME_V; \ + U8 gimme = GIMME_V; \ if (UNLIKELY(SvAMAGIC(arg) && \ (tmpsv = amagic_call(arg, &PL_sv_undef, meth, \ AMGf_want_list | AMGf_noright \ @@ -965,7 +965,7 @@ PP(pp_grepstart) PP(pp_mapwhile) { dSP; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; I32 items = (SP - PL_stack_base) - TOPMARK; /* how many new items */ I32 count; I32 shift; @@ -1332,14 +1332,14 @@ S_dopoptolabel(pTHX_ const char *label, STRLEN len, U32 flags) -I32 +U8 Perl_dowantarray(pTHX) { - const I32 gimme = block_gimme(); + const U8 gimme = block_gimme(); return (gimme == G_VOID) ? G_SCALAR : gimme; } -I32 +U8 Perl_block_gimme(pTHX) { const I32 cxix = dopoptosub(cxstack_ix); @@ -1674,7 +1674,7 @@ Perl_die_unwind(pTHX_ SV *msv) SV *namesv = NULL; PERL_CONTEXT *cx; SV **oldsp; - I32 gimme; + U8 gimme; JMPENV *restartjmpenv; OP *restartop; @@ -1800,7 +1800,7 @@ PP(pp_caller) dSP; const PERL_CONTEXT *cx; const PERL_CONTEXT *dbcx; - I32 gimme = GIMME_V; + U8 gimme = GIMME_V; const HEK *stash_hek; I32 count = 0; bool has_arg = MAXARG && TOPs; @@ -1870,7 +1870,7 @@ PP(pp_caller) PUSHs(newSVpvs_flags("(eval)", SVs_TEMP)); mPUSHi(0); } - gimme = (I32)cx->blk_gimme; + gimme = cx->blk_gimme; if (gimme == G_VOID) PUSHs(&PL_sv_undef); else @@ -1984,7 +1984,7 @@ PP(pp_dbstate) { dSP; PERL_CONTEXT *cx; - const I32 gimme = G_ARRAY; + const U8 gimme = G_ARRAY; GV * const gv = PL_DBgv; CV * cv = NULL; @@ -2036,7 +2036,7 @@ PP(pp_dbstate) PP(pp_enter) { dSP; - I32 gimme = GIMME_V; + U8 gimme = GIMME_V; (void)cx_pushblock(CXt_BLOCK, gimme, SP, PL_savestack_ix); @@ -2047,7 +2047,7 @@ PP(pp_leave) { PERL_CONTEXT *cx; SV **oldsp; - I32 gimme; + U8 gimme; cx = CX_CUR(); assert(CxTYPE(cx) == CXt_BLOCK); @@ -2097,7 +2097,7 @@ PP(pp_enteriter) { dSP; dMARK; PERL_CONTEXT *cx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; void *itervarp; /* GV or pad slot of the iteration variable */ SV *itersave; /* the old var in the iterator var slot */ U8 cxflags = 0; @@ -2214,7 +2214,7 @@ PP(pp_enterloop) { dSP; PERL_CONTEXT *cx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; cx = cx_pushblock(CXt_LOOP_PLAIN, gimme, SP, PL_savestack_ix); cx_pushloop_plain(cx); @@ -2225,7 +2225,7 @@ PP(pp_enterloop) PP(pp_leaveloop) { PERL_CONTEXT *cx; - I32 gimme; + U8 gimme; SV **oldsp; SV **mark; @@ -2262,7 +2262,7 @@ PP(pp_leaveloop) PP(pp_leavesublv) { - I32 gimme; + U8 gimme; PERL_CONTEXT *cx; SV **oldsp; OP *retop; @@ -3260,7 +3260,7 @@ S_try_yyparse(pTHX_ int gramtype) */ STATIC bool -S_doeval_compile(pTHX_ int gimme, CV* outside, U32 seq, HV *hh) +S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) { dSP; OP * const saveop = PL_op; @@ -3600,7 +3600,7 @@ PP(pp_require) #endif const char *tryname = NULL; SV *namesv = NULL; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; int filter_has_file = 0; PerlIO *tryrsfp = NULL; SV *filter_cache = NULL; @@ -4080,7 +4080,7 @@ PP(pp_entereval) dSP; PERL_CONTEXT *cx; SV *sv; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; const U32 was = PL_breakable_sub_gen; char tbuf[TYPE_DIGITS(long) + 12]; bool saved_delete = FALSE; @@ -4206,7 +4206,7 @@ PP(pp_entereval) PP(pp_leaveeval) { SV **oldsp; - I32 gimme; + U8 gimme; PERL_CONTEXT *cx; OP *retop; SV *namesv = NULL; @@ -4287,7 +4287,7 @@ void Perl_create_eval_scope(pTHX_ OP *retop, U32 flags) { PERL_CONTEXT *cx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; cx = cx_pushblock((CXt_EVAL|CXp_TRYBLOCK), gimme, PL_stack_sp, PL_savestack_ix); @@ -4312,7 +4312,7 @@ PP(pp_entertry) PP(pp_leavetry) { SV **oldsp; - I32 gimme; + U8 gimme; PERL_CONTEXT *cx; OP *retop; @@ -4341,7 +4341,7 @@ PP(pp_entergiven) { dSP; PERL_CONTEXT *cx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; SV *origsv = DEFSV; SV *newsv = POPs; @@ -4357,7 +4357,7 @@ PP(pp_entergiven) PP(pp_leavegiven) { PERL_CONTEXT *cx; - I32 gimme; + U8 gimme; SV **oldsp; PERL_UNUSED_CONTEXT; @@ -4917,7 +4917,7 @@ PP(pp_enterwhen) { dSP; PERL_CONTEXT *cx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; /* This is essentially an optimization: if the match fails, we don't want to push a context and then @@ -4938,7 +4938,7 @@ PP(pp_leavewhen) { I32 cxix; PERL_CONTEXT *cx; - I32 gimme; + U8 gimme; SV **oldsp; cx = CX_CUR(); @@ -963,7 +963,7 @@ PP(pp_print) PP(pp_rv2av) { dSP; dTOPss; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; static const char an_array[] = "an ARRAY"; static const char a_hash[] = "a HASH"; const bool is_pp_rv2av = PL_op->op_type == OP_RV2AV @@ -1251,7 +1251,7 @@ PP(pp_aassign) SV *sv; AV *ary; - I32 gimme; + U8 gimme; HV *hash; SSize_t i; int magic; @@ -1716,7 +1716,7 @@ PP(pp_match) const char *truebase; /* Start of string */ REGEXP *rx = PM_GETRE(pm); bool rxtainted; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; STRLEN len; const I32 oldsave = PL_savestack_ix; I32 had_zerolen = 0; @@ -1908,7 +1908,7 @@ Perl_do_readline(pTHX) PerlIO *fp; IO * const io = GvIO(PL_last_in_gv); const I32 type = PL_op->op_type; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; if (io) { const MAGIC *const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); @@ -3268,7 +3268,7 @@ PP(pp_grepwhile) /* All done yet? */ if (UNLIKELY(PL_stack_base + *PL_markstack_ptr > SP)) { I32 items; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; LEAVE_with_name("grep"); /* exit outer scope */ (void)POPMARK; /* pop src */ @@ -3362,7 +3362,7 @@ PP(pp_grepwhile) */ void -Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, I32 gimme, int pass) +Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, U8 gimme, int pass) { dVAR; dSP; @@ -3616,7 +3616,7 @@ Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, I32 gimme, int pass) PP(pp_leavesub) { - I32 gimme; + U8 gimme; PERL_CONTEXT *cx; SV **oldsp; OP *retop; @@ -3833,7 +3833,7 @@ PP(pp_entersub) PADLIST *padlist; I32 depth; bool hasargs; - I32 gimme; + U8 gimme; /* keep PADTMP args alive throughout the call (we need to do this * because @_ isn't refcounted). Note that we create the mortals @@ -1826,7 +1826,7 @@ PP(pp_unpack) { dSP; dPOPPOPssrl; - I32 gimme = GIMME_V; + U8 gimme = GIMME_V; STRLEN llen; STRLEN rlen; const char *pat = SvPV_const(left, llen); @@ -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; @@ -297,7 +297,7 @@ PP(pp_backtick) dSP; dTARGET; PerlIO *fp; const char * const tmps = POPpconstx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; const char *mode = "r"; TAINT_PROPER("``"); @@ -1345,7 +1345,7 @@ PP(pp_getc) if (io) { const MAGIC * const mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar); if (mg) { - const U32 gimme = GIMME_V; + const U8 gimme = GIMME_V; Perl_tied_method(aTHX_ SV_CONST(GETC), SP, MUTABLE_SV(io), mg, gimme, 0); if (gimme == G_SCALAR) { SPAGAIN; @@ -1382,7 +1382,7 @@ STATIC OP * S_doform(pTHX_ CV *cv, GV *gv, OP *retop) { PERL_CONTEXT *cx; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; PERL_ARGS_ASSERT_DOFORM; @@ -2870,7 +2870,7 @@ PP(pp_stat) dSP; GV *gv = NULL; IO *io = NULL; - I32 gimme; + U8 gimme; I32 max = 13; SV* sv; @@ -4026,7 +4026,7 @@ PP(pp_readdir) dSP; SV *sv; - const I32 gimme = GIMME_V; + const U8 gimme = GIMME_V; GV * const gv = MUTABLE_GV(POPs); const Direntry_t *dp; IO * const io = GvIOn(gv); @@ -206,7 +206,7 @@ PERL_CALLCONV OP* Perl_bind_match(pTHX_ I32 type, OP *left, OP *right) PERL_CALLCONV OP* Perl_block_end(pTHX_ I32 floor, OP* seq) __attribute__warn_unused_result__; -PERL_CALLCONV I32 Perl_block_gimme(pTHX) +PERL_CALLCONV U8 Perl_block_gimme(pTHX) __attribute__warn_unused_result__; PERL_CALLCONV int Perl_block_start(pTHX_ int full) @@ -775,7 +775,7 @@ PERL_CALLCONV OP * Perl_doref(pTHX_ OP *o, I32 type, bool set_op_ref); #define PERL_ARGS_ASSERT_DOREF \ assert(o) PERL_CALLCONV void Perl_dounwind(pTHX_ I32 cxix); -PERL_CALLCONV I32 Perl_dowantarray(pTHX) +PERL_CALLCONV U8 Perl_dowantarray(pTHX) __attribute__warn_unused_result__; PERL_CALLCONV void Perl_drand48_init_r(perl_drand48_t *random_state, U32 seed); @@ -1610,7 +1610,7 @@ PERL_CALLCONV I32 Perl_keyword(pTHX_ const char *name, I32 len, bool all_keyword PERL_CALLCONV int Perl_keyword_plugin_standard(pTHX_ char* keyword_ptr, STRLEN keyword_len, OP** op_ptr); #define PERL_ARGS_ASSERT_KEYWORD_PLUGIN_STANDARD \ assert(keyword_ptr); assert(op_ptr) -PERL_CALLCONV void Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, I32 gimme, int filter); +PERL_CALLCONV void Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, U8 gimme, int filter); #define PERL_ARGS_ASSERT_LEAVE_ADJUST_STACKS \ assert(from_sp); assert(to_sp) PERL_CALLCONV void Perl_leave_scope(pTHX_ I32 base); @@ -4531,7 +4531,7 @@ STATIC OP* S_do_smartmatch(pTHX_ HV* seen_this, HV* seen_other, const bool copie STATIC OP* S_docatch(pTHX_ OP *o) __attribute__warn_unused_result__; -STATIC bool S_doeval_compile(pTHX_ int gimme, CV* outside, U32 seq, HV* hh); +STATIC bool S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV* hh); STATIC OP* S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstack, OP **oplimit) __attribute__warn_unused_result__; #define PERL_ARGS_ASSERT_DOFINDLABEL \ @@ -5177,7 +5177,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog) */ PAD* last_pad = NULL; dMULTICALL; - I32 gimme = G_SCALAR; + U8 gimme = G_SCALAR; CV *caller_cv = NULL; /* who called us */ CV *last_pushed_cv = NULL; /* most recently called (?{}) CV */ CHECKPOINT runops_cp; /* savestack position before executing EVAL */ diff --git a/universal.c b/universal.c index 3217d33280..31a53cc0b5 100644 --- a/universal.c +++ b/universal.c @@ -898,7 +898,7 @@ XS(XS_re_regexp_pattern) { dXSARGS; REGEXP *re; - I32 const gimme = GIMME_V; + U8 const gimme = GIMME_V; EXTEND(SP, 2); SP -= items; |