This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
eliminate PERL_STACK_OVERFLOW_CHECK
authorDavid Mitchell <davem@iabyn.com>
Fri, 25 Dec 2015 22:41:21 +0000 (22:41 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:19:18 +0000 (09:19 +0000)
This macro is defined as NOOP on all platforms except for MacOS classic,
where it was added as a hook to allow for OSes that have a small CPU
stack size. Since pp_entersub et al don't actually use the CPU stack,
this hook looks misconceived from the beginning. So remove all
uses of it in the core.

cop.h
perl.h
pp_ctl.c
pp_hot.c
pp_sort.c
pp_sys.c

diff --git a/cop.h b/cop.h
index 54a5b1c..45a39c1 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -1351,10 +1351,8 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
         saveix_floor = PL_savestack_ix;                                 \
         if (!(flags & CXp_SUB_RE_FAKE))                                 \
             CvDEPTH(cv)++;                                             \
-       if (CvDEPTH(cv) >= 2) {                                         \
-           PERL_STACK_OVERFLOW_CHECK();                                \
+       if (CvDEPTH(cv) >= 2)                                           \
            Perl_pad_push(aTHX_ padlist, CvDEPTH(cv));                  \
-       }                                                               \
        PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));                       \
        multicall_cv = cv;                                              \
         PERL_UNUSED_VAR(multicall_cv); /* for API */                    \
@@ -1400,10 +1398,8 @@ See L<perlcall/LIGHTWEIGHT CALLBACKS>.
         PUSHSUB(cx);                                                   \
         if (!(flags & CXp_SUB_RE_FAKE))                                 \
             CvDEPTH(cv)++;                                             \
-       if (CvDEPTH(cv) >= 2) {                                         \
-           PERL_STACK_OVERFLOW_CHECK();                                \
+       if (CvDEPTH(cv) >= 2)                                           \
            Perl_pad_push(aTHX_ padlist, CvDEPTH(cv));                  \
-       }                                                               \
        PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));                       \
        multicall_cv = cv;                                              \
        multicall_cop = CvSTART(cv);                                    \
diff --git a/perl.h b/perl.h
index 46906af..2117e49 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -6354,13 +6354,8 @@ expression, but with an empty argument list, like this:
 #define PERL_SCRIPT_MODE "r"
 #endif
 
-/*
- * Some operating systems are stingy with stack allocation,
- * so perl may have to guard against stack overflow.
- */
-#ifndef PERL_STACK_OVERFLOW_CHECK
+/* not used. Kept as a NOOP for backcompat */
 #define PERL_STACK_OVERFLOW_CHECK()  NOOP
-#endif
 
 /*
  * Some nonpreemptive operating systems find it convenient to
index 8478918..48654f4 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2023,10 +2023,8 @@ PP(pp_dbstate)
             PL_debug = 0;
             SAVESTACK_POS();
            CvDEPTH(cv)++;
-           if (CvDEPTH(cv) >= 2) {
-               PERL_STACK_OVERFLOW_CHECK();
+           if (CvDEPTH(cv) >= 2)
                pad_push(CvPADLIST(cv), CvDEPTH(cv));
-           }
            PAD_SET_CUR_NOSAVE(CvPADLIST(cv), CvDEPTH(cv));
            RETURNOP(CvSTART(cv));
        }
index 824e7e7..2442850 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3859,10 +3859,8 @@ PP(pp_entersub)
         cx->blk_oldsaveix = old_savestack_ix;
 
        padlist = CvPADLIST(cv);
-       if (UNLIKELY((depth = ++CvDEPTH(cv)) >= 2)) {
-           PERL_STACK_OVERFLOW_CHECK();
+       if (UNLIKELY((depth = ++CvDEPTH(cv)) >= 2))
            pad_push(padlist, depth);
-       }
        PAD_SET_CUR_NOSAVE(padlist, depth);
        if (LIKELY(hasargs)) {
            AV *const av = MUTABLE_AV(PAD_SVl(0));
index 02c5dd8..9e0d64c 100644 (file)
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -1675,10 +1675,8 @@ PP(pp_sort)
                if (!is_xsub) {
                    PADLIST * const padlist = CvPADLIST(cv);
 
-                   if (++CvDEPTH(cv) >= 2) {
-                       PERL_STACK_OVERFLOW_CHECK();
+                   if (++CvDEPTH(cv) >= 2)
                        pad_push(padlist, CvDEPTH(cv));
-                   }
                    PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
 
                    if (hasargs) {
index ea99011..3be4be3 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1391,10 +1391,8 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop)
 
     PUSHBLOCK(cx, CXt_FORMAT, PL_stack_sp);
     PUSHFORMAT(cx, retop);
-    if (CvDEPTH(cv) >= 2) {
-       PERL_STACK_OVERFLOW_CHECK();
+    if (CvDEPTH(cv) >= 2)
        pad_push(CvPADLIST(cv), CvDEPTH(cv));
-    }
     PAD_SET_CUR_NOSAVE(CvPADLIST(cv), CvDEPTH(cv));
 
     setdefout(gv);         /* locally select filehandle so $% et al work */