X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/f34acfecc286f2eff2450db713da005d888a7317..6987f4434e4dfee71506125954ee1ae41c46f1cb:/op.h diff --git a/op.h b/op.h index 537b2ef..9750717 100644 --- a/op.h +++ b/op.h @@ -24,7 +24,7 @@ * !op_slabbed. * op_savefree on savestack via SAVEFREEOP * op_folded Result/remainder of a constant fold operation. - * op_moresib this op is is not the last sibling + * op_moresib this op is not the last sibling * op_spare One spare bit * op_flags Flags common to all operations. See OPf_* below. * op_private Flags peculiar to a particular operation (BUT, @@ -70,14 +70,14 @@ typedef PERL_BITFIELD16 Optype; #define OP_GIMME_REVERSE(flags) ((flags) & G_WANT) /* -=head1 "Gimme" Values +=for apidoc_section $callback =for apidoc Amn|U32|GIMME_V The XSUB-writer's equivalent to Perl's C. Returns C, C or C for void, scalar or list context, respectively. See L for a usage example. -=for apidoc Amn|U32|GIMME +=for apidoc AmnD|U32|GIMME A backward-compatible version of C which can only return C or C; in a void context, it returns C. Deprecated. Use C instead. @@ -181,7 +181,7 @@ Deprecated. Use C instead. /* things that can be elements of op_aux */ -typedef union { +typedef union { PADOFFSET pad_offset; SV *sv; IV iv; @@ -329,48 +329,52 @@ struct pmop { /* Set by the parser if it discovers an error, so the regex shouldn't be * compiled */ -#define PMf_HAS_ERROR (1U<<(PMf_BASE_SHIFT+4)) +#define PMf_HAS_ERROR (1U<<(PMf_BASE_SHIFT+3)) /* 'use re "taint"' in scope: taint $1 etc. if target tainted */ -#define PMf_RETAINT (1U<<(PMf_BASE_SHIFT+5)) +#define PMf_RETAINT (1U<<(PMf_BASE_SHIFT+4)) /* match successfully only once per reset, with related flag RXf_USED in * re->extflags holding state. This is used only for ?? matches, and only on * OP_MATCH and OP_QR */ -#define PMf_ONCE (1U<<(PMf_BASE_SHIFT+6)) +#define PMf_ONCE (1U<<(PMf_BASE_SHIFT+5)) /* PMf_ONCE, i.e. ?pat?, has matched successfully. Not used under threading. */ -#define PMf_USED (1U<<(PMf_BASE_SHIFT+7)) +#define PMf_USED (1U<<(PMf_BASE_SHIFT+6)) /* subst replacement is constant */ -#define PMf_CONST (1U<<(PMf_BASE_SHIFT+8)) +#define PMf_CONST (1U<<(PMf_BASE_SHIFT+7)) /* keep 1st runtime pattern forever */ -#define PMf_KEEP (1U<<(PMf_BASE_SHIFT+9)) +#define PMf_KEEP (1U<<(PMf_BASE_SHIFT+8)) -#define PMf_GLOBAL (1U<<(PMf_BASE_SHIFT+10)) /* pattern had a g modifier */ +#define PMf_GLOBAL (1U<<(PMf_BASE_SHIFT+9)) /* pattern had a g modifier */ /* don't reset pos() if //g fails */ -#define PMf_CONTINUE (1U<<(PMf_BASE_SHIFT+11)) +#define PMf_CONTINUE (1U<<(PMf_BASE_SHIFT+10)) /* evaluating replacement as expr */ -#define PMf_EVAL (1U<<(PMf_BASE_SHIFT+12)) +#define PMf_EVAL (1U<<(PMf_BASE_SHIFT+11)) /* Return substituted string instead of modifying it. */ -#define PMf_NONDESTRUCT (1U<<(PMf_BASE_SHIFT+13)) +#define PMf_NONDESTRUCT (1U<<(PMf_BASE_SHIFT+12)) /* the pattern has a CV attached (currently only under qr/...(?{}).../) */ -#define PMf_HAS_CV (1U<<(PMf_BASE_SHIFT+14)) +#define PMf_HAS_CV (1U<<(PMf_BASE_SHIFT+13)) /* op_code_list is private; don't free it etc. It may well point to * code within another sub, with different pad etc */ -#define PMf_CODELIST_PRIVATE (1U<<(PMf_BASE_SHIFT+15)) +#define PMf_CODELIST_PRIVATE (1U<<(PMf_BASE_SHIFT+14)) /* the PMOP is a QR (we should be able to detect that from the op type, * but the regex compilation API passes just the pm flags, not the op * itself */ -#define PMf_IS_QR (1U<<(PMf_BASE_SHIFT+16)) -#define PMf_USE_RE_EVAL (1U<<(PMf_BASE_SHIFT+17)) /* use re'eval' in scope */ +#define PMf_IS_QR (1U<<(PMf_BASE_SHIFT+15)) +#define PMf_USE_RE_EVAL (1U<<(PMf_BASE_SHIFT+16)) /* use re'eval' in scope */ + +/* Means that this is a subpattern being compiled while processing a \p{} + * wildcard. This isn't called from op.c, but it is passed as a pm flag. */ +#define PMf_WILDCARD (1U<<(PMf_BASE_SHIFT+17)) /* See comments at the beginning of these defines about adding bits. The * highest bit position should be used, so that if PMf_BASE_SHIFT gets @@ -392,7 +396,7 @@ struct pmop { #else # define PmopSTASH(o) \ (((o)->op_pmflags & PMf_ONCE) ? (o)->op_pmstashstartu.op_pmstash : NULL) -# if defined (DEBUGGING) && defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) +# if defined (DEBUGGING) && defined(PERL_USE_GCC_BRACE_GROUPS) # define PmopSTASH_set(o,hv) ({ \ assert((o)->op_pmflags & PMf_ONCE); \ ((o)->op_pmstashstartu.op_pmstash = (hv)); \ @@ -635,7 +639,7 @@ typedef struct { /* -=head1 Optree Manipulation Functions +=for apidoc_section $optree_manipulation =for apidoc Am|OP*|LINKLIST|OP *o Given the root of an optree, link the tree in execution order using the @@ -699,8 +703,9 @@ struct opslot { struct opslab { OPSLAB * opslab_next; /* next slab */ OPSLAB * opslab_head; /* first slab in chain */ - OP * opslab_freed; /* chain of freed ops (head only)*/ + OP ** opslab_freed; /* array of sized chains of freed ops (head only)*/ size_t opslab_refcnt; /* number of ops (head slab only) */ + U16 opslab_freed_size; /* allocated size of opslab_freed */ U16 opslab_size; /* size of slab in pointers, including header */ U16 opslab_free_space; /* space available in this slab @@ -713,13 +718,18 @@ struct opslab { }; # define OPSLOT_HEADER STRUCT_OFFSET(OPSLOT, opslot_op) -# define OPSLOT_HEADER_P (OPSLOT_HEADER/sizeof(I32 *)) # define OpSLOT(o) (assert_(o->op_slabbed) \ (OPSLOT *)(((char *)o)-OPSLOT_HEADER)) +/* the slab that owns this op */ +# define OpMySLAB(o) \ + ((OPSLAB*)((char *)((I32**)OpSLOT(o) - OpSLOT(o)->opslot_offset)-STRUCT_OFFSET(struct opslab, opslab_slots))) /* the first (head) opslab of the chain in which this op is allocated */ # define OpSLAB(o) \ - (((OPSLAB*)( (I32**)OpSLOT(o) - OpSLOT(o)->opslot_offset))->opslab_head) + (OpMySLAB(o)->opslab_head) +/* calculate the slot given the owner slab and an offset */ +#define OpSLOToff(slab, offset) \ + ((OPSLOT*)(((I32 **)&(slab)->opslab_slots)+(offset))) # define OpslabREFCNT_dec(slab) \ (((slab)->opslab_refcnt == 1) \ @@ -741,7 +751,7 @@ struct block_hooks { }; /* -=head1 Compile-time scope hooks +=for apidoc_section $scope =for apidoc mx|U32|BhkFLAGS|BHK *hk Return the BHK's flags. @@ -806,7 +816,7 @@ preprocessing token; the type of C depends on C. STMT_START { \ if (PL_blockhooks) { \ SSize_t i; \ - for (i = av_tindex(PL_blockhooks); i >= 0; i--) { \ + for (i = av_top_index(PL_blockhooks); i >= 0; i--) { \ SV *sv = AvARRAY(PL_blockhooks)[i]; \ BHK *hk; \ \ @@ -827,7 +837,7 @@ preprocessing token; the type of C depends on C. #define RV2CVOPCV_MARK_EARLY 0x00000001 #define RV2CVOPCV_RETURN_NAME_GV 0x00000002 #define RV2CVOPCV_RETURN_STUB 0x00000004 -#ifdef PERL_CORE /* behaviour of this flag is subject to change: */ +#if defined(PERL_CORE) || defined(PERL_EXT) /* behaviour of this flag is subject to change: */ # define RV2CVOPCV_MAYBE_NAME_GV 0x00000008 #endif #define RV2CVOPCV_FLAG_MASK 0x0000000f /* all of the above */ @@ -839,7 +849,7 @@ preprocessing token; the type of C depends on C. #define OP_LVALUE_NO_CROAK 1 /* -=head1 Custom Operators +=for apidoc_section $custom =for apidoc Am|U32|XopFLAGS|XOP *xop Return the XOP's flags. @@ -849,7 +859,7 @@ Return a member of the XOP structure. C is a cpp token indicating which entry to return. If the member is not set this will return a default value. The return type depends on C. This macro evaluates its arguments more than -once. If you are using C to retreive a +once. If you are using C to retrieve a C from a C, use the more efficient L instead. =for apidoc Am||XopENTRYCUSTOM|const OP *o|which @@ -935,7 +945,7 @@ typedef enum { (Perl_custom_op_get_field(x, XOPe_xop_ptr).xop_ptr) /* -=head1 Optree Manipulation Functions +=for apidoc_section $optree_manipulation =for apidoc Am|const char *|OP_NAME|OP *o Return the name of the provided OP. For core ops this looks up the name @@ -1049,10 +1059,6 @@ C is non-null. For a higher-level interface, see C>. #define newATTRSUB(f, o, p, a, b) Perl_newATTRSUB_x(aTHX_ f, o, p, a, b, FALSE) #define newSUB(f, o, p, b) newATTRSUB((f), (o), (p), NULL, (b)) -/* -=head1 Hook manipulation -*/ - #ifdef USE_ITHREADS # define OP_CHECK_MUTEX_INIT MUTEX_INIT(&PL_check_mutex) # define OP_CHECK_MUTEX_LOCK MUTEX_LOCK(&PL_check_mutex) @@ -1125,7 +1131,7 @@ C is non-null. For a higher-level interface, see C>. /* stuff for OP_ARGCHECK */ -struct op_argcheck_aux { +struct op_argcheck_aux { UV params; /* number of positional parameters */ UV opt_params; /* number of optional positional parameters */ char slurpy; /* presence of slurpy: may be '\0', '@' or '%' */