In perl.git, the branch sprout/rstack has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/9cab2d253d1a40466168ec3976f809bd265a9fe3?hp=090c65e667b4a0e2c5a2e362f966379f1212a76c>

- Log -----------------------------------------------------------------
commit 9cab2d253d1a40466168ec3976f809bd265a9fe3
Author: Father Chrysostomos <[email protected]>
Date:   Wed Aug 10 23:03:43 2016 -0700

    perl.c: Inline CALL_LIST_BODY
    
    into the only spot that calls it.  This just makes the code at that
    point clearer and easier to edit.

M       perl.c

commit 8d0d54f960590b682ad416b8f5224e101829fafa
Author: Father Chrysostomos <[email protected]>
Date:   Wed Aug 10 23:02:35 2016 -0700

    Consider this a crash course...

M       cop.h
M       inline.h
M       op.c
M       perl.c
M       pp_hot.c
M       scope.c
-----------------------------------------------------------------------

Summary of changes:
 cop.h    |  4 ++--
 inline.h | 30 ++++++++++++++++++++++++++++++
 op.c     |  1 +
 perl.c   | 21 ++++++++++++++-------
 pp_hot.c |  4 ++--
 scope.c  |  1 -
 6 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/cop.h b/cop.h
index b371379..37f15be 100644
--- a/cop.h
+++ b/cop.h
@@ -1042,14 +1042,14 @@ typedef struct stackinfo PERL_SI;
        if (!prev) {                                                    \
            Perl_croak_popstack();                                      \
        }                                                               \
-       SWITCHSTACK(PL_curstack,prev->si_stack);                        \
+       SWITCHSTACK(PL_rcurstack,prev->si_stack);                       \
        /* don't free prev here, free them all at the END{} */          \
        PL_curstackinfo = prev;                                         \
     } STMT_END
 
 #define POPSTACK_TO(s) \
     STMT_START {                                                       \
-       while (PL_curstack != s) {                                      \
+       while (PL_rcurstack != s) {                                     \
            dounwind(-1);                                               \
            POPSTACK;                                                   \
        }                                                               \
diff --git a/inline.h b/inline.h
index 9bc6b8b..b0bc4a5 100644
--- a/inline.h
+++ b/inline.h
@@ -127,6 +127,36 @@ PadnameIN_SCOPE(const PADNAME * const pn, const U32 seq)
 
 /* ------------------------------- pp.h ------------------------------- */
 
+PERL_STATIC_INLINE void
+S_PUSHMARK(pTHX_ SV **p)
+{
+    
+    I32 * mark_stack_entry;
+    if (UNLIKELY((mark_stack_entry = ++PL_markstack_ptr)
+                       == PL_markstack_max))
+    mark_stack_entry = markstack_grow();
+    *mark_stack_entry  = (I32)((p) - PL_stack_base);
+    DEBUG_s(DEBUG_v(PerlIO_printf(Perl_debug_log,
+                                "MARK push %p %"IVdf"\n",
+                                 PL_markstack_ptr, (IV)*mark_stack_entry
+                                )));
+}
+
+PERL_STATIC_INLINE void
+S_rPUSHMARK(pTHX_ SV **p)
+{
+    
+    I32 * mark_stack_entry;
+    if (UNLIKELY((mark_stack_entry = ++PL_rmarkstack_ptr)
+                       == PL_rmarkstack_max))
+    mark_stack_entry = markstack_grow();
+    *mark_stack_entry  = (I32)((p) - PL_rstack_base);
+    DEBUG_s(DEBUG_v(PerlIO_printf(Perl_debug_log,
+                                "MARK push %p %"IVdf"\n",
+                                 PL_rmarkstack_ptr, (IV)*mark_stack_entry
+                                )));
+}
+
 PERL_STATIC_INLINE I32
 S_TOPMARK(pTHX)
 {
diff --git a/op.c b/op.c
index e611dbe..53bcf45 100644
--- a/op.c
+++ b/op.c
@@ -8899,6 +8899,7 @@ S_process_special_blocks(pTHX_ I32 floor, const char 
*const fullname,
            DEBUG_x( dump_sub(gv) );
            Perl_av_create_and_push(aTHX_ &PL_beginav, MUTABLE_SV(cv));
            GvCV_set(gv,0);             /* cv has been hijacked */
+Perl_sv_dump(cv);
            call_list(oldscope, PL_beginav);
 
             POPSTACK;
diff --git a/perl.c b/perl.c
index 44f8642..56313c1 100644
--- a/perl.c
+++ b/perl.c
@@ -80,10 +80,6 @@ static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int 
maxlen);
     if (PL_op) \
        CALLRUNOPS(aTHX);
 
-#define CALL_LIST_BODY(cv) \
-    PUSHMARK(PL_stack_sp); \
-    call_sv(MUTABLE_SV((cv)), G_EVAL|G_DISCARD|G_VOID);
-
 static void
 S_init_tls_and_interp(PerlInterpreter *my_perl)
 {
@@ -4153,8 +4149,18 @@ Perl_init_stacks(pTHX)
     PL_curstackinfo = new_stackinfo(REASONABLE(128),
                                 REASONABLE(8192/sizeof(PERL_CONTEXT) - 1));
     PL_curstackinfo->si_type = PERLSI_MAIN;
-    PL_curstack = PL_curstackinfo->si_stack;
-    PL_mainstack = PL_curstack;                /* remember in case we switch 
stacks */
+    PL_rcurstack = PL_curstackinfo->si_stack;
+    PL_mainstack = PL_rcurstack;       /* remember in case we switch stacks */
+
+    PL_rstack_base = AvARRAY(PL_rcurstack);
+    PL_rstack_sp = PL_rstack_base;
+    PL_rstack_max = PL_rstack_base + AvMAX(PL_rcurstack);
+
+    PL_curstack = newAV();
+    AvREAL_off(PL_curstack);
+    av_extend(PL_curstack, 0); /* Small at first; it may not be needed.  */
+    AvALLOC(PL_curstack)[0] = &PL_sv_undef;
+    AvFILLp(PL_curstack) = 0;
 
     PL_stack_base = AvARRAY(PL_curstack);
     PL_stack_sp = PL_stack_base;
@@ -5024,7 +5030,8 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
        JMPENV_PUSH(ret);
        switch (ret) {
        case 0:
-           CALL_LIST_BODY(cv);
+           PUSHMARK(PL_stack_sp);
+           call_sv(MUTABLE_SV((cv)), G_EVAL|G_DISCARD|G_VOID);
            atsv = ERRSV;
            (void)SvPV_const(atsv, len);
            if (len) {
diff --git a/pp_hot.c b/pp_hot.c
index 16d4ecc..f4c3727 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -3967,7 +3967,7 @@ PP(pp_entersub)
                /* Mark is at the end of the stack. */
                /* But we cannot assume that about the other stack.  */
                if (!rstack)
-                   PUSHMARK;
+                   PUSHMARK(SP);
                EXTEND(SP, items);
                for (; i < items; ++i)
                {
@@ -3999,7 +3999,7 @@ PP(pp_entersub)
                 }
            }
            if (!rstack) {
-               S_PUSHMARK(aTHX);
+               S_PUSHMARK(aTHX_ PL_stack_sp);
                Copy(PL_rstack_base + markix, PL_stack_sp,
                     SP - PL_rstack_base - markix, SV *);
            }
diff --git a/scope.c b/scope.c
index 49db3a7..6f11f37 100644
--- a/scope.c
+++ b/scope.c
@@ -83,7 +83,6 @@ Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
     PERL_SI *si;
     Newx(si, 1, PERL_SI);
     si->si_stack = newAV();
-    AvREAL_off(si->si_stack);
     av_extend(si->si_stack, stitems > 0 ? stitems-1 : 0);
     AvALLOC(si->si_stack)[0] = &PL_sv_undef;
     AvFILLp(si->si_stack) = 0;

--
Perl5 Master Repository

Reply via email to