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 /ext | |
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 'ext')
-rw-r--r-- | ext/B/t/OptreeCheck.pm | 18 | ||||
-rw-r--r-- | ext/B/t/optree_constants.t | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/ext/B/t/OptreeCheck.pm b/ext/B/t/OptreeCheck.pm index 45523133a3..547f017d72 100644 --- a/ext/B/t/OptreeCheck.pm +++ b/ext/B/t/OptreeCheck.pm @@ -213,7 +213,8 @@ They're both required, and the correct one is selected for the platform being tested, and saved into the synthesized property B<wanted>. Individual sample lines may be suffixed with whitespace followed -by (<|<=|==|>=|>)5.nnnn to select that line only for the listed perl +by (<|<=|==|>=|>)5.nnnn (up to two times) to +select that line only for the listed perl version; the whitespace and conditional are stripped. =head2 bcopts => $bcopts || [ @bcopts ] @@ -641,9 +642,10 @@ sub mkCheckRex { # strip out conditional lines - $str =~ s{^(.*?)\s+(<|<=|==|>=|>)\s*(5\.\d+)\ *\n} + $str =~ s{^(.*?) \s+(<|<=|==|>=|>)\s*(5\.\d+) + (?:\s+(<|<=|==|>=|>)\s*(5\.\d+))? \ *\n} { - my ($line, $cmp, $version) = ($1,$2,$3); + my ($line, $cmp, $version, $cmp2, $v2) = ($1,$2,$3,$4,$5,$6); my $repl = ""; if ( $cmp eq '<' ? $] < $version : $cmp eq '<=' ? $] <= $version @@ -651,11 +653,19 @@ sub mkCheckRex { : $cmp eq '>=' ? $] >= $version : $cmp eq '>' ? $] > $version : die("bad comparision '$cmp' in string [$str]\n") + and !$cmp2 || ( + $cmp2 eq '<' ? $] < $v2 + : $cmp2 eq '<=' ? $] <= $v2 + : $cmp2 eq '==' ? $] == $v2 + : $cmp2 eq '>=' ? $] >= $v2 + : $cmp2 eq '>' ? $] > $v2 + : die("bad comparision '$cmp2' in string [$str]\n") + ) ) { $repl = "$line\n"; } $repl; - }gem; + }gemx; $tc->{wantstr} = $str; diff --git a/ext/B/t/optree_constants.t b/ext/B/t/optree_constants.t index bfd355e0cc..d08c6be93d 100644 --- a/ext/B/t/optree_constants.t +++ b/ext/B/t/optree_constants.t @@ -348,7 +348,8 @@ checkOptree ( name => 'lc*,uc*,gt,lt,ge,le,cmp', # n <$> const[PV "b-cmp-a"] s ->o # p <;> nextstate(main 916 optree_constants.t:313) v:>,<,%,{ ->q # q <$> const[PVNV 0] s/SHORT ->r < 5.017002 -# q <$> const[PVNV 0] s/FOLD,SHORT ->r >=5.017002 +# q <$> const[PVNV 0] s/FOLD,SHORT ->r >=5.017002 < 5.019001 +# q <$> const[SPECIAL sv_no] s/FOLD,SHORT ->r >=5.019001 EOT_EOT # r <1> leavesub[1 ref] K/REFC,1 ->(end) # - <@> lineseq KP ->r |