X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=op.c;h=04df4deb3180a3b431e10b544cc3c9d94fe3ba71;hb=0f133d1fd189cd7868dcc2bc811ba6499a1e9fd2;hp=2eadb102fbce77a4786d62261d0716878d0ecffe;hpb=c5661c80adf757c3cf464bf5f538fe5082b73584;p=p5sagit%2Fp5-mst-13.2.git diff --git a/op.c b/op.c index 2eadb10..04df4de 100644 --- a/op.c +++ b/op.c @@ -30,13 +30,8 @@ #define PERL_SLAB_SIZE 2048 #endif -#define NewOp(m,var,c,type) \ - STMT_START { var = (type *) Slab_Alloc(m,c*sizeof(type)); } STMT_END - -#define FreeOp(p) Slab_Free(p) - -STATIC void * -S_Slab_Alloc(pTHX_ int m, size_t sz) +void * +Perl_Slab_Alloc(pTHX_ int m, size_t sz) { /* * To make incrementing use count easy PL_OpSlab is an I32 * @@ -74,8 +69,8 @@ S_Slab_Alloc(pTHX_ int m, size_t sz) return (void *)(PL_OpPtr + 1); } -STATIC void -S_Slab_Free(pTHX_ void *op) +void +Perl_Slab_Free(pTHX_ void *op) { I32 **ptr = (I32 **) op; I32 *slab = ptr[-1]; @@ -83,9 +78,9 @@ S_Slab_Free(pTHX_ void *op) assert( ptr < ( (I32 **) slab + PERL_SLAB_SIZE) ); assert( *slab > 0 ); if (--(*slab) == 0) { - #ifdef NETWARE - #define PerlMemShared PerlMem - #endif +# ifdef NETWARE +# define PerlMemShared PerlMem +# endif PerlMemShared_free(slab); if (slab == PL_OpSlab) { @@ -93,10 +88,6 @@ S_Slab_Free(pTHX_ void *op) } } } - -#else -#define NewOp(m, var, c, type) Newz(m, var, c, type) -#define FreeOp(p) Safefree(p) #endif /* * In the following definition, the ", Nullop" is just to make the compiler @@ -1829,8 +1820,11 @@ Perl_newPROG(pTHX_ OP *o) CALL_PEEP(PL_eval_start); } else { - if (o->op_type == OP_STUB) + if (o->op_type == OP_STUB) { + PL_comppad_name = 0; + PL_compcv = 0; return; + } PL_main_root = scope(sawparens(scalarvoid(o))); PL_curcop = &PL_compiling; PL_main_start = LINKLIST(PL_main_root); @@ -2171,7 +2165,7 @@ Perl_newLISTOP(pTHX_ I32 type, I32 flags, OP *first, OP *last) listop->op_last = pushop; } - return (OP*)listop; + return CHECKOP(type, listop); } OP * @@ -2608,7 +2602,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags) PmopSTASH_set(pmop,PL_curstash); } - return (OP*)pmop; + return CHECKOP(type, pmop); } OP * @@ -2676,7 +2670,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl) OP *curop; if (pm->op_pmflags & PMf_EVAL) { curop = 0; - if (CopLINE(PL_curcop) < PL_multi_end) + if (CopLINE(PL_curcop) < (line_t)PL_multi_end) CopLINE_set(PL_curcop, (line_t)PL_multi_end); } else if (repl->op_type == OP_CONST) @@ -2928,6 +2922,7 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *idop, OP *arg) PL_hints |= HINT_BLOCK_SCOPE; PL_copline = NOLINE; PL_expect = XSTATE; + PL_cop_seqmax++; /* Purely for B::*'s benefit */ } /* @@ -3356,7 +3351,9 @@ S_new_logop(pTHX_ I32 type, I32 flags, OP** firstp, OP** otherp) return first; } } - else if (ckWARN(WARN_MISC) && (first->op_flags & OPf_KIDS)) { + else if (ckWARN(WARN_MISC) && (first->op_flags & OPf_KIDS) && + type != OP_DOR) /* [#24076] Don't warn for err FOO. */ + { OP *k1 = ((UNOP*)first)->op_first; OP *k2 = k1->op_sibling; OPCODE warnop = 0; @@ -3414,6 +3411,8 @@ S_new_logop(pTHX_ I32 type, I32 flags, OP** firstp, OP** otherp) first->op_next = (OP*)logop; first->op_sibling = other; + CHECKOP(type,logop); + o = newUNOP(OP_NULL, 0, (OP*)logop); other->op_next = o; @@ -3458,6 +3457,8 @@ Perl_newCONDOP(pTHX_ I32 flags, OP *first, OP *trueop, OP *falseop) logop->op_other = LINKLIST(trueop); logop->op_next = LINKLIST(falseop); + CHECKOP(OP_COND_EXPR, /* that's logop->op_type */ + logop); /* establish postfix order */ start = LINKLIST(first); @@ -3743,7 +3744,7 @@ Perl_newFOROP(pTHX_ I32 flags,char *label,line_t forline,OP *sv,OP *expr,OP *blo append_elem(OP_LIST, expr, scalar(sv)))); assert(!loop->op_next); /* for my $x () sets OPpLVAL_INTRO; - * for our $x () sets OPpOUR_INTRO; both only used by Deparse.pm */ + * for our $x () sets OPpOUR_INTRO */ loop->op_private = (U8)iterpflags; #ifdef PL_OP_SLAB_ALLOC { @@ -3780,7 +3781,9 @@ Perl_newLOOPEX(pTHX_ I32 type, OP *label) op_free(label); } else { - if (label->op_type == OP_ENTERSUB) + /* Check whether it's going to be a goto &function */ + if (label->op_type == OP_ENTERSUB + && !(label->op_flags & OPf_STACKED)) label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN)); o = newUNOP(type, OPf_STACKED, label); } @@ -4351,6 +4354,9 @@ Perl_newCONSTSUB(pTHX_ HV *stash, char *name, SV *sv) CvCONST_on(cv); sv_setpv((SV*)cv, ""); /* prototype is "" */ + if (stash) + CopSTASH_free(PL_curcop); + LEAVE; return cv; @@ -4678,9 +4684,10 @@ Perl_ck_bitop(pTHX_ OP *o) (op) == OP_NE || (op) == OP_I_NE || \ (op) == OP_NCMP || (op) == OP_I_NCMP) o->op_private = (U8)(PL_hints & HINT_PRIVATE_MASK); - if (o->op_type == OP_BIT_OR - || o->op_type == OP_BIT_AND - || o->op_type == OP_BIT_XOR) + if (!(o->op_flags & OPf_STACKED) /* Not an assignment */ + && (o->op_type == OP_BIT_OR + || o->op_type == OP_BIT_AND + || o->op_type == OP_BIT_XOR)) { OP * left = cBINOPo->op_first; OP * right = left->op_sibling; @@ -4701,8 +4708,9 @@ Perl_ck_bitop(pTHX_ OP *o) OP * Perl_ck_concat(pTHX_ OP *o) { - if (cUNOPo->op_first->op_type == OP_CONCAT) - o->op_flags |= OPf_STACKED; + OP *kid = cUNOPo->op_first; + if (kid->op_type == OP_CONCAT && !(kUNOP->op_first->op_flags & OPf_MOD)) + o->op_flags |= OPf_STACKED; return o; } @@ -5297,7 +5305,7 @@ Perl_ck_glob(pTHX_ OP *o) #if !defined(PERL_EXTERNAL_GLOB) /* XXX this can be tightened up and made more failsafe. */ - if (!gv) { + if (!(gv && GvCVu(gv) && GvIMPORTED_CV(gv))) { GV *glob_gv; ENTER; Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, @@ -6269,6 +6277,21 @@ Perl_peep(pTHX_ register OP *o) o->op_seq = PL_op_seqmax++; break; case OP_STUB: + /* XXX This makes sub {}; work as expected. + ie {return;} not {return @_;} + When optimiser is properly split into fixups and + optimisations, this needs to stay in the fixups. */ + if(!oldop && + o->op_next && + o->op_next->op_type == OP_LEAVESUB) { + OP* newop = newSTATEOP(0, Nullch, 0); + newop->op_next = o->op_next; + o->op_next = 0; + op_free(o); + o = newop; + ((UNOP*)o->op_next)->op_first = newop; + CvSTART(PL_compcv) = newop; + } if ((o->op_flags & OPf_WANT) != OPf_WANT_LIST) { o->op_seq = PL_op_seqmax++; break; /* Scalar stub must produce undef. List stub is noop */