This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PUSHLOOP_PLAIN: don't set unused fields
authorDavid Mitchell <davem@iabyn.com>
Sat, 17 Oct 2015 12:15:06 +0000 (13:15 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 09:18:30 +0000 (09:18 +0000)
Currently PUSHLOOP_PLAIN sets a whole unch of fields that it isn't going
to ue to NULL or 0, e.g. blk_loop.itersave.

Skip this and leave them wild. Make cx_dump() not try to dump them for
CXt_LOOP_PLAIN

cop.h
scope.c

diff --git a/cop.h b/cop.h
index 252eeb9..ba9d425 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -809,11 +809,7 @@ struct block_loop {
 
 #define PUSHLOOP_PLAIN(cx)                                             \
        cx->blk_loop.my_op = cLOOP;                                     \
-       cx->blk_loop.state_u.ary.ary = NULL;                            \
-       cx->blk_loop.state_u.ary.ix = 0;                                \
-        cx->cx_old_savestack_ix = PL_savestack_ix;                      \
-       cx->blk_loop.itervar_u.svp = NULL;                              \
-       cx->blk_loop.itersave = NULL;
+        cx->cx_old_savestack_ix = PL_savestack_ix;
 
 #ifdef USE_ITHREADS
 #  define PUSHLOOP_FOR_setpad(c) (c)->blk_loop.oldcomppad = PL_comppad
diff --git a/scope.c b/scope.c
index 0188dd1..6881923 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -1374,13 +1374,17 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
        PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n", CxLABEL(cx));
        PerlIO_printf(Perl_debug_log, "BLK_LOOP.MY_OP = 0x%"UVxf"\n",
                PTR2UV(cx->blk_loop.my_op));
-       /* XXX: not accurate for LAZYSV/IV */
-       PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
-               PTR2UV(cx->blk_loop.state_u.ary.ary));
-       PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
-               (long)cx->blk_loop.state_u.ary.ix);
-       PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
-               PTR2UV(CxITERVAR(cx)));
+        if (CxTYPE(cx) != CXt_LOOP_PLAIN) {
+            PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
+                    PTR2UV(CxITERVAR(cx)));
+            PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
+                    PTR2UV(cx->blk_loop.itersave));
+            /* XXX: not accurate for LAZYSV/IV/LIST */
+            PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
+                    PTR2UV(cx->blk_loop.state_u.ary.ary));
+            PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
+                    (long)cx->blk_loop.state_u.ary.ix);
+        }
        break;
 
     case CXt_SUBST: