This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add epigraph for Perl 5.21.0.
[perl5.git] / pp.h
diff --git a/pp.h b/pp.h
index 42e63fa..97738c2 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -30,7 +30,7 @@ the C<SP> macro.  See C<SP>.
 
 =for apidoc ms||djSP
 
-Declare Just C<SP>. This is actually identical to C<dSP>, and declares
+Declare Just C<SP>.  This is actually identical to C<dSP>, and declares
 a local copy of perl's stack pointer, available via the C<SP> macro.
 See C<SP>.  (Available for backward source code compatibility with the
 old (Perl 5.005) thread model.)
@@ -57,7 +57,7 @@ Refetch the stack pointer.  Used after a callback.  See L<perlcall>.
 
 #define PUSHMARK(p)    \
        STMT_START {                                    \
-           if (++PL_markstack_ptr == PL_markstack_max) \
+           if (UNLIKELY(++PL_markstack_ptr == PL_markstack_max))       \
            markstack_grow();                           \
            *PL_markstack_ptr = (I32)((p) - PL_stack_base);\
        } STMT_END
@@ -149,7 +149,7 @@ Pops a long off the stack.
 
 /*
 =for apidoc Am|void|EXTEND|SP|SSize_t nitems
-Used to extend the argument stack for an XSUB's return values. Once
+Used to extend the argument stack for an XSUB's return values.  Once
 used, guarantees that there is room for at least C<nitems> to be pushed
 onto the stack.
 
@@ -270,15 +270,25 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
 =cut
 */
 
-#define EXTEND(p,n)    (void)(UNLIKELY(PL_stack_max - p < (SSize_t)(n)) &&     \
+#ifdef STRESS_REALLOC
+# define EXTEND(p,n)   (void)(sp = stack_grow(sp,p, (SSize_t)(n)))
+/* Same thing, but update mark register too. */
+# define MEXTEND(p,n)  STMT_START {                                    \
+                           const int markoff = mark - PL_stack_base;   \
+                           sp = stack_grow(sp,p,(SSize_t) (n));        \
+                           mark = PL_stack_base + markoff;             \
+                       } STMT_END
+#else
+# define EXTEND(p,n)   (void)(UNLIKELY(PL_stack_max - p < (SSize_t)(n)) &&     \
                            (sp = stack_grow(sp,p, (SSize_t) (n))))
 
 /* Same thing, but update mark register too. */
-#define MEXTEND(p,n)   STMT_START {if (UNLIKELY(PL_stack_max - p < (int)(n))) {\
+# define MEXTEND(p,n)  STMT_START {if (UNLIKELY(PL_stack_max - p < (int)(n))) {\
                            const int markoff = mark - PL_stack_base;           \
                            sp = stack_grow(sp,p,(SSize_t) (n));                \
                            mark = PL_stack_base + markoff;                     \
                        } } STMT_END
+#endif
 
 #define PUSHs(s)       (*++sp = (s))
 #define PUSHTARG       STMT_START { SvSETMAGIC(TARG); PUSHs(TARG); } STMT_END
@@ -390,12 +400,12 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
 /* do SvGETMAGIC on the stack args before checking for overload */
 
 #define tryAMAGICun_MG(method, flags) STMT_START { \
-       if ( (SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG)) \
+       if ( UNLIKELY((SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG))) \
                && Perl_try_amagic_un(aTHX_ method, flags)) \
            return NORMAL; \
     } STMT_END
 #define tryAMAGICbin_MG(method, flags) STMT_START { \
-       if ( ((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG)) \
+       if ( UNLIKELY(((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG))) \
                && Perl_try_amagic_bin(aTHX_ method, flags)) \
            return NORMAL; \
     } STMT_END
@@ -412,10 +422,11 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
        SV *tmpsv;                                              \
        SV *arg= *sp;                                           \
         int gimme = GIMME_V;                                    \
-       if (SvAMAGIC(arg) &&                                    \
+       if (UNLIKELY(SvAMAGIC(arg) &&                           \
            (tmpsv = amagic_call(arg, &PL_sv_undef, meth,       \
                                 AMGf_want_list | AMGf_noright  \
-                               |AMGf_unary))) {                \
+                               |AMGf_unary))))                 \
+        {                                                      \
            SPAGAIN;                                            \
             if (gimme == G_VOID) {                              \
                 (void)POPs; /* XXX ??? */                       \
@@ -424,7 +435,7 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
                 SSize_t i;                                      \
                 SSize_t len;                                    \
                 assert(SvTYPE(tmpsv) == SVt_PVAV);              \
-                len = av_len((AV *)tmpsv) + 1;                  \
+                len = av_tindex((AV *)tmpsv) + 1;               \
                 (void)POPs; /* get rid of the arg */            \
                 EXTEND(sp, len);                                \
                 for (i = 0; i < len; ++i)                       \