This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Father Chrysostomos [Thu, 16 Oct 2014 12:48:18 +0000 (05:48 -0700)]
perldelta for our declarations
f5b5c2a Simplify double-nextstate optimisation
5afbd73 Elide our($foo) from execution order in void cx
8717a76 op.c: Null list and pushmark in void cx
Chris 'BinGOs' Williams [Thu, 16 Oct 2014 12:15:02 +0000 (13:15 +0100)]
Update Test-Simple to CPAN version 1.001008
[DELTA]
1.001008 Wed Oct 15 20:10:22:00 PST 2014
* Updated Changes file
1.001007 Wed Oct 15 16:37:11:00 PST 2014
* Fix subtest name when skip_all is used
Chris 'BinGOs' Williams [Thu, 16 Oct 2014 11:29:13 +0000 (12:29 +0100)]
Update B-Debug to CPAN version 1.22
[DELTA]
1.22 2014-10-12 rurban
* add 5.21.5 support: changed test, from blead for split optim.,
added METHOP
* print 0x00000000 as 0x0
* add -d -MOd=Debug support
* README: fixed copyright date
Chris 'BinGOs' Williams [Thu, 16 Oct 2014 11:27:15 +0000 (12:27 +0100)]
Update experimental to CPAN version 0.012
[DELTA]
0.012 2014-10-12 12:10:06+02:00 Europe/Amsterdam
Added lvalue references feature
Father Chrysostomos [Thu, 16 Oct 2014 03:37:30 +0000 (20:37 -0700)]
op.c: Null list and pushmark in void cx
See
7d3c8a6837 for the explanation.
‘our($foo,$bar);’ is one example of the legitimate use of list+push-
mark in void context.
Here, we can null them and remove them from the execution order, since
they are not necessary.
We only do this if this is an op sequence that padrange would not
optimise, since padrange needs a pushmark, and we don’t want to
disable it.
This combined with other recent optimisations makes code like this:
our ($foo,@bar,%baz);
our $a;
our ($b,$c);
die;
skip straight over all those variable declarations at run time, going
straight to the ‘die’.
Father Chrysostomos [Wed, 15 Oct 2014 19:58:18 +0000 (12:58 -0700)]
Elide our($foo) from execution order in void cx
our($foo) in void context has a compile-time affect but no run-item
effect, except to execute ops needlessly. There is no need to execute
those ops. We can simply remove them from the execution order.
‘our($foo,$fit,$far);’ still leaves a list and a pushmark, which I
plan to eliminate in the next commit.
‘our $foo; our $bar; our $baz;’ has no run-time cost now, because,
once the variables are eliminated, the nextstate ops in betwen them,
now adjacent, are also eliminated by another optimisation.
Jarkko Hietaniemi [Wed, 15 Oct 2014 02:52:28 +0000 (22:52 -0400)]
rt122747.t needs Unicode tables.
Jarkko Hietaniemi [Wed, 15 Oct 2014 02:50:34 +0000 (22:50 -0400)]
eintr.t needs Fcntl.
Jarkko Hietaniemi [Mon, 13 Oct 2014 00:44:02 +0000 (20:44 -0400)]
Irix: note that prctl comes in different incompatible flavors.
Jarkko Hietaniemi [Wed, 15 Oct 2014 22:26:41 +0000 (18:26 -0400)]
Irix: <float.h> thinks double-double has 107 bits of mantissa.
As opposed to 106.
Also add comment about the sizeof 12 versus 16 for x86 80-bit format.
Jarkko Hietaniemi [Wed, 15 Oct 2014 02:47:33 +0000 (22:47 -0400)]
Irix: MIPSpro 7.4 compiler has broken memcmp.
(Supposedly 7.4.1m is okay in this regard, and there is also 7.5.)
The commit that 'broke' Perl build on IRIX was
57620943
which of course wasn't to blame, the IRIX compiler was.
(Symptom: miniperl crashing, can be narrowed to just /[[:alpha:]]/)
Furthermore: IRIX build was also earlier broken for a long time by
another problem (in the preprocessor), see for example perl #33849.
(Symptom: compile failing in gv.c RvDEEPCP)
Summary: building Perls on IRIX needs either this very commit,
or undoing the
57620943 (for the memcmp brokenness), and possibly
applying both the
c297d531 and
08c5d564 (for the cpp brokenness).
(The latter were applied between 5.10.0 and 5.10.1.)
Shlomi Fish [Fri, 10 Oct 2014 07:12:09 +0000 (10:12 +0300)]
Modernized an example in perlipc.pod.
1. Convert to use strict + use warnings.
2. Changed a while(++ loop) to while(1) { ++ }.
Committer revised patch per suggestions in RT # 122938.
Dagfinn Ilmari Mannsåker [Wed, 15 Oct 2014 10:15:53 +0000 (11:15 +0100)]
Fix typo in
4cad5dc8's perldelta for 157fb5a
For: RT # 122981
Father Chrysostomos [Wed, 15 Oct 2014 05:52:29 +0000 (22:52 -0700)]
Deparse join("", pos) correctly
I optimised join into stringify if it had a list of one scalar-
returning op.
$ ./perl -Ilib -MO=Deparse -e '$_ = join $foo, $bar'
$_ = "$bar";
-e syntax OK
The problem, though, is that we now create op trees that didn’t happen
before,* and B::Deparse can’t handle them correctly:
$ ./perl -Ilib -MO=Deparse -e '$_ = join $foo, pos'
$_ = "pos($_)";
-e syntax OK
So we need to turn that into:
$_ = join('???', pos);
* Actually, in 5.8 it was possible to interpolate arbitrary expres-
sions after ‘$_[0]->’:
$_ = "\n,rekcah lreP rehtona tsuJ"; sub a{chop}
print "${[bless[]]}[0]->a . reverse $_";
And that, consequently, did not deparse properly.
Father Chrysostomos [Wed, 15 Oct 2014 04:56:25 +0000 (21:56 -0700)]
Change OA_DANGEROUS description in regen/opcode*
‘Has side effects’ can be misleading. The OA_DANGEROUS flag is only
used by the common-vars search that checks to see whether it is possi-
ble to skip making temporary copies.
We have to make copies in cases like this:
($a,$b) = func();
because func() could return ($b,$a).
If any op on either side is marked OA_DANGEROUS and not handled spe-
cially in op.c:S_aassign_scommon_vars, then it is assumed it could
return a scalar that is also elsewhere in the list, so a temp copy
is needed.
(I think some of the existing ops with this flag could drop it.)
Father Chrysostomos [Tue, 14 Oct 2014 03:37:29 +0000 (20:37 -0700)]
Simplify double-nextstate optimisation
Executing two nextstate ops in a row is equivalent to executing just
the second, so the peephole optimiser eliminates one of them.
The double-nextstate optimisation seems to have been written under
the assumption that the current op cannot be elided from the op_next
change, which is untrue, as we have oldop (the previous op in
the chain).
If the current op and the one following it are both nextstate ops,
then the contents of the second are moved over to the first and the
second is nulled. Then current_op->op_next is adjusted to skip over
the newly-nulled op.
The the next op in the chain, the one that the first nextstate op now
points to, is processed.
The result is that every other nextstate in sequence of three or more
would be elided:
1 <;> nextstate(main 1 -e:1) v ->2
- <0> ex-const v ->-
- <0> null v ->-
- <0> ex-const v ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
- <0> ex-const v ->-
- <0> null v ->-
- <0> ex-const v ->3
3 <;> nextstate(main 1 -e:1) v:{ ->4
- <0> ex-const v ->-
- <0> null v ->-
- <0> ex-const v ->4
4 <;> nextstate(main 1 -e:1) v:{ ->5
We don’t need to go through the complication of making the first next-
state equivalent to the second. Just null the first one and adjust
the previous op’s pointer (oldop->op_next) to point to the second one.
Now all consecutive nextstates get nulled except the last:
- <0> ex-nextstate v ->-
- <0> ex-const v ->-
- <0> ex-nextstate v ->-
- <0> ex-const v ->-
- <0> ex-nextstate v ->-
- <0> ex-const v ->-
- <0> ex-nextstate v ->-
- <0> ex-const v ->-
- <0> ex-nextstate v ->1
- <0> ex-const v ->-
- <0> ex-nextstate v ->1
- <0> ex-const v ->1
1 <;> nextstate(main 1 -e:1) v:{ ->2
The only visible difference this makes is in B::Deparse output, but
this changed in 5.14 when the optimisation was first introduced, so I
think changing it again is acceptable:
$ perl5.12.4 -MO=Deparse -e 'use strict; 0; use warnings; 0'
use strict 'refs';
'???';
use warnings;
'???';
-e syntax OK
$ perl5.14.4 -MO=Deparse -e 'use strict; 0; use warnings; 0'
use warnings;
use strict 'refs';
'???';
;
'???';
-e syntax OK
$ ./perl -Ilib -MO=Deparse -e 'use strict; 0; use warnings; 0'
;
'???';
use warnings;
use strict;
'???';
-e syntax OK
Tony Cook [Wed, 15 Oct 2014 00:44:34 +0000 (11:44 +1100)]
perldelta for
594b6face91a
Lukas Mai [Sun, 12 Oct 2014 17:01:09 +0000 (19:01 +0200)]
treat fatal warnings after syntax errors as syntax errors
Daniel Dragan [Tue, 14 Oct 2014 10:25:51 +0000 (06:25 -0400)]
fix comment from commit
f4eedc6b8c
David Mitchell [Tue, 14 Oct 2014 11:45:24 +0000 (12:45 +0100)]
fix op.c under -DPERL_GLOBAL_STRUCT
David Mitchell [Tue, 14 Oct 2014 11:26:13 +0000 (12:26 +0100)]
threads: $#shared = N should destroy
When shrinking a shared array by setting $#shared = N,
any freed elements should trigger destructors if they are objects,
but they weren't.
This commit extends the work done by
7d585d2f3001 (which created tmp
proxys when abandoning elements of arrays and hashes) to the STORESIZE
method, which is what is triggered by $#a assignment (and indirectly by
undef @a).
David Mitchell [Mon, 13 Oct 2014 11:45:14 +0000 (12:45 +0100)]
threads::shared "$#shared = N" off-by-one error
RT #122950
my @a : shared;
$#a = 3; # actually set it to 4
There was a simple off-by-one error in the XS code that handled the
STORESIZE tie method (confusing the array size and fill, which differ
by 1).
Amazingly, there was no test for it, and no-one had noticed up until now.
Note that this commit causes three tests in object2.t to fail: this
is because fixing the $#shared bug exposed another bug that was being
masked by this one. They will be fixed in the next commit
Tony Cook [Tue, 14 Oct 2014 00:48:33 +0000 (11:48 +1100)]
perldelta for
cae71c5daa29
Tony Cook [Thu, 2 Oct 2014 03:40:22 +0000 (13:40 +1000)]
deprecate POSIX::tmpnam
This patch avoids repeating the deprecation warning if the same tmpnam()
call is executed multiple times.
Father Chrysostomos [Mon, 13 Oct 2014 21:48:13 +0000 (14:48 -0700)]
aelemfast_lex in aassign_common_vars_aliases_only
S_aassign_common_vars_aliases_only needs to handle aelemfast_lex,
otherwise we miss some rare cases where we have aliased scalars and
elements on both sides of the assignment.
Father Chrysostomos [Mon, 13 Oct 2014 21:46:53 +0000 (14:46 -0700)]
Handle aelemfast_lex in S_aassign_common_vars
This was a missed opportunity for optimisation. Prior to be9de18 it
was optimised, because S_aassign_common_vars was called earlier in
the compilation phase, before the aelemfast optimisation.
Father Chrysostomos [Mon, 13 Oct 2014 19:35:49 +0000 (12:35 -0700)]
op.c: Skip priv flags assert if ppaddr changes
because an XS module is probably installing its own ppaddr, in which
case it knows more about the private flags than we do.
Daniel Dragan [Sun, 12 Oct 2014 07:42:38 +0000 (03:42 -0400)]
speed up building with less disk IO pod moves+__END__+misc
In Cwd.pm, dont search for pwd on Win32.
Also trim down the list of makefile suffixes on Win32 so it doesn't try
searching for av.pas and perl.f90 and hash.cbl on disk.
Add __END__ tokens to stop the last read() call on the handle which
returns 0 bytes at EOF.
Daniel Dragan [Mon, 13 Oct 2014 02:42:15 +0000 (22:42 -0400)]
remove excess whitespace from warnings.pm
Some lines end with spaces, remove that, use tabs instead of spaces in code
so the perl code is less bytes to read from disk. This patch saved 183
bytes. Part of [perl #122955].
Daniel Dragan [Mon, 13 Oct 2014 01:57:01 +0000 (21:57 -0400)]
move POD in warnings.pm to end of file to reduce module load I/O calls
warnings.pm is the hottest file/takes the most read() calls of any
module during a make all. By moving POD to the end, ~40KB of OS read()
IO was reduced to ~16KB of OS read() IO calls. Also the parser doesn't need
to search for Perl code in the POD further lessining load time because of
the __END__ token. Filed as [perl #122955].
Daniel Dragan [Mon, 13 Oct 2014 19:20:30 +0000 (15:20 -0400)]
silence warning after "Fold join to const or stringify where possible"
VC 2003
op.c(4022) : warning C4244: '=' : conversion from 'unsigned short' to
'char', possible loss of data
Father Chrysostomos [Mon, 13 Oct 2014 15:27:02 +0000 (08:27 -0700)]
[perl #122965] aelemfast in list assignment
I accidentally broke ($_[0],$_[1])=($_[1],$_[0]) in be9de18, which was
only supposed to be a refactoring. Since it now happens later in the
compilation phase when optimisations like aelemfast have happened, the
search for common vars needs to take aelemfast into account.
Father Chrysostomos [Mon, 13 Oct 2014 06:22:39 +0000 (23:22 -0700)]
perldelta for 73f4c4f
Father Chrysostomos [Mon, 13 Oct 2014 06:20:27 +0000 (23:20 -0700)]
perldelta for 987c969
Father Chrysostomos [Mon, 13 Oct 2014 06:17:44 +0000 (23:17 -0700)]
perldelta for afc8007
Father Chrysostomos [Mon, 13 Oct 2014 06:16:35 +0000 (23:16 -0700)]
perldelta for split-to-array
4ecee20 op.c: Distangle split and common-vars
fd017c0 Optimise @lexarray = split...
ef7999f Optimise my(@array)=split
4574270 opt.t: Test split-to-array optimisation
Father Chrysostomos [Mon, 13 Oct 2014 06:11:16 +0000 (23:11 -0700)]
perldelta for 821956c
Father Chrysostomos [Mon, 13 Oct 2014 06:08:58 +0000 (23:08 -0700)]
perldelta for de183bb
Father Chrysostomos [Mon, 13 Oct 2014 06:06:23 +0000 (23:06 -0700)]
perldelta for bcff414
Father Chrysostomos [Mon, 13 Oct 2014 06:05:47 +0000 (23:05 -0700)]
perldelta for deparsing with CORE:: prefix
3188a82 Deparse with CORE:: to avoid lex sub conflicts
e54915d Deparse sub calls quietly
7741cee Finish deparsing ‘my sub if; CORE::if...’
Father Chrysostomos [Mon, 13 Oct 2014 06:02:05 +0000 (23:02 -0700)]
perldelta for a21eb52
Father Chrysostomos [Mon, 13 Oct 2014 06:00:40 +0000 (23:00 -0700)]
perldelta for 4c62787/#122771
Father Chrysostomos [Mon, 13 Oct 2014 05:57:50 +0000 (22:57 -0700)]
perldelta for f8a7cce and 88a758b
Father Chrysostomos [Mon, 13 Oct 2014 05:56:11 +0000 (22:56 -0700)]
perldelta for 2258401
Father Chrysostomos [Mon, 13 Oct 2014 02:39:36 +0000 (19:39 -0700)]
perldelta for f351564 and 5f4d849
Father Chrysostomos [Mon, 13 Oct 2014 02:39:09 +0000 (19:39 -0700)]
perldelta for c8ec376
Father Chrysostomos [Mon, 13 Oct 2014 02:28:52 +0000 (19:28 -0700)]
perldelta for c997e36 and
6bd144e0f
Father Chrysostomos [Mon, 13 Oct 2014 01:11:48 +0000 (18:11 -0700)]
perldelta for 157fb5a
Father Chrysostomos [Mon, 13 Oct 2014 01:09:10 +0000 (18:09 -0700)]
perldelta for 1e9a122
Father Chrysostomos [Mon, 13 Oct 2014 01:07:12 +0000 (18:07 -0700)]
perldelta for 8fb0127
Father Chrysostomos [Mon, 13 Oct 2014 01:05:45 +0000 (18:05 -0700)]
Update perlguts for PADMY changes
Father Chrysostomos [Mon, 13 Oct 2014 01:04:38 +0000 (18:04 -0700)]
perlguts typo
Father Chrysostomos [Mon, 13 Oct 2014 01:02:44 +0000 (18:02 -0700)]
perldelta for PADMY changes
145bf8e Remove most uses of PADMY
a9f1090 Peek.t should not expect PADMY under 5.21.5
c068384 Stop setting PADMY; renumber PADSTALE
Father Chrysostomos [Mon, 13 Oct 2014 01:01:19 +0000 (18:01 -0700)]
perldelta for ecf05a5
Father Chrysostomos [Mon, 13 Oct 2014 00:58:32 +0000 (17:58 -0700)]
B: Document GPFLAGS
Father Chrysostomos [Mon, 13 Oct 2014 00:56:22 +0000 (17:56 -0700)]
perldelta for 14d9114
Father Chrysostomos [Sun, 12 Oct 2014 21:56:46 +0000 (14:56 -0700)]
perldelta for 926f5fc
Father Chrysostomos [Sun, 12 Oct 2014 21:53:29 +0000 (14:53 -0700)]
Jarkko Hietaniemi [Sun, 12 Oct 2014 21:43:48 +0000 (17:43 -0400)]
Tru64: S_mulexp10 overflow help.
Jarkko Hietaniemi [Sun, 12 Oct 2014 21:11:02 +0000 (17:11 -0400)]
infnan: if the mulexp10 value goes to zero, return it.
Tony Cook [Sun, 12 Oct 2014 23:14:28 +0000 (10:14 +1100)]
perldelta for
e78728e52f52
Dagfinn Ilmari Mannsåker [Wed, 8 Oct 2014 19:58:05 +0000 (20:58 +0100)]
Add support for Linux pipe buffer size fcntl commands
This lets us make t/io/eintr.t more reliable by making sure we're
actually writing more than the buffer size.
Father Chrysostomos [Sun, 12 Oct 2014 18:23:54 +0000 (11:23 -0700)]
Test croaks inadvertently rmvd by
bd2688c4c
Father Chrysostomos [Sun, 12 Oct 2014 18:22:49 +0000 (11:22 -0700)]
Revert "op.c: Don’t keep looping when we see potential common vars"
This reverts commit
bd2688c4c50527e5796ba4bc132c379f11e57112.
It seemed like an obvious optimisation, until it dawned on me that
this loop is doing two things, not just searching for common vars.
Father Chrysostomos [Sun, 12 Oct 2014 15:10:41 +0000 (08:10 -0700)]
Optimise "@_" to a single join
instead of stringify(join(...)).
Father Chrysostomos [Sun, 12 Oct 2014 13:58:11 +0000 (06:58 -0700)]
opt.t: Test split-to-array optimisation
Karl Williamson [Sun, 12 Oct 2014 15:53:24 +0000 (09:53 -0600)]
perldiag: Fix typo
Father Chrysostomos [Sun, 12 Oct 2014 13:48:08 +0000 (06:48 -0700)]
dump.c: Dump pmop patterns without trailing )
Father Chrysostomos [Sun, 12 Oct 2014 13:36:31 +0000 (06:36 -0700)]
Use full name for Perl_tmps_grow_p in EXTEND_MORTAL
For functions only exported and not public, we can’t use the short
forms in pubic macros.
Father Chrysostomos [Sat, 11 Oct 2014 17:40:52 +0000 (10:40 -0700)]
Test that my($self)=@_ uses no-common-vars optimisation
IIRC, this was broken in 5.10.0, but I don’t have a 5.10.0 around to
confirm (only 5.10.1).
Father Chrysostomos [Sat, 11 Oct 2014 08:21:12 +0000 (01:21 -0700)]
Fold join to const or stringify where possible
Due to the exigencies of the implementation, "$_->$*" ends up with a
join op (join $", $$_), which is unnecessary. This gave me the idea
of folding it where possible (instead of trying to tackle it in
toke.c), which would also make explicit joins benefit, too.
If the arguments are a simple scalar or constant followed by a
single-item list, then the join can become a stringify, and the sepa-
rator can simply disappear.
Further (and this is unrelated to "$_->$*"), if all of join’s argu-
ments are constant, the whole thing can be folded to a const op.
Father Chrysostomos [Sun, 12 Oct 2014 07:20:26 +0000 (00:20 -0700)]
Optimise my(@array)=split
Even though we can’t optimise away the array op for my(@array),
local(@array), and @{foo()}, we can still optimise away the assign-
ment. Just have split pop the array off the stack and Bob’s
your Uncle.
Father Chrysostomos [Sun, 12 Oct 2014 06:33:40 +0000 (23:33 -0700)]
Optimise @lexarray = split...
‘@pkgary = split //, $foo’ gets optimised such that the split writes
directly to the array and the assignment doesn’t have to happen.
This commit makes it work also with lexical arrays. It only works for
arrays declared previously; ‘my @a = split’ doesn’t get optimised,
just as ‘local @a = split’ doesn’t.
The pad offset is stored in the op_targ field of the pushre op, just
as the GV is stored in its op_pmreplrootu field.
Father Chrysostomos [Sun, 12 Oct 2014 06:24:00 +0000 (23:24 -0700)]
perlref: Document lvalue slice refs
Something I missed.
Father Chrysostomos [Sun, 12 Oct 2014 06:22:24 +0000 (23:22 -0700)]
Clarify two panic perldiag entries
Father Chrysostomos [Sun, 12 Oct 2014 06:17:43 +0000 (23:17 -0700)]
pp.c:pp_split: Remove redundant !s
SvPV always returns something (or croaks), so s cannot be null here.
Father Chrysostomos [Sun, 12 Oct 2014 00:17:32 +0000 (17:17 -0700)]
Fix ()=@a=split
@a=split//,$foo gets optimised such that split writes directly to
the array and the list assignment doesn’t happen. In fact, the list
assignment is completetly removed from the op tree:
$ ./perl -Ilib -MO=Concise -e '@a=split//,$foo'
7 <@> leave[1 ref] vKP/REFC ->(end)
1 <0> enter ->2
2 <;> nextstate(main 1 -e:1) v:{ ->3
6 <@> split[t2] vK/IMPLIM ->7
3 </> pushre(/""/ => @a) s/RTIME ->4
- <1> ex-rv2sv sK/1 ->5
4 <$> gvsv(*foo) s ->5
5 <$> const(IV 0) s ->6
-e syntax OK
(There would have been aassign where you see split if the optimisation
had not happened.)
($a,$b,$c) = split... optimises split by setting its limit argument
automatically so it doesn’t bother splitting into more parts than
necessary.
The latter optimisation was doing the wrong thing for () = @a = split,
because the @a=split on the rhs was being optimised down to a split
op. Then the limit optimisation would see an empty (or short) list on
the lhs and a split op on the rhs and see it as a candidate for lim-
ited split. So too few items would be assigned to the array.
We need to check whether the split on the rhs is a split-to-array
first before doing the limit optimisation. (If it is, then don’t
optimise.)
This breaks one of my JAPHs:
()=@==split" ","Just another Perl hacker,\n";
print reverse@=
Jarkko Hietaniemi [Thu, 9 Oct 2014 21:35:32 +0000 (23:35 +0200)]
infnan: test overflows and underflows.
Father Chrysostomos [Sat, 11 Oct 2014 17:24:33 +0000 (10:24 -0700)]
[Merge] Lvalue references
Also:
• Single refgen optimisation now applies to \@ \% \& as well.
• split-to-array no longer runs the risk of clobbering its argument
and returning junk.
• The split-to-array optimisation happens more often than before.
• foreach my $x is no longer subject to the list-assignment-after-ali-
asing bug (#89646).
Father Chrysostomos [Sat, 11 Oct 2014 07:00:55 +0000 (00:00 -0700)]
Document lvalue references
Father Chrysostomos [Sat, 11 Oct 2014 05:16:38 +0000 (22:16 -0700)]
Make Deparse.t more tolerant of our @F vs our(@F)
Currently B::Deparse deparses ‘our @F;’ as ‘our @F;’, but ‘our @F =...’
as ‘our(@F) = ...’, adding parentheses. For split-to-array, it just
happens to omit the parentheses, because there is no list op for it
to process, and it is when processing a list op that it decides to put
them there. While it could be changed to omit the parentheses for the
list or add them for split-to-array, for now just make the test more
tolerant, as this is just a cosmetic difference.
Father Chrysostomos [Sat, 11 Oct 2014 04:52:37 +0000 (21:52 -0700)]
Extend lex alias detection to foreach, too
Now that I have added a mechanism for detecting lexical aliases in
list assignments, we can extend that to foreach, too, to fix another
instance of the list-assignment-after-aliasing bug.
Father Chrysostomos [Sat, 11 Oct 2014 04:48:48 +0000 (21:48 -0700)]
Skip no-common-vars optimisation for lex aliases
Father Chrysostomos [Fri, 10 Oct 2014 23:44:58 +0000 (16:44 -0700)]
op.c: Move common vars check into the peephole optimiser
Putting it this late in the compilation phase will facilitate checking
for lexical aliases, too.
Father Chrysostomos [Fri, 10 Oct 2014 23:37:00 +0000 (16:37 -0700)]
Update B-Debug’s tests for split optimisation
This will have to be submitted upstream after this branch is merged.
Father Chrysostomos [Fri, 10 Oct 2014 15:45:29 +0000 (08:45 -0700)]
op.c: Distangle split and common-vars
The split-to-array optimisation was being skipped if the assignment
referenced the same variable on both sides, or if it referenced @_
(since @_ aliases other vars). This was to prevent split from freeing
its own argument when writing to the array.
As the previous commit shows, that didn’t actually work properly, and
so that commit used a different means to work around that problem.
So now there is no reason to skip the optimisation in such cases.
@_ = split;
@a = split //, $a[0];
now optimise away the assignment.
(This also allows me to move the common-vars check into the peep-
hole optimiser, where it needs to be to work correctly with lexi-
cal aliases.)
Father Chrysostomos [Fri, 10 Oct 2014 15:39:49 +0000 (08:39 -0700)]
Make split temporarily refcnt its argument
In this example, the @a=split... is optimised so that split writes to
@a directly:
*a = *b;
$a[1] = "foobarbaz";
@a = split //, $b[1];
print "@a\n";
But since @a and @b are the same, $b[1] gets freed even before the
split occurs. This just happens to work, because copy-on-write saves
the day, since the buffer is still valid, the "foobarbaz" constant
still holding on to it.
This modified example gives me junk:
*a = *b;
$a[1] = "foobarbaz";
$a[1] .= "";
@a = split //, $b[1];
print "@a\n";
The easiest solution is to make pp_split hold a temporary reference
count on the SV.
This will also allow the split optimisation to be disentangled from
the common-vars pessimisation (which fails here anyway). And *that*
will allow the common-vars pessimisation to take lexical aliases
into account.
Father Chrysostomos [Fri, 10 Oct 2014 05:05:15 +0000 (22:05 -0700)]
op.c:newASSIGNOP: Rmv LINKLIST call
Originally, aassign_common_vars used LINKLIST itself because it
was following op_next pointers. That changed in
3023b5f30, so the
LINKLIST was moved outside that function.
The LINKLIST call could not simply have been deleted, because the
split optimisation that follows assumes that it has been called and
fixes up an op_next pointer.
If we remove the LINKLIST call *and* the op_next fix-up, then every-
thing works. The op_next fix-up was only happening to begin with
because of LINKLIST.
Father Chrysostomos [Fri, 10 Oct 2014 04:54:12 +0000 (21:54 -0700)]
op.c: Don’t keep looping when we see potential common vars
When we loop through the list in LIST=..., once we have decided that
we need to do the more thorough check for common vars we don’t reverse
that decision based on subsequent ops, so there is no point in con-
tinuing to loop through them.
Father Chrysostomos [Thu, 9 Oct 2014 22:53:53 +0000 (15:53 -0700)]
lvref.t: Remove special TODO code
We no longer have a plethora of to-do tests, so this specialised code
no longer gains us anything.
Father Chrysostomos [Thu, 9 Oct 2014 22:51:18 +0000 (15:51 -0700)]
Store internal state of state vars separately
Use a separate pad entry to record whether a state variable has been
initialised, instead of using a flag on the value.
This prevents \$state_var = \$some_other_var from interfering with
that internal state. It probably also fixes some cases with foreach
as well, but I have not confirmed.
Father Chrysostomos [Thu, 9 Oct 2014 21:07:35 +0000 (14:07 -0700)]
lvref.t: More list and cond tests
Father Chrysostomos [Tue, 7 Oct 2014 05:12:27 +0000 (22:12 -0700)]
Deparse lvalue references
Father Chrysostomos [Sat, 4 Oct 2014 13:35:29 +0000 (06:35 -0700)]
lvref.t: Remove temporary eval & skip
Father Chrysostomos [Sat, 4 Oct 2014 13:31:11 +0000 (06:31 -0700)]
lvref.t: Fix hash elem tests
I was testing against a package hash for the ‘lexical’ tests.
Father Chrysostomos [Sat, 4 Oct 2014 02:50:45 +0000 (19:50 -0700)]
Handle state vars correctly in ref assignment
Only \state(@_) was handling this correctly, as pp_lvavref
calls pp_padav.
Father Chrysostomos [Fri, 3 Oct 2014 23:33:55 +0000 (16:33 -0700)]
lvref.t: Tests for \my assignment and scope exit
Father Chrysostomos [Fri, 3 Oct 2014 19:40:23 +0000 (12:40 -0700)]
Rework lvref.t foreach tests
Remove the to-do marker.
Add tests for package vars, too.
Redo the \my &a test. I’ve decided not to bother with the ‘my &a’
syntax for now (if at all). It is problematic and needs discussion.
(If ‘my &a’ is allowed in foreach, then it should be allowed else-
where, but ‘my &a;’ would call a stub.)
Father Chrysostomos [Fri, 3 Oct 2014 19:29:35 +0000 (12:29 -0700)]
Get foreach \&foo working
Previously these would crash. Usually, &foo is wrapped in an entersub
op which gets converted to rv2cv when refgen applies lvalue context.
In foreach \&foo, there is no need for us to go the entersub route;
rather we pass the original rv2cv op directly to refgen without the
entersub wrapping. So the resulting op tree is different. S_lvref
was not expecting this alternate op tree.
Father Chrysostomos [Fri, 3 Oct 2014 05:38:27 +0000 (22:38 -0700)]
foreach \$var
Some passing tests are still marked to-do. We need more tests still.