Clear method caches when unwinding local *foo=sub{}
authorFather Chrysostomos <sprout@cpan.org>
Thu, 29 Nov 2012 17:08:08 +0000 (09:08 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 29 Nov 2012 17:11:32 +0000 (09:11 -0800)
commitdb9306af4ddf47b54fb142041f8f950b1ec18f08
tree2d966d7a75b8edd8f159f089f96b4e9f061395ee
parentaf5aa9e378e68e5202ada6a61d269e74cc9fe298
Clear method caches when unwinding local *foo=sub{}

local *foo=sub{} is done in two stages:

• First the local *foo localises the GP (the glob pointer, or list of
  slots), setting a flag on the GV.
• Then scalar assignment sees the flag on the GV on the LHS and loca-
  lises a single slot.

The slot localisation only stores on the savestack a pointer into the
GP struct and the old value.  There is no reference to the GV.

To restore a method properly, we have to have a reference to the GV
when the slot localisation is undone.

So in this commit I have added a new save type, SAVEt_GVSLOT.  It is
like SAVEt_GENERIC_SV, except it pushes the GV as well.  Currently
it is used only for CVs, but I will need it for HVs and maybe
AVs as well.

It is possible for the unwinding of the slot localisation to affect
only a GV other than the one that is pushed, if glob assignments have
taken place since the local *foo.  So we have to check whether the
pointer is inside the GP and use PL_sub_generation++ if it is not.
scope.c
scope.h
sv.c
t/mro/method_caching.t