summaryrefslogtreecommitdiff
path: root/gv.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-28 08:36:34 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-11-29 09:11:30 -0800
commit978a498e17ec54b6f1fc65f3375a62a68f321f99 (patch)
treecc9f490a623bb40458a8813f59a5bb64af80b188 /gv.h
parent6e1b2de7c59099adaa1866fe94957b98fabcd9c4 (diff)
downloadperl-978a498e17ec54b6f1fc65f3375a62a68f321f99.tar.gz
Reset method caches when GPs are shared
The new MRO stuff in 5.10 made PL_sub_generation++ mostly unnecessary, and almost all uses of it were replaced with mro_method_changed_in. There is only one problem: That doesn’t actually work properly. After glob-to-glob assignment (*foo = *bar), both globs share the same GP (glob pointer, or list of glob slots). But there is no list of GVs associated with any GP. So there is no way, given a GV whose GP is shared, to find out what other classes might need their method caches reset. sub B::b { "b" } *A::b = *B::b; @C::ISA = "A"; print C->b, "\n"; # should print "b" eval 'sub B::b { "c" }'; print C->b, "\n"; # should print "c" __END__ $ perl5.8.9 foo b c $ perl5.10.0 foo b b And it continues up to 5.16.x. If a GP is shared, then those places where mro_method_changed_in is called after the GP has been modified must do PL_sub_generation++ instead if the GP is shared, which can be detected through its refer- ence count.
Diffstat (limited to 'gv.h')
-rw-r--r--gv.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/gv.h b/gv.h
index 8e09340053..1e17f35d46 100644
--- a/gv.h
+++ b/gv.h
@@ -264,6 +264,13 @@ Return the CV from the GV.
#define gv_autoload4(stash, name, len, method) \
gv_autoload_pvn(stash, name, len, !!(method))
#define newGVgen(pack) newGVgen_flags(pack, 0)
+#define gv_method_changed(gv) \
+ ( \
+ assert_(isGV_with_GP(gv)) \
+ GvREFCNT(gv) > 1 \
+ ? (void)++PL_sub_generation \
+ : mro_method_changed_in(GvSTASH(gv)) \
+ )
#define gv_AVadd(gv) gv_add_by_type((gv), SVt_PVAV)
#define gv_HVadd(gv) gv_add_by_type((gv), SVt_PVHV)