develooper Front page | perl.perl5.changes | Postings from July 2012

[perl.git] branch blead, updated. v5.17.1-359-g986d39e

From:
Father Chrysostomos
Date:
July 12, 2012 21:59
Subject:
[perl.git] branch blead, updated. v5.17.1-359-g986d39e
Message ID:
E1SpXxs-0008NW-DF@camel.ams6.corp.booking.com
In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/986d39eeb4080ac83a841368252abaf063cc1486?hp=90519d0fd74b0bc30c7b0f455caef9f51f7fea12>

- Log -----------------------------------------------------------------
commit 986d39eeb4080ac83a841368252abaf063cc1486
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Thu Jul 12 17:50:51 2012 -0700

    Fix @{*ISA} autovivification
    
    It was not attaching magic to the array, preventing subsequent changes
    to the array from updating isa caches.

M	gv.c
M	t/mro/basic.t

commit dfedf89255b7306231f87f711321b2a976aec65f
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Thu Jul 12 17:35:37 2012 -0700

    Fix *ISA = *glob_without_array
    
    I broke this in 5.14 with commit 6624142a.
    
    In trying to make *ISA = *Other::ISA work, I added logic to make
    @Other::ISA’s existing magic now point to *ISA’s stash.  I skipped
    that logic if *Other::ISA did not contain an array.  But in so
    doing, I inadvertently skipped the call to mro_isa_changed_in at the
    same time.

M	sv.c
M	t/mro/basic.t

commit af7751f6652f1fb8efc5c0fe424de739fc30a332
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Thu Jul 12 14:34:03 2012 -0700

    op.c: Make slabs sizes powers of two
    
    It wasn’t exactly doubling the size of the previous slab, but making
    it two less than that.  I’m assuming that malloc implementations round
    things up to powers of two, and trying to take advantage of that, so
    we don’t have wasted gaps at the ends of slabs.

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

Summary of changes:
 gv.c          |    3 +++
 op.c          |    5 +++--
 sv.c          |    5 +++--
 t/mro/basic.t |   19 ++++++++++++++++++-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/gv.c b/gv.c
index ba8e85e..e0fdc63 100644
--- a/gv.c
+++ b/gv.c
@@ -83,6 +83,9 @@ Perl_gv_add_by_type(pTHX_ GV *gv, svtype type)
 
     if (!*where)
 	*where = newSV_type(type);
+    if (type == SVt_PVAV && GvNAMELEN(gv) == 3
+     && strnEQ(GvNAME(gv), "ISA", 3))
+	sv_magic(*where, (SV *)gv, PERL_MAGIC_isa, NULL, 0);
     return gv;
 }
 
diff --git a/op.c b/op.c
index e722b89..7396a19 100644
--- a/op.c
+++ b/op.c
@@ -222,9 +222,10 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
 	/* Create a new slab.  Make this one twice as big. */
 	slot = slab2->opslab_first;
 	while (slot->opslot_next) slot = slot->opslot_next;
-	slab2 = S_new_slab(aTHX_ DIFF(slab2, slot)*2 > PERL_MAX_SLAB_SIZE
+	slab2 = S_new_slab(aTHX_
+			    (DIFF(slab2, slot)+1)*2 > PERL_MAX_SLAB_SIZE
 					? PERL_MAX_SLAB_SIZE
-					: DIFF(slab2, slot)*2);
+					: (DIFF(slab2, slot)+1)*2);
 	slab2->opslab_next = slab->opslab_next;
 	slab->opslab_next = slab2;
     }
diff --git a/sv.c b/sv.c
index dd78927..9caaa4d 100644
--- a/sv.c
+++ b/sv.c
@@ -3723,7 +3723,6 @@ S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype)
          /* The stash may have been detached from the symbol table, so
             check its name. */
          && GvSTASH(dstr) && HvENAME(GvSTASH(dstr))
-         && GvAV((const GV *)sstr)
         )
             mro_changes = 2;
         else {
@@ -3758,6 +3757,7 @@ S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype)
 	}
     GvMULTI_on(dstr);
     if(mro_changes == 2) {
+      if (GvAV((const GV *)sstr)) {
 	MAGIC *mg;
 	SV * const sref = (SV *)GvAV((const GV *)dstr);
 	if (SvSMAGICAL(sref) && (mg = mg_find(sref, PERL_MAGIC_isa))) {
@@ -3769,7 +3769,8 @@ S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype)
 	    av_push((AV *)mg->mg_obj, SvREFCNT_inc_simple_NN(dstr));
 	}
 	else sv_magic(sref, dstr, PERL_MAGIC_isa, NULL, 0);
-	mro_isa_changed_in(GvSTASH(dstr));
+      }
+      mro_isa_changed_in(GvSTASH(dstr));
     }
     else if(mro_changes == 3) {
 	HV * const stash = GvHV(dstr);
diff --git a/t/mro/basic.t b/t/mro/basic.t
index 9955b81..188159e 100644
--- a/t/mro/basic.t
+++ b/t/mro/basic.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-BEGIN { require q(./test.pl); } plan(tests => 52);
+BEGIN { require q(./test.pl); } plan(tests => 54);
 
 require mro;
 
@@ -328,3 +328,20 @@ is(eval { MRO_N->testfunc() }, 123);
     undef %Thwit::;
     ok !Thrext->isa('Sile'), 'undef %package:: updates subclasses';
 }
+
+{
+    # Obliterating @ISA via glob assignment
+    # Broken in 5.14.0; fixed in 5.17.2
+    @Gwythaint::ISA = "Fantastic::Creature";
+    undef *This_glob_haD_better_not_exist; # paranoia; must have no array
+    *Gwythaint::ISA = *This_glob_haD_better_not_exist;
+    ok !Gwythaint->isa("Fantastic::Creature"),
+       'obliterating @ISA via glob assignment';
+}
+
+{
+    # Autovivifying @ISA via @{*ISA}
+    undef *fednu::ISA;
+    @{*fednu::ISA} = "pyfg";
+    ok +fednu->isa("pyfg"), 'autovivifying @ISA via *{@ISA}';
+}

--
Perl5 Master Repository



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About