X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/5255171e6cd0accee6f76ea2980e32b3b5b8e171..7cf3104fcc1721d3e512b7b6e928b9e419c00743:/op.h diff --git a/op.h b/op.h index 3ddce78..286b880 100644 --- a/op.h +++ b/op.h @@ -20,8 +20,10 @@ * op_opt Whether or not the op has been optimised by the * peephole optimiser. * 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 Four spare bits! + * 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 @@ -53,7 +55,8 @@ typedef PERL_BITFIELD16 Optype; PERL_BITFIELD16 op_opt:1; \ PERL_BITFIELD16 op_slabbed:1; \ PERL_BITFIELD16 op_savefree:1; \ - PERL_BITFIELD16 op_spare:4; \ + PERL_BITFIELD16 op_static:1; \ + PERL_BITFIELD16 op_spare:3; \ U8 op_flags; \ U8 op_private; #endif @@ -63,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) @@ -139,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 +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 @@ -364,10 +371,7 @@ struct pmop { union { OP * op_pmreplstart; /* Only used in OP_SUBST */ #ifdef USE_ITHREADS - struct { - char * op_pmstashpv; /* Only used in OP_MATCH, with PMf_ONCE set */ - U32 op_pmstashflags; /* currently only SVf_UTF8 or 0 */ - } op_pmstashthr; + PADOFFSET op_pmstashoff; /* Only used in OP_MATCH, with PMf_ONCE set */ #else HV * op_pmstash; #endif @@ -408,9 +412,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)) @@ -450,30 +451,13 @@ struct pmop { #ifdef USE_ITHREADS -# define PmopSTASHPV(o) \ - (((o)->op_pmflags & PMf_ONCE) ? (o)->op_pmstashstartu.op_pmstashthr.op_pmstashpv : NULL) -# if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) -# define PmopSTASHPV_set(o,pv) ({ \ - assert((o)->op_pmflags & PMf_ONCE); \ - ((o)->op_pmstashstartu.op_pmstashthr.op_pmstashpv = savesharedpv(pv)); \ - }) -# else -# define PmopSTASHPV_set(o,pv) \ - ((o)->op_pmstashstartu.op_pmstashthr.op_pmstashpv = savesharedpv(pv)) -# endif -# define PmopSTASH_flags(o) ((o)->op_pmstashstartu.op_pmstashthr.op_pmstashflags) -# define PmopSTASH_flags_set(o,flags) ((o)->op_pmstashstartu.op_pmstashthr.op_pmstashflags = flags) -# define PmopSTASH(o) (PmopSTASHPV(o) \ - ? gv_stashpv((o)->op_pmstashstartu.op_pmstashthr.op_pmstashpv, \ - GV_ADD | PmopSTASH_flags(o)) : NULL) -# define PmopSTASH_set(o,hv) (PmopSTASHPV_set(o, (hv) ? HvNAME_get(hv) : NULL), \ - PmopSTASH_flags_set(o, \ - ((hv) && HvNAME_HEK(hv) && \ - HvNAMEUTF8(hv)) \ - ? SVf_UTF8 \ - : 0)) -# define PmopSTASH_free(o) PerlMemShared_free(PmopSTASHPV(o)) - +# define PmopSTASH(o) ((o)->op_pmflags & PMf_ONCE \ + ? PL_stashpad[(o)->op_pmstashstartu.op_pmstashoff] \ + : NULL) +# define PmopSTASH_set(o,hv) \ + (assert_((o)->op_pmflags & PMf_ONCE) \ + (o)->op_pmstashstartu.op_pmstashoff = \ + (hv) ? alloccopstash(hv) : 0) #else # define PmopSTASH(o) \ (((o)->op_pmflags & PMf_ONCE) ? (o)->op_pmstashstartu.op_pmstash : NULL) @@ -485,13 +469,10 @@ struct pmop { # else # define PmopSTASH_set(o,hv) ((o)->op_pmstashstartu.op_pmstash = (hv)) # endif -# define PmopSTASHPV(o) (PmopSTASH(o) ? HvNAME_get(PmopSTASH(o)) : NULL) - /* op_pmstashstartu.op_pmstash is not refcounted */ -# define PmopSTASHPV_set(o,pv) PmopSTASH_set((o), gv_stashpv(pv,GV_ADD)) -/* Note that if this becomes non-empty, then S_forget_pmop in op.c will need - changing */ -# define PmopSTASH_free(o) #endif +#define PmopSTASHPV(o) (PmopSTASH(o) ? HvNAME_get(PmopSTASH(o)) : NULL) + /* op_pmstashstartu.op_pmstash is not refcounted */ +#define PmopSTASHPV_set(o,pv) PmopSTASH_set((o), gv_stashpv(pv,GV_ADD)) struct svop { BASEOP @@ -566,7 +547,8 @@ 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) && !SvLEN(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 \