In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/be294d8de54348bbae20db1deaab47d34dfba5fd?hp=98fce2a4417fa36585bb48f6ae845bee93cac0fa>

- Log -----------------------------------------------------------------
commit be294d8de54348bbae20db1deaab47d34dfba5fd
Author: David Mitchell <[email protected]>
Date:   Wed Sep 21 09:22:13 2016 +0100

    add a test for gv_try_downgrade()
    
    Previously, making gv_try_downgrade() just immediately return didn't cause
    any tests to fail.

M       t/op/gv.t

commit 5debce0abfd900416a8fae42c0fced0298d2957c
Author: David Mitchell <[email protected]>
Date:   Tue Sep 20 09:45:07 2016 +0100

    fix builds under USE_PAD_RESET
    
    It had suffered some bitrot.

M       op.c
M       pad.c
-----------------------------------------------------------------------

Summary of changes:
 op.c      |  6 ++++++
 pad.c     |  2 +-
 t/op/gv.t | 19 ++++++++++++++++++-
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/op.c b/op.c
index 66cac9b..3e44be8 100644
--- a/op.c
+++ b/op.c
@@ -5744,7 +5744,13 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, OP *repl, bool 
isreg, I32 floor)
                SSize_t i = 0;
                assert(PadnamelistMAXNAMED(PL_comppad_name) == 0);
                while (++i <= AvFILLp(PL_comppad)) {
+#  ifdef USE_PAD_RESET
+                    /* under USE_PAD_RESET, pad swipe replaces a swiped
+                     * folded constant with a fresh padtmp */
+                   assert(!PL_curpad[i] || SvPADTMP(PL_curpad[i]));
+#  else
                    assert(!PL_curpad[i]);
+#  endif
                }
 #endif
                /* But we know that one op is using this CV's slab. */
diff --git a/pad.c b/pad.c
index 7cf1fe3..bdaf948 100644
--- a/pad.c
+++ b/pad.c
@@ -756,7 +756,7 @@ Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype)
            sv = *av_fetch(PL_comppad, retval, TRUE);
            if (!(SvFLAGS(sv) &
 #ifdef USE_PAD_RESET
-                   (konst ? SVs_PADTMP : 0))
+                   (konst ? SVs_PADTMP : 0)
 #else
                    SVs_PADTMP
 #endif
diff --git a/t/op/gv.t b/t/op/gv.t
index 9bdc711..8d5e7dc 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -12,7 +12,7 @@ BEGIN {
 
 use warnings;
 
-plan(tests => 277 );
+plan(tests => 280);
 
 # type coercion on assignment
 $foo = 'foo';
@@ -1170,6 +1170,23 @@ SKIP: {
     is ($? & 127, 0,"[perl #128597] No crash when gp_free calls ckWARN_d");
 }
 
+# test gv_try_downgrade()
+# If a GV can be stored in a stash in a compact, non-GV form, then
+# whenever ops are freed which reference the GV, an attempt is made to
+# downgrade the GV to something simpler. Made sure this happens.
+
+package GV_DOWNGRADE {
+    use constant FOO => 1;
+
+    ::like "$GV_DOWNGRADE::{FOO}", qr/SCALAR/, "gv_downgrade: pre";
+    eval q{
+        my $x = \&FOO; # upgrades compact to full GV
+        ::like "$GV_DOWNGRADE::{FOO}", qr/^\*/, "gv_downgrade: full";
+    };
+    # after the eval's ops are freed, the GV should get downgraded again
+    ::like "$GV_DOWNGRADE::{FOO}", qr/SCALAR/, "gv_downgrade: post";
+}
+
 __END__
 Perl
 Rules

--
Perl5 Master Repository

Reply via email to