* op_static tell op_free() to skip PerlMemShared_free(), when
* !op_slabbed.
* op_savefree on savestack via SAVEFREEOP
- * op_spare Three spare bits
+ * op_folded Result/remainder of a constant fold operation.
+ * op_spare Two 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
PERL_BITFIELD16 op_slabbed:1; \
PERL_BITFIELD16 op_savefree:1; \
PERL_BITFIELD16 op_static:1; \
- PERL_BITFIELD16 op_spare:3; \
+ PERL_BITFIELD16 op_folded:1; \
+ PERL_BITFIELD16 op_spare:2; \
U8 op_flags; \
U8 op_private;
#endif
/* 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 OP_SPLIT, special split " " */
+ /* On pushre, rx is used as part of split, e.g. split " " */
/* On regcomp, "use re 'eval'" was in scope */
/* On OP_READLINE, was <$filehandle> */
/* On RV2[ACGHS]V, don't create GV--in
- After ck_glob, use Perl glob function
*/
/* On OP_PADRANGE, push @_ */
+ /* On OP_DUMP, has no label */
/* old names; don't use in new code, but don't break them, either */
#define OPf_LIST OPf_WANT_LIST
#define OPpDEREF_HV 64 /* Want ref to HV. */
#define OPpDEREF_SV (32|64) /* Want ref to SV. */
+/* OP_ENTERSUB and OP_RV2CV flags
+
+Flags are set on entersub and rv2cv in three phases:
+ parser - the parser passes the flag to the op constructor
+ check - the check routine called by the op constructor sets the flag
+ context - application of scalar/ref/lvalue context applies the flag
+
+In the third stage, an entersub op might turn into an rv2cv op (undef &foo,
+\&foo, lock &foo, exists &foo, defined &foo). The two places where that
+happens (op_lvalue_flags and doref in op.c) need to make sure the flags do
+not conflict. Flags applied in the context phase are only set when there
+is no conversion of op type.
+
+ bit entersub flag phase rv2cv flag phase
+ --- ------------- ----- ---------- -----
+ 1 OPpENTERSUB_INARGS context OPpMAY_RETURN_CONSTANT context
+ 2 HINT_STRICT_REFS check HINT_STRICT_REFS check
+ 4 OPpENTERSUB_HASTARG check
+ 8 OPpENTERSUB_AMPER parser
+ 16 OPpENTERSUB_DB check
+ 32 OPpDEREF_AV context
+ 64 OPpDEREF_HV context
+ 128 OPpLVAL_INTRO context OPpENTERSUB_NOPAREN parser
+
+*/
+
/* OP_ENTERSUB only */
#define OPpENTERSUB_DB 16 /* Debug subroutine. */
#define OPpENTERSUB_HASTARG 4 /* Called from OP tree. */
#define OPpENTERSUB_INARGS 1 /* Lval used as arg to a sub. */
/* used by OPpDEREF (32|64) */
-/* used by HINT_STRICT_SUBS 2 */
+/* used by HINT_STRICT_REFS 2 */
/* Mask for OP_ENTERSUB flags, the absence of which must be propagated
in dynamic context */
#define OPpENTERSUB_LVAL_MASK (OPpLVAL_INTRO|OPpENTERSUB_INARGS)
#define OPpEARLY_CV 32 /* foo() called before sub foo was parsed */
/* OP_?ELEM only */
#define OPpLVAL_DEFER 16 /* Defer creation of array/hash elem */
+ /* OP_RV2[AH]V OP_KV[AH]SLICE OP_[AH]SLICE */
+#define OPpSLICEWARNING 4 /* warn about %hash{$scalar} */
/* OP_RV2[SAH]V, OP_GVSV, OP_ENTERITER only */
#define OPpOUR_INTRO 16 /* Variable was in an our() */
/* OP_RV2[AGH]V, OP_PAD[AH]V, OP_[AH]ELEM, OP_[AH]SLICE OP_AV2ARYLEN,
#define OPpCONST_STRICT 8 /* bareword subject to strict 'subs' */
#define OPpCONST_ENTERED 16 /* Has been entered as symbol. */
#define OPpCONST_BARE 64 /* Was a bare word (filehandle?). */
-#define OPpCONST_FOLDED 128 /* Result of constant folding */
/* Private for OP_FLIP/FLOP */
#define OPpFLIP_LINENUM 64 /* Range arg potentially a line num. */
#define OPpEVAL_UNICODE 4
#define OPpEVAL_BYTES 8
#define OPpEVAL_COPHH 16 /* Construct %^H from cop hints */
+#define OPpEVAL_RE_REPARSING 32 /* eval_sv(..., G_RE_REPARSING) */
/* Private for OP_CALLER, OP_WANTARRAY and OP_RUNCV */
#define OPpOFFBYONE 128 /* Treat caller(1) as caller(2) */
/* Private for OP_(LAST|REDO|NEXT|GOTO|DUMP) */
#define OPpPV_IS_UTF8 128 /* label is in UTF8 */
+/* Private for OP_SPLIT */
+#define OPpSPLIT_IMPLIM 128 /* implicit limit */
+
struct op {
BASEOP
};
OP * op_first;
OP * op_last;
#ifdef USE_ITHREADS
- IV op_pmoffset;
+ PADOFFSET op_pmoffset;
#else
REGEXP * op_pmregexp; /* compiled expression */
#endif
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
* OP_MATCH and OP_QR */
#define PMf_ONCE (1<<(PMf_BASE_SHIFT+1))
-/* PMf_ONCE has matched successfully. Not used under threading. */
+/* PMf_ONCE, i.e. ?pat?, has matched successfully. Not used under threading. */
#define PMf_USED (1<<(PMf_BASE_SHIFT+3))
/* subst replacement is constant */
#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)
# 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
# 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 \
#define CALL_BLOCK_HOOKS(which, arg) \
STMT_START { \
if (PL_blockhooks) { \
- I32 i; \
+ SSize_t i; \
for (i = av_len(PL_blockhooks); i >= 0; i--) { \
SV *sv = AvARRAY(PL_blockhooks)[i]; \
BHK *hk; \