X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/3107b51fb9c191a2ee82450f00c4568640538e12..00ec60ba0b8283af9a17ca1eddf992ca371f0411:/op.h?ds=sidebyside diff --git a/op.h b/op.h index ceedf35..935e126 100644 --- a/op.h +++ b/op.h @@ -19,19 +19,11 @@ * op_type The type of the operation. * op_opt Whether or not the op has been optimised by the * peephole optimiser. - * - * See the comments in S_clear_yystack() for more - * details on the following three flags: - * - * op_latefree tell op_free() to clear this op (and free any kids) - * but not yet deallocate the struct. This means that - * the op may be safely op_free()d multiple times - * op_latefreed an op_latefree op has been op_free()d - * op_attached this op (sub)tree has been attached to a CV * op_slabbed allocated via opslab + * op_static tell op_free() to skip PerlMemShared_free(), when + * !op_slabbed. * op_savefree on savestack via SAVEFREEOP - * - * op_spare a spare bit! + * op_spare Three spare bits * op_flags Flags common to all operations. See OPf_* below. * op_private Flags peculiar to a particular operation (BUT, * by default, set to the number of children until @@ -61,12 +53,10 @@ typedef PERL_BITFIELD16 Optype; PADOFFSET op_targ; \ PERL_BITFIELD16 op_type:9; \ PERL_BITFIELD16 op_opt:1; \ - PERL_BITFIELD16 op_latefree:1; \ - PERL_BITFIELD16 op_latefreed:1; \ - PERL_BITFIELD16 op_attached:1; \ PERL_BITFIELD16 op_slabbed:1; \ PERL_BITFIELD16 op_savefree:1; \ - PERL_BITFIELD16 op_spare:1; \ + PERL_BITFIELD16 op_static:1; \ + PERL_BITFIELD16 op_spare:3; \ U8 op_flags; \ U8 op_private; #endif @@ -76,11 +66,9 @@ typedef PERL_BITFIELD16 Optype; then all the other bit-fields before/after it should change their types too to let VC pack them into the same 4 byte integer.*/ +/* for efficiency, requires OPf_WANT_VOID == G_VOID etc */ #define OP_GIMME(op,dfl) \ - (((op)->op_flags & OPf_WANT) == OPf_WANT_VOID ? G_VOID : \ - ((op)->op_flags & OPf_WANT) == OPf_WANT_SCALAR ? G_SCALAR : \ - ((op)->op_flags & OPf_WANT) == OPf_WANT_LIST ? G_ARRAY : \ - dfl) + (((op)->op_flags & OPf_WANT) ? ((op)->op_flags & OPf_WANT) : dfl) #define OP_GIMME_REVERSE(flags) ((flags) & G_WANT) @@ -127,7 +115,7 @@ Deprecated. Use C instead. /* On OP_ENTERSUB || OP_NULL, saw a "do". */ /* On OP_EXISTS, treat av as av, not avhv. */ /* On OP_(ENTER|LEAVE)EVAL, don't clear $@ */ - /* On pushre, rx is used as part of split, e.g. split " " */ + /* On OP_SPLIT, special split " " */ /* On regcomp, "use re 'eval'" was in scope */ /* On OP_READLINE, was <$filehandle> */ /* On RV2[ACGHS]V, don't create GV--in @@ -152,6 +140,7 @@ Deprecated. Use C instead. - Before ck_glob, called as CORE::glob - After ck_glob, use Perl glob function */ + /* On OP_PADRANGE, push @_ */ /* old names; don't use in new code, but don't break them, either */ #define OPf_LIST OPf_WANT_LIST @@ -234,6 +223,11 @@ Deprecated. Use C instead. /* OP_RV2[AGH]V, OP_PAD[AH]V, OP_[AH]ELEM, OP_[AH]SLICE OP_AV2ARYLEN, OP_R?KEYS, OP_SUBSTR, OP_POS, OP_VEC */ #define OPpMAYBE_LVSUB 8 /* We might be an lvalue to return */ + /* OP_RV2HV and OP_PADHV */ +#define OPpTRUEBOOL 32 /* %hash in (%hash || $foo) in + void context */ +#define OPpMAYBE_TRUEBOOL 64 /* %hash in (%hash || $foo) where + cx is not known till run time */ /* OP_SUBSTR only */ #define OPpSUBSTR_REPL_FIRST 16 /* 1st arg is replacement string */ @@ -242,6 +236,11 @@ Deprecated. Use C instead. #define OPpPAD_STATE 16 /* is a "state" pad */ /* for OP_RV2?V, lower bits carry hints (currently only HINT_STRICT_REFS) */ + /* OP_PADRANGE only */ + /* bit 7 is OPpLVAL_INTRO */ +#define OPpPADRANGE_COUNTMASK 127 /* bits 6..0 hold target range, */ +#define OPpPADRANGE_COUNTSHIFT 7 /* 7 bits in total */ + /* OP_RV2GV only */ #define OPpDONT_INIT_GV 4 /* Call gv_fetchpv with GV_NOINIT */ /* (Therefore will return whatever is currently in the symbol table, not @@ -416,9 +415,6 @@ struct pmop { * OP_MATCH and OP_QR */ #define PMf_ONCE (1<<(PMf_BASE_SHIFT+1)) -/* replacement contains variables */ -#define PMf_MAYBE_CONST (1<<(PMf_BASE_SHIFT+2)) - /* PMf_ONCE has matched successfully. Not used under threading. */ #define PMf_USED (1<<(PMf_BASE_SHIFT+3)) @@ -574,7 +570,7 @@ struct loop { # define cGVOPx_gv(o) ((GV*)PAD_SVl(cPADOPx(o)->op_padix)) # define IS_PADGV(v) (v && SvTYPE(v) == SVt_PVGV && isGV_with_GP(v) \ && GvIN_PAD(v)) -# define IS_PADCONST(v) (v && SvREADONLY(v)) +# define IS_PADCONST(v) (v && (SvREADONLY(v) || SvIsCOW(v))) # define cSVOPx_sv(v) (cSVOPx(v)->op_sv \ ? cSVOPx(v)->op_sv : PAD_SVl((v)->op_targ)) # define cSVOPx_svp(v) (cSVOPx(v)->op_sv \ @@ -739,7 +735,7 @@ least an C. * cating an op if there are no freed ops available or big enough. */ -#if !defined(PL_OP_SLAB_ALLOC) && defined(PERL_CORE) +#ifdef PERL_CORE struct opslot { /* keep opslot_next first */ OPSLOT * opslot_next; /* next slot */ @@ -761,12 +757,8 @@ struct opslab { # define OPSLOT_HEADER STRUCT_OFFSET(OPSLOT, opslot_op) # define OPSLOT_HEADER_P (OPSLOT_HEADER/sizeof(I32 *)) -# ifdef DEBUGGING -# define OpSLOT(o) (assert(o->op_slabbed), \ +# define OpSLOT(o) (assert_(o->op_slabbed) \ (OPSLOT *)(((char *)o)-OPSLOT_HEADER)) -# else -# define OpSLOT(o) ((OPSLOT *)(((char *)o)-OPSLOT_HEADER)) -# endif # define OpSLAB(o) OpSLOT(o)->opslot_slab # define OpslabREFCNT_dec(slab) \ (((slab)->opslab_refcnt == 1) \