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.
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(); \
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);
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
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
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
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
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);
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)
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,
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;
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;
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) ))
PP(pp_padhv)
{
dSP; dTARGET;
- I32 gimme;
+ U8 gimme;
assert(SvTYPE(TARG) == SVt_PVHV);
XPUSHs(TARG);
{
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)++;
{
dSP;
AV *array = MUTABLE_AV(POPs);
- const I32 gimme = GIMME_V;
+ const U8 gimme = GIMME_V;
*Perl_av_iter_p(aTHX_ array) = 0;
dSP;
HV * hash = MUTABLE_HV(POPs);
HE *entry;
- const I32 gimme = GIMME_V;
+ const U8 gimme = GIMME_V;
entry = hv_iternext(hash);
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);
PP(pp_delete)
{
dSP;
- I32 gimme;
+ U8 gimme;
I32 discard;
if (PL_op->op_private & OPpLVAL_INTRO)
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;
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 \
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;
-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);
SV *namesv = NULL;
PERL_CONTEXT *cx;
SV **oldsp;
- I32 gimme;
+ U8 gimme;
JMPENV *restartjmpenv;
OP *restartop;
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;
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
{
dSP;
PERL_CONTEXT *cx;
- const I32 gimme = G_ARRAY;
+ const U8 gimme = G_ARRAY;
GV * const gv = PL_DBgv;
CV * cv = NULL;
PP(pp_enter)
{
dSP;
- I32 gimme = GIMME_V;
+ U8 gimme = GIMME_V;
(void)cx_pushblock(CXt_BLOCK, gimme, SP, PL_savestack_ix);
{
PERL_CONTEXT *cx;
SV **oldsp;
- I32 gimme;
+ U8 gimme;
cx = CX_CUR();
assert(CxTYPE(cx) == CXt_BLOCK);
{
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;
{
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);
PP(pp_leaveloop)
{
PERL_CONTEXT *cx;
- I32 gimme;
+ U8 gimme;
SV **oldsp;
SV **mark;
PP(pp_leavesublv)
{
- I32 gimme;
+ U8 gimme;
PERL_CONTEXT *cx;
SV **oldsp;
OP *retop;
*/
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;
#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;
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;
PP(pp_leaveeval)
{
SV **oldsp;
- I32 gimme;
+ U8 gimme;
PERL_CONTEXT *cx;
OP *retop;
SV *namesv = NULL;
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);
PP(pp_leavetry)
{
SV **oldsp;
- I32 gimme;
+ U8 gimme;
PERL_CONTEXT *cx;
OP *retop;
{
dSP;
PERL_CONTEXT *cx;
- const I32 gimme = GIMME_V;
+ const U8 gimme = GIMME_V;
SV *origsv = DEFSV;
SV *newsv = POPs;
PP(pp_leavegiven)
{
PERL_CONTEXT *cx;
- I32 gimme;
+ U8 gimme;
SV **oldsp;
PERL_UNUSED_CONTEXT;
{
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
{
I32 cxix;
PERL_CONTEXT *cx;
- I32 gimme;
+ U8 gimme;
SV **oldsp;
cx = CX_CUR();
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
SV *sv;
AV *ary;
- I32 gimme;
+ U8 gimme;
HV *hash;
SSize_t i;
int magic;
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;
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);
/* 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 */
*/
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;
PP(pp_leavesub)
{
- I32 gimme;
+ U8 gimme;
PERL_CONTEXT *cx;
SV **oldsp;
OP *retop;
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
{
dSP;
dPOPPOPssrl;
- I32 gimme = GIMME_V;
+ U8 gimme = GIMME_V;
STRLEN llen;
STRLEN rlen;
const char *pat = SvPV_const(left, llen);
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;
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("``");
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;
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;
dSP;
GV *gv = NULL;
IO *io = NULL;
- I32 gimme;
+ U8 gimme;
I32 max = 13;
SV* sv;
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);
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)
#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);
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);
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 \
*/
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 */
{
dXSARGS;
REGEXP *re;
- I32 const gimme = GIMME_V;
+ U8 const gimme = GIMME_V;
EXTEND(SP, 2);
SP -= items;