diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-06-18 20:34:21 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-07-25 23:47:59 -0700 |
commit | 82b84d048796842c82f596fa9622a88b70e4dd1b (patch) | |
tree | 6c03704cb8996a908d157feac65bf91e3f2d9380 /pad.c | |
parent | c370bd2ea3bafeee0cf4a12391eb41c288c25e2c (diff) | |
download | perl-82b84d048796842c82f596fa9622a88b70e4dd1b.tar.gz |
op.c: Stop copying constants under ithreads
This fixes bugs #21979, #89188, #109746, #114838 and #115388 and
mostly fixes #109744 and #105906 (other issues still remain in those
two tickets).
Because the PADTMP flag was doing double duty, indicating that a
pad slot was in use in addition to indicating a target, constants
could not be shared between pad slots, as freeing one const op (and
turning of its PADTMP flag in pad_free) would mark some other pad
slot as free.
I believe this may have been fixed already by change 3b1c21fabed,
which made const ops use pad_swipe (which removes the SV from the
pad) instead of pad_free (which marks it as available for reuse). But
the copying still happens.
In any case, as of the previous commit, whether a pad slot for a con-
stant is in use is now stored in the pad name. Slots in use for const
ops now have &PL_sv_no names.
So there is no longer any reason to copy the constants.
The difference can be observed thus:
Before:
$ ./perl -lIlib -MDevel::Peek -e 'sub foo(){42} Dump foo; Dump foo'
SV = IV(0x7f94ea02ef10) at 0x7f94ea02ef20
REFCNT = 2
FLAGS = (PADTMP,IOK,READONLY,pIOK)
IV = 42
SV = IV(0x7f94ea02eeb0) at 0x7f94ea02eec0
REFCNT = 1
FLAGS = (PADTMP,IOK,READONLY,pIOK)
IV = 42
After:
$ ./perl -lIlib -MDevel::Peek -e 'sub foo(){42} Dump foo; Dump foo'
SV = IV(0x7f894882ef10) at 0x7f894882ef20
REFCNT = 3
FLAGS = (IOK,READONLY,pIOK)
IV = 42
SV = IV(0x7f894882ef10) at 0x7f894882ef20
REFCNT = 3
FLAGS = (IOK,READONLY,pIOK)
IV = 42
Notice the different addresses.
There are still special cases for copying &PL_sv_undef, which I need
to tackle.
Since most constants created by ‘use constant’ have the PADMY flag on
(since they reside in lexical variables inside constant.pm) and PADMY
and PADTMP are exclusive, I have stop turning on PADTMP for constants.
It is no longer necessary now, since before its purpose was to mark
pad entries as being in use. That means many to-do tests pass.
Diffstat (limited to 'pad.c')
-rw-r--r-- | pad.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1638,7 +1638,7 @@ Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust) "Pad 0x%"UVxf"[0x%"UVxf"] swipe: %ld\n", PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po)); - if (PL_curpad[po]) + if (PL_curpad[po] && !SvPADMY(PL_curpad[po])) SvPADTMP_off(PL_curpad[po]); if (refadjust) SvREFCNT_dec(PL_curpad[po]); |