platform/upstream/perl.git
11 years agofix 114884 positive GPOS lookbehind regex substitution failure
Yves Orton [Sun, 16 Sep 2012 12:25:02 +0000 (14:25 +0200)]
fix 114884 positive GPOS lookbehind regex substitution failure

This also corrects a test added in 2c2969659ae1c534e7f3fac9e7a7d186defd9943 which was
arguably wrong. The details of \G are a bit fuzzy, and IMO its a little hard to say exactly
what is right, although it generally is clear what is wrong.

11 years agopp_match(): don't set REXEC_IGNOREPOS on 1st iter
David Mitchell [Sat, 22 Jun 2013 16:24:13 +0000 (17:24 +0100)]
pp_match(): don't set REXEC_IGNOREPOS on 1st iter

Currently all core callers of regexec set both the
REXEC_IGNOREPOS and REXEC_NOT_FIRST flags, or neither, depending
on whether this is the first or subsequent iteration of a //g;
*except* for one place in pp_match(), where REXEC_IGNOREPOS is set
on the first iteration for the one specific case of /g with an anchored
\G.

Now AFAICT this makes no difference, because the starting position
as calculated by regexec() still comes to the same value of
(strbeg + pos -gofs), and the same value og ganch calculated.

Also in the commit that added this particular use of the flag to pp_match,
(0ef3e39ecdfec), removing the flag makes no difference to the passing or
not of the new test case.

So I don't understand what its purpose it, and its possibly a mistake.
Removing it now makes the code simpler for further clearup.

11 years agopp_match(): stop setting $-[0] before regexec()
David Mitchell [Fri, 21 Jun 2013 20:44:45 +0000 (21:44 +0100)]
pp_match(): stop setting $-[0] before regexec()

It doesn't actually achieve anything.

11 years agopp_match: avoid setting $+[0]
David Mitchell [Fri, 21 Jun 2013 19:16:30 +0000 (20:16 +0100)]
pp_match: avoid setting $+[0]

This function sometimes set $+[0] to pos() before calling regexec().
This value isn't used by regexec(), and was really just a way of updating
the new start position for //g. Replace it with a local var instead.

11 years agopp_match(): eliminate unused t variable
David Mitchell [Fri, 21 Jun 2013 19:00:01 +0000 (20:00 +0100)]
pp_match(): eliminate unused t variable

and restrict usage of s variable

11 years agopp_match(): skip passing gpos arg to regexec()
David Mitchell [Thu, 20 Jun 2013 13:54:44 +0000 (14:54 +0100)]
pp_match(): skip passing gpos arg to regexec()

In one specific case, pp_match() passes the value of pos() to regexec()
via the otherwise unused 'data' arg.

It turns out that pp_match() only passes this value when it exists and is
>= 0, while regexec() only uses it when there's no pos magic or pos() < 0.

So its never used as far as I can tell.

So, strip it for now.

11 years agoadd some basic floating /\G/ tests
David Mitchell [Thu, 20 Jun 2013 13:22:42 +0000 (14:22 +0100)]
add some basic floating /\G/ tests

Floating is when the \G is an unknown number of characters from the start
of the pattern, such as /a+\G/. Surprisingly, there were no tests for this
form.

Here are a few basic tests just to exercise the main code paths. More
comprehensive tests could do with being added at some point.

11 years agofix /.\G/ under threading
David Mitchell [Thu, 20 Jun 2013 12:33:31 +0000 (13:33 +0100)]
fix /.\G/ under threading

When a regex was being duped, it's (constant) gofs field wasn't being
copied, but rather was being set to zero. Skip this and lots of TODO tests
pass.

11 years agoskip creating new capture COW SV if possible
David Mitchell [Wed, 19 Jun 2013 11:44:41 +0000 (12:44 +0100)]
skip creating new capture COW SV if possible

Each time we do a match, we currently (where possible) make a COW copy of
the just-matched string. This involves creating a new SV that shares the
same PVX buffer with the string. In a repeated match like while (/.../g),
that means the each time round we free the old capture SV and create a new
one.

As as optimisation, skip the free/create if the old capture SV is already
a COW clone of the match string.

11 years agomake Perl_reg_set_capture_string static
David Mitchell [Tue, 18 Jun 2013 15:34:43 +0000 (16:34 +0100)]
make Perl_reg_set_capture_string static

This function was introduced a few commits ago. Since it's now only
called from within regexec.c, make it static.

11 years agoadd intuit-only match to s///
David Mitchell [Tue, 18 Jun 2013 15:17:39 +0000 (16:17 +0100)]
add intuit-only match to s///

pp_match() has an intuit-only match mode: if intuit_start() succeeds and
the regex is marked as only needing intuit (RXf_CHECK_ALL), then calling
regexec() is skipped, and just $& set and then returns.

The commit which originally added that feature to pp_match() also added a
comment to pp_subst() suggesting that the same thing could be done there.

This commit finally achieves that. It builds on the previous commit (which
moved this mechanism from pp_match() directly into regexec()), skipping
calling intuit_start() and directly calling regexec() with the
REXEC_CHECKED flag not set.

This appears to reduce the execution time of a simple substitution
like s/abc/def/ by a fifth.

11 years agomove intuit call from pp_match() into regexec()
David Mitchell [Tue, 18 Jun 2013 13:44:12 +0000 (14:44 +0100)]
move intuit call from pp_match() into regexec()

Currently the main part of pp_match() looks like:

    if (can_use_intuit) {
        if (!intuit_start())
            goto nope;
        if (can_match_based_only_on_intuit_result) {
            ... set up $&, $-[0] etc ...
            goto gotcha;
        }
    }
    if (!regexec(..., REXEC_CHECKED|r_flags))
        goto nope;

  gotcha:
    ...

This rather breaks the regex API encapulation. The caller of the regex
engine shouldn't have to worry about whether to call intuit() or
regexec(), and to know to set $& in the intuit-only case.

So, move all the intuit-calling and $& setting into regexec itself.
This is cleaner, and will also shortly allow us to enable intuit-only
matches in pp_subst() too. After this change, the code above looks like
(in its entirety):

    if (!regexec(..., r_flags))
        goto nope;

    ...

There, isn't that nicer?

11 years agomake intuit_start() handle mixed utf8-ness
David Mitchell [Tue, 18 Jun 2013 11:29:16 +0000 (12:29 +0100)]
make intuit_start() handle mixed utf8-ness

Fix a bug in intuit_start() that makes it fail when the utf8-ness of the
string and pattern differ. This was mostly masked, since pp_match() skips
calling intuit in this case (and has done since 2000, presumably as a
workaround for this issue, and possibly for other issues since fixed).
But pp_subst() didn't skip, so code like this would fail:

    $c = "\x{c0}";
    utf8::upgrade($c);
    print "ok\n" if $c =~ s/\xC0{1,2}$/\xC0/i;

Now that intuit is (hopefully) fixed, also remove the guard in pp_match().

11 years agopp_match(): fix UTF* match setting
David Mitchell [Mon, 17 Jun 2013 16:38:41 +0000 (17:38 +0100)]
pp_match(): fix UTF* match setting

A recent commit did RX_MATCH_UTF8_set() based on the utf8-ness of the
pattern rather than the match string. I didn't matter because in that
branch they were guaranteed to have the same value, but fix it anyway,
both for correctness sake, and because it it *will* matter shortly

11 years agopp_match(): intuit can handle refs these days
David Mitchell [Sun, 16 Jun 2013 15:54:09 +0000 (16:54 +0100)]
pp_match(): intuit can handle refs these days

It looks like we no longer need to skip intuit-only matching when the
match is a ref or overloaded (e.g. $ref =~ /ARRAY/)

11 years agopp_match(): remove ret_no label
David Mitchell [Sun, 16 Jun 2013 15:09:07 +0000 (16:09 +0100)]
pp_match(): remove ret_no label

The nope: and ret_no: labels labelled the same point in the code.
Eliminate one of them.

11 years agopp_match(): combine intuit and regexec branches
David Mitchell [Sun, 16 Jun 2013 15:01:22 +0000 (16:01 +0100)]
pp_match(): combine intuit and regexec branches

There was some code that looked roughly like:

    if (can_match_on_intuit_only) {
        ....
        goto yup;
    }
    if (!regexec())
        goto ret_no;

  gotcha:
    A; B;
    if (simple)
        RETURNYES;
    X; Y;
    RETURN;

  yup:
    A;
    if (!simple)
        goto gotcha;
    B;
    RETURNYES

Refactor it to look like

    if (can_match_on_intuit_only) {
        ....
        goto gotcha;
    }
    if (!regexec())
        goto ret_no;

  gotcha:
    A; B;
    if (simple)
        RETURNYES;
    X; Y;
    RETURN;

As well as simplifying the code, it also avoids duplicating some work
(the 'A' above was done twice sometimes) - harmless but less efficient.

11 years agopp_match(): refactor intuit-only code
David Mitchell [Sun, 16 Jun 2013 14:45:20 +0000 (15:45 +0100)]
pp_match(): refactor intuit-only code

change

    if (intuit_only)
        goto yup:
    ...
  yup:
    A; B; X; Y;

to

    if (intuit_only)
        A; B;
        goto yup:
    ...
  yup:
    X; Y;

where A and B are intuit_only-specific steps while X and Y are done by the
regexec() branch too. This will shortly allow us to merge the two
branches.

11 years agopp_match(): minor refactor: consolidate RETPUSHYES
David Mitchell [Sun, 16 Jun 2013 14:38:56 +0000 (15:38 +0100)]
pp_match(): minor refactor: consolidate RETPUSHYES

Make the code slightly simpler by doing an early RETPUSHYES after success
where possible.

11 years agopp_match(): factor out some common code
David Mitchell [Sun, 16 Jun 2013 13:27:19 +0000 (14:27 +0100)]
pp_match(): factor out some common code

Some identical code is used in two separate branches to set pos()
after a successful match. Hoist the common code to above the branch.

11 years agore-enable intuit-only matches
David Mitchell [Sun, 16 Jun 2013 12:26:30 +0000 (13:26 +0100)]
re-enable intuit-only matches

The COW changes inadvertently disabled intuit-only matches.
These are where calling intuit_start() to find the starting point for a
match is enough to know that the whole pattern will match, and so you can
skip calling regexec() too. For example, fixed strings without captures
such as /abc/.

The COW breakage meant that regexec was always called, making something
like /abc/ abut 3 times slower.

This commit re-enables intuit-only matches.

However, it turns out that this opens up a can of worms.
Normally, recording the just-matched-against string so that things like $&
and captures work, is done within regexec(). When this is skipped,
pp_match has to do a similar thing itself. The code that does this (which
is in principle a copy of the code in regexec()) is a bit of a mess. Due
to a logic error, a big chunk of it has actually been dead code for 10+
years.  Its had lots of modifications (e.g. people have made the same
changes to regexec() and pp_match()), but since it never gets executed,
errors aren't detected. And the bits that are executed haven't completely
received all the COW and SAWAMERSAND updates that have happened recently.

The Best way to fix this is is to extract out the capture code in
regexec() into a separate function (which we did in the previous commit),
then throw away all the broken capture code in pp_match() and replace it
with a call to the new function (which this commit does).

One side effect of this commit is that as well as restoring intuit-only
behaviour for the patterns that used to pre-COW, it also enables this
behaviour for patterns which formerly didn't, namely where $& or //p are
seen.

This commit is the barest minimum necessary to fix this; subsequent
commits will clean and improve this.

11 years agoadd Perl_reg_set_capture_string() function
David Mitchell [Sat, 15 Jun 2013 16:54:10 +0000 (17:54 +0100)]
add Perl_reg_set_capture_string() function

Cut and paste into a separate function, the block of code in
regexec_flags() that is responsible (on successful match) for setting
RX_SAVED_COPY, RX_SUBBEG etc, ready for use by capture vars like $1, $&.

Although this function is currently only called from one place, we will
shortly use it elsewhere too.

This should contain no functional changes.

11 years agoperl5191delta: deep recursion warnings (07b2687d2/#118521)
Father Chrysostomos [Sun, 28 Jul 2013 06:21:24 +0000 (23:21 -0700)]
perl5191delta: deep recursion warnings (07b2687d2/#118521)

11 years ago[Merge] Constants, inlined subs, TARGs, ...
Father Chrysostomos [Fri, 26 Jul 2013 06:50:01 +0000 (23:50 -0700)]
[Merge] Constants, inlined subs, TARGs, ...

This branch fixes many inconsistencies in the way constants, inlinable
subroutines, and operator return values (TARGs) are handled.

• Constant folding no longer causes operators to return read-only sca-
  lars that would otherwise return mutable scalars (1+2, "thr"."ee").
• Modifying mutable scalars returned from operators no longer affects
  future return values (this affected the range operator).
• Subroutines like sub () {42} always return mutable scalars.
• Constants like 1 and "two" now always produce read-only scalars.
• Constants created by ‘use constant’ always return read-only scalars.
• Referencing an operator return value, or a constant under threads,
  no longer creates a new scalar, causing print \$_, \$_ to print two
  different addresses.

This list is not exhaustive.

11 years agoVersion number tweaks in tests and other cleanup
Father Chrysostomos [Fri, 26 Jul 2013 04:56:18 +0000 (21:56 -0700)]
Version number tweaks in tests and other cleanup

I didn’t have this constant stuff ready as soon as I expected.  I also
left a comment and a couple of ‘local $TODO’s lying around that don’t
need to be there.  As a bonus, correct a typo in constant.pm’s docu-
mentation.

11 years agopad.c apidocs: Clarify use of &PL_sv_no
Father Chrysostomos [Fri, 26 Jul 2013 04:46:22 +0000 (21:46 -0700)]
pad.c apidocs: Clarify use of &PL_sv_no

specifically with regard to possible future changes.

11 years agoFix up IO::Compress tests
Father Chrysostomos [Thu, 25 Jul 2013 07:32:49 +0000 (00:32 -0700)]
Fix up IO::Compress tests

They were expecting \"abc" to return a constant value, but constant
folding no longer causes \ to return a read-only scalar.

11 years agoIncrease $XS::APItest::VERSION to 0.55
Father Chrysostomos [Wed, 24 Jul 2013 18:00:08 +0000 (11:00 -0700)]
Increase $XS::APItest::VERSION to 0.55

11 years agoStop op freeing from interfering with sub(){42} mutability
Father Chrysostomos [Wed, 24 Jul 2013 15:39:01 +0000 (08:39 -0700)]
Stop op freeing from interfering with sub(){42} mutability

The problem is that when an OP_CONST is freed, it calls pad_swipe,
which clears the PADTMP flag when removing the SV from the pad.  Since
PADTMP no longer necessarily means ‘in a pad’, we shouldn’t turn
this flag off.

11 years agofresh_perl.t: Make the test for #3066 more explicit
Father Chrysostomos [Wed, 24 Jul 2013 15:35:46 +0000 (08:35 -0700)]
fresh_perl.t: Make the test for #3066 more explicit

This test was added to make sure that constants don’t become undefined
as a result of being shared between ops.

What was tested, though, was a side-effect, and not the actual bug
itself.

This behaviour has changed (sub(){42} now returns a mutable val-
ue), so this test needs to change, too.  It was only passing under
ithreads, and only as the result of another bug, which the next com-
mit will fix.

11 years agoMake overloaded constants always read-only
Father Chrysostomos [Wed, 3 Jul 2013 02:53:05 +0000 (19:53 -0700)]
Make overloaded constants always read-only

They were not read-only if the constant handler returned a shared
hash key scalar.

This was brought up in bug #109744.

11 years agoDon’t check IS_PADCONST in pad.c:pad_alloc
Father Chrysostomos [Wed, 3 Jul 2013 01:29:43 +0000 (18:29 -0700)]
Don’t check IS_PADCONST in pad.c:pad_alloc

Since recent commits have given constants &PL_sv_no names, this check
is redundant, since any slots for constants will have been skipped
over by the sv != &PL_sv_undef check just above.

11 years agopad.c: Don’t copy shared hash key targets when cloning
Father Chrysostomos [Wed, 3 Jul 2013 01:25:48 +0000 (18:25 -0700)]
pad.c: Don’t copy shared hash key targets when cloning

When creating a new thread, don’t treat shared hash key targets as
constants.  (See the previous commit for explanation.)

This should cause no change in behaviour, because the new target will
not be in use, and its next use will immediately overwrite its value.
It just saves having to copy a string that will be overwritten.

11 years agoStop shared hash key TARGs from being shared
Father Chrysostomos [Wed, 3 Jul 2013 01:18:13 +0000 (18:18 -0700)]
Stop shared hash key TARGs from being shared

A CV has a list of pads containing a different pad for each recursion
level.  pad_push, which adds a new pad to the list, copies some items
from pad no. 1 but not others.  In particular op targets¹ are created
anew, but, under ithreads, constants² are not.  Historically, these
were distinguished from each other by flags on the value.  Any read-
only or shared hash key scalar was considered to be a constant, and
hence shared between pads.  The target returned by ref() is a shared
hash key scalar, so it was being shared between recursion levels.
Recent commits have made it possible to distinguish between constants
and targets based on the name.  Formerly, both were nameless pad
entries.  Now constants have zero-length names (PadnamePV(name) &&
!PadnameLEN(name)).  So we can use that to fix this bug.

¹ Many operators return the same scalar each time, for efficiency.
  This is stored in the pad, and is known as the target, or TARG.
² Constanst are stored in the pad under ithreads, instead of being
  attached directly to ops, as they are under non-threaded builds.

11 years ago[perl #79908] Stop sub inlining from breaking closures
Father Chrysostomos [Mon, 1 Jul 2013 03:26:34 +0000 (20:26 -0700)]
[perl #79908] Stop sub inlining from breaking closures

When a closure closes over a variable, it references the variable
itself, as opposed to taking a snapshot of its value.

This was broken by the constant optimisation added for
constant.pm’s sake:

{
    my $x;
    sub () { $x };  # takes a snapshot of the current value of $x
}

constant.pm no longer uses that mechanism, except on older perls, so
we can remove this hack, causing code like this this to start work-
ing again:

BEGIN{
    my $x = 5;
    *foo = sub(){$x};
    $x = 6
}
print foo; # now prints 6, not 5

11 years agoMake sub(){42} return a mutable value
Father Chrysostomos [Sun, 30 Jun 2013 21:51:37 +0000 (14:51 -0700)]
Make sub(){42} return a mutable value

But only make it do so in lvalue context.  This will be just as fast
in true rvalue context.  In either case, it is still inlined.

This makes sub () { 42 } and sub () { return 42 } do the same thing.

It also means that sub () { '-'x75 } reverts back to returning a muta-
ble value, the way it did in 5.16.  From now on, tweaks to constant
folding will no longer affect the mutability of the return value of a
nullary function.

‘use constant’ is unaffected.  It still returns read-only values.

This was brought up in ticket #109744.

11 years agoTweak optree_constants.t for inlined list consts
Father Chrysostomos [Sun, 30 Jun 2013 07:40:58 +0000 (00:40 -0700)]
Tweak optree_constants.t for inlined list consts

11 years agoUpdate constant.pm to reflect list inlinement
Father Chrysostomos [Sun, 30 Jun 2013 07:26:46 +0000 (00:26 -0700)]
Update constant.pm to reflect list inlinement

I also removed ‘some symbols may be redefined without generating a
warning’.  I know not to what it refers.  It has been there as long as
constant.pm has.  If a constant is clobbered by another constant with
the same value, there is no warning, as it is harmless.  That may be
to what it refers, but we don’t need a caveat for that.

11 years agoInline list constants
Father Chrysostomos [Sun, 30 Jun 2013 07:20:33 +0000 (00:20 -0700)]
Inline list constants

These are inlined the same way as 1..5.  We have two ops:

  rv2av
    |
    `-- const

The const op returns an AV, which is stored in the op tree, and then
rv2av flattens it.

11 years agoconstant.pm: Make list constants read-only
Father Chrysostomos [Sun, 30 Jun 2013 06:59:48 +0000 (23:59 -0700)]
constant.pm: Make list constants read-only

Here we take advantage of the array-ref-stash-elem mechanism added in
the previous commit, which causes the actual elements of the stored
array to be pushed on to the stack.

11 years agoAllow stash elems to be array refs
Father Chrysostomos [Sun, 30 Jun 2013 06:33:14 +0000 (23:33 -0700)]
Allow stash elems to be array refs

These turn into CVs that return the contents of the array.  Future
commits will make constant.pm use these and also make them inlinable.

Even without inlining, these subs are faster, because they are XSUBs:

$ time ./perl -Ilib -e 'my @a=1..1000000; sub foo { @a } () = foo for 1..10'

real 0m3.725s
user 0m3.407s
sys 0m0.227s
$ time ./perl -Ilib -e 'my @a=1..1000000; BEGIN { $::{foo} = \@a } () = foo for 1..10'

real 0m2.153s
user 0m1.949s
sys 0m0.121s

11 years agoIncrease $constant::VERSION to 1.28
Father Chrysostomos [Sat, 29 Jun 2013 01:25:28 +0000 (18:25 -0700)]
Increase $constant::VERSION to 1.28

11 years agoStop constant.pm from (ab)using subs for scalars
Father Chrysostomos [Fri, 28 Jun 2013 08:27:48 +0000 (01:27 -0700)]
Stop constant.pm from (ab)using subs for scalars

under versions that support $::{foo} = \1.

This changes no behaviour.  Future commits will change the way
sub(){42} and sub(){$forty_two} work.  (The former will return a muta-
ble value; the latter will not be inlined at all.)

11 years ago[perl #78194] Make re-evals copy PADTMPs
Father Chrysostomos [Fri, 28 Jun 2013 01:11:48 +0000 (18:11 -0700)]
[perl #78194] Make re-evals copy PADTMPs

So that \$_ == \$_ will be true in "$foo$bar" =~ /(?{...})/.

Many ops return the same scalar each time, for efficiency; refgen (\)
knows about that and copies them, to hide the implementation detail,
but other constructs, such as regular expression code blocks in this
case, need to do the same thing.

11 years ago[perl #78194] Make sort copy PADTMPs
Father Chrysostomos [Thu, 27 Jun 2013 21:37:14 +0000 (14:37 -0700)]
[perl #78194] Make sort copy PADTMPs

Copy PADTMPs (op return values) when there is a sort block/sub that is
not optimised away and we are not sorting in place, so that \$a == \$a
will return true.

Many ops return the same scalar each time, for efficiency; refgen (\)
knows about that and copies them, to hide the implementation detail,
but other ops (sort in this case) need to do the same thing.

11 years ago[perl #78194] Make x copy PADTMPs in lv cx
Father Chrysostomos [Tue, 25 Jun 2013 04:28:36 +0000 (21:28 -0700)]
[perl #78194] Make x copy PADTMPs in lv cx

So that \(("$a")x2) will give two references to the same scalar, the
way that \(($a)x2) does.

11 years ago[perl #78194] Make list slices copy PADTMPs in lv cx
Father Chrysostomos [Tue, 25 Jun 2013 03:16:30 +0000 (20:16 -0700)]
[perl #78194] Make list slices copy PADTMPs in lv cx

So that slices that reference the same value multiple times (such as
(...)[1,1]) will exhibit referential identity (\(...)[1,1] will return
two references to the same scalar).

11 years agoStop folding of ops from changing mutability
Father Chrysostomos [Sun, 23 Jun 2013 14:08:24 +0000 (07:08 -0700)]
Stop folding of ops from changing mutability

If $a+$b produces a mutable value, then so should 1+2.

11 years ago[perl #78194] Make foreach copy pad tmps
Father Chrysostomos [Sun, 23 Jun 2013 14:06:49 +0000 (07:06 -0700)]
[perl #78194] Make foreach copy pad tmps

before aliasing them to $_.

This caused one to-do test in sub.t to pass, but the bug it is testing
for has not been fixed, so I added another one.  I didn’t remove the
to-do test that started passing, because it is still a good test to
have (the only test we have for interactions betwen foreach, shared
hash keys, and recursion).

11 years agoCorrect list.t descr in MANIFEST
Father Chrysostomos [Sun, 23 Jun 2013 06:04:13 +0000 (23:04 -0700)]
Correct list.t descr in MANIFEST

We don’t use the term ‘array’ for lists any more.  Also, mention
slices, since list slices are tested here.

11 years ago[perl #3105] Make 1..3 modification safe
Father Chrysostomos [Sun, 23 Jun 2013 01:46:00 +0000 (18:46 -0700)]
[perl #3105] Make 1..3 modification safe

This construct is optimised at compile time to an anonymous array with
an implicit @{} around it if both arguments are constant.  Modifying
elements of that array produces wrong results the next time the same
code is executed.

If we mark each element of the array as PADTMP, then it will be
treated like an operator’s return value (which it is) and get copied
as appropriate.

11 years agoconstant.t: Correct version
Father Chrysostomos [Sat, 22 Jun 2013 07:26:12 +0000 (00:26 -0700)]
constant.t: Correct version

I didn’t have this done in time for 5.19.1.

11 years ago[perl #78194] Make sub calls copy pad tmps
Father Chrysostomos [Thu, 20 Jun 2013 21:32:15 +0000 (14:32 -0700)]
[perl #78194] Make sub calls copy pad tmps

before aliasing them to elements of @_.

11 years agoIncrease $OptreeCheck::VERSION to 0.10
Father Chrysostomos [Thu, 20 Jun 2013 21:13:20 +0000 (14:13 -0700)]
Increase $OptreeCheck::VERSION to 0.10

though I still don’t understand why it has a version at all.

11 years ago[perl #78194] Make grep/map copy pad tmps
Father Chrysostomos [Thu, 20 Jun 2013 13:04:59 +0000 (06:04 -0700)]
[perl #78194] Make grep/map copy pad tmps

before aliasing them to $_.

And make sure the copies go back on the stack for grep, since modi-
fying $_ in the grep block or expression is supposed to modify the
item returned.

11 years agopad.c: cast before comparing signed with unsigned
Father Chrysostomos [Thu, 20 Jun 2013 12:25:01 +0000 (05:25 -0700)]
pad.c: cast before comparing signed with unsigned

11 years agoop.c: Stop copying constants under ithreads
Father Chrysostomos [Wed, 19 Jun 2013 03:34:21 +0000 (20:34 -0700)]
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.

11 years agopad.c: Expand pad_push SVf_READONLY explanation
Father Chrysostomos [Tue, 18 Jun 2013 23:51:57 +0000 (16:51 -0700)]
pad.c: Expand pad_push SVf_READONLY explanation

11 years agopad.c: Use &PL_sv_no for const pad names
Father Chrysostomos [Sun, 16 Jun 2013 21:00:01 +0000 (14:00 -0700)]
pad.c: Use &PL_sv_no for const pad names

Currently &PL_sv_undef as a pad name can indicate either a free slot
available for use by pad_alloc or a slot used by an op target (or,
under ithreads, a constant or GV).

Currently pad_alloc distinguishes between free slots and unnamed slots
based on whether the value in the pad has PADMY or PADTMP set.  If
neither is set, then the slot is free.  If either is set, the slot
is in use.

This makes it rather difficult to distinguish between constants stored
in the pad (under ithreads) and targets.  The latter need to be copied
when referenced, to give the impression that a new scalar is being
returned by an operator each time.  (So \"$a" has to return a refer-
ence to a new scalar each time, but \1 should return the same one.)
Also, constants are shared between recursion levels.  Currently, if
the value is marked READONLY or is a shared hash key scalar, it is
shared.  But targets can also me shared hash keys, resulting in bugs.

It also makes it impossible for the same constant to be shared by mul-
tiple pad slots, as freeing one const op will turn off the PADTMP flag
while the other slot still uses it, making the latter appear to be
free.  Hence a lot of copying occurs under ithreads.  (Actually, that
may not be true any more since 3b1c21fabed, as freed const ops swipe
their constants from the pad.  But right now, a lot of copying does
still happen.)

Also, XS modules may want to create const ops that return the same
mutable SV each time.  That is currently not possible without
various workarounds including custom ops and references.  (See
<https://rt.perl.org/rt3/Ticket/Display.html?id=105906#txn-1075354>.)

This commit changes pad_alloc and pad_free to use &PL_sv_no for con-
stants and updates other code to keep all tests passing.  Subsequent
commits will actually use that information to fix bugs.

This will probably break PadWalker, but I think it is an acceptable
trade-off.  The alternative would be to make PadnamePV forever more
complex than necessary, by giving it a special case for &PL_sv_no and
having it return NULL.

I gave PadnameLEN a special case for &PL_sv_undef, so it may appear
that I have simply shifted the complexity around.  But if pad names
stop being SVs, then this exception will simply disappear, since the
global &PL_padname_undef will have 0 in its length field.

11 years agoRe(mov|writ)e two comments from pad.c:pad_alloc
Father Chrysostomos [Sun, 16 Jun 2013 19:40:05 +0000 (12:40 -0700)]
Re(mov|writ)e two comments from pad.c:pad_alloc

The thing about "foreach" index vars was added in bbce6d697 (insepar-
able changes from patch from perl5.003_08 to perl5.003_09, presuma-
bly the ‘Lexical scoping cleanup’ part).  It is not valid, because
‘foreach’ doesn’t aliases a pad entry to a non-pad (not marked PADMY
or PADTMP) value until run time, and pad_alloc happens at compile
time.  The real reason we need this loop is that entries that close
over unavailable variables are not marked PADMY.  That may have been a
mistake, but it works because of this loop.  The reason for the loop
also may have changed over time.

The comment about copying to sv is not valid, because it is used later
on in the same condition when compared to &PL_sv_undef.  It was added
in commit dd2155a49b.

11 years agoop.c:S_fold_constants: Add assertion
Father Chrysostomos [Sun, 16 Jun 2013 06:17:59 +0000 (23:17 -0700)]
op.c:S_fold_constants: Add assertion

This code correctly handles a value returned by a folded constant that
is a target or a mortal.

If it is neither, then it takes ownership of a reference count (with-
out doing SvREFCNT_inc), so it ends up sharing a reference count with
whatever owned it before.  That is only safe to do with immortals,
which is (afaict) the only other type of scalar that can get through
this code, so it is actually correct.

Changes elsewhere could easily break this, though, so add an
assertion.

11 years agoChange the tests for #3105 into to-dos
Father Chrysostomos [Sun, 16 Jun 2013 04:52:07 +0000 (21:52 -0700)]
Change the tests for #3105 into to-dos

instead of testing for the incorrect behaviour

11 years agoTest readonliness of overload constants
Father Chrysostomos [Sun, 16 Jun 2013 03:41:49 +0000 (20:41 -0700)]
Test readonliness of overload constants

including one to-do test

11 years agoTo-do test for #109746
Father Chrysostomos [Sun, 16 Jun 2013 03:29:16 +0000 (20:29 -0700)]
To-do test for #109746

11 years agoTest (im)mutability of constants and constant-like subs
Father Chrysostomos [Sun, 16 Jun 2013 03:24:55 +0000 (20:24 -0700)]
Test (im)mutability of constants and constant-like subs

including many to-do tests

11 years agoTest !0 and !1 immutability and singletonness
Father Chrysostomos [Sun, 16 Jun 2013 02:42:35 +0000 (19:42 -0700)]
Test !0 and !1 immutability and singletonness

The latter (for bug #114838) is a to-do test under ithreads.

11 years agoTest that literal numbers and strings are read-only
Father Chrysostomos [Sun, 16 Jun 2013 02:29:27 +0000 (19:29 -0700)]
Test that literal numbers and strings are read-only

including ${\3}, which currently fails under ithreads (and is hence a
to-do test).

11 years agoTo-do tests for perl #78194
Father Chrysostomos [Sun, 16 Jun 2013 02:14:14 +0000 (19:14 -0700)]
To-do tests for perl #78194

plus a regular (not to-do) test for an lvalue sub case that already
works properly.

11 years agoref.t: To-do test for retvals of folded ops
Father Chrysostomos [Sat, 15 Jun 2013 18:57:56 +0000 (11:57 -0700)]
ref.t: To-do test for retvals of folded ops

11 years agosub.t: To-do test for recursive shared-hash-keys TARGs
Father Chrysostomos [Sat, 15 Jun 2013 18:41:57 +0000 (11:41 -0700)]
sub.t: To-do test for recursive shared-hash-keys TARGs

This is only buggy under ithreads.

sub a {
  for (${\""}.${\""}) {
    $_ = $_[0] || __PACKAGE__;
    print "$_\n";
    a("road") unless $_[0];
    print "$_\n";
  }
}
a();

The outer call sets the scalar returned by ${\""}.${\""} to the cur-
rent package name.

The inner call sets it to "road".

Each call prints it twice, the outer call surrounding the inner call.
The output in 5.10-5.18 is:

main
road
road
road

because the inner call is clobbering the same scalar.  If __PACKAGE__
is changed to "main", it works, and prints

main
road
road
main

(as the script above also prints in 5.8.8).

11 years agoperldelta for d7d11da6a3
Tony Cook [Fri, 26 Jul 2013 01:17:02 +0000 (11:17 +1000)]
perldelta for d7d11da6a3

11 years ago[perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
Tony Cook [Fri, 26 Jul 2013 01:09:11 +0000 (11:09 +1000)]
[perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers

11 years agobump $Exporter::VERSION (and hence $Exporter::Heavy::VERSION)
Tony Cook [Fri, 26 Jul 2013 01:00:23 +0000 (11:00 +1000)]
bump $Exporter::VERSION (and hence $Exporter::Heavy::VERSION)

11 years ago[perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers
Tony Cook [Thu, 18 Jul 2013 06:03:19 +0000 (16:03 +1000)]
[perl #39739] Exporter::Heavy ignores custom $SIG{__WARN__} handlers

11 years ago[perl #39739] TODO test for Exporter respecting warning handlers
Tony Cook [Thu, 18 Jul 2013 06:02:29 +0000 (16:02 +1000)]
[perl #39739] TODO test for Exporter respecting warning handlers

11 years agolet Porting/cmpVERSION.pl know Exporter was moved to dist/
Tony Cook [Fri, 26 Jul 2013 00:54:13 +0000 (10:54 +1000)]
let Porting/cmpVERSION.pl know Exporter was moved to dist/

11 years agoUpdate ExtUtils-MakeMaker to CPAN version 6.72
Chris 'BinGOs' Williams [Wed, 24 Jul 2013 20:31:18 +0000 (21:31 +0100)]
Update ExtUtils-MakeMaker to CPAN version 6.72

  [DELTA]

6.72 Wed Jul 24 18:38:19 BST 2013
    No changes from 6.71_01

6.71_01 Wed Jul 24 09:31:07 BST 2013
    Bug Fixes:
    * Resolved more regressions in parse_version code

11 years agoUpdate Module-CoreList MANIFEST to include Utils.pm
Chris 'BinGOs' Williams [Wed, 24 Jul 2013 20:28:34 +0000 (21:28 +0100)]
Update Module-CoreList MANIFEST to include Utils.pm

11 years agoperlopentut: Fit verbatim lines into 79 columns
Karl Williamson [Wed, 24 Jul 2013 15:15:01 +0000 (09:15 -0600)]
perlopentut: Fit verbatim lines into 79 columns

11 years agoperlvar.pod: add a separate section on $& et al
David Mitchell [Wed, 24 Jul 2013 14:20:22 +0000 (15:20 +0100)]
perlvar.pod: add a separate section on $& et al

Add a new separate section explaining the performance issues of $`, $&
and $'; plus descriptions of the various workarounds like @-, /p and COW,
and which perl version they were each introduced in.

Then in the entries for each individual var, strip out any commentary
about performance, and just include a link to the new performance
section.

11 years agoEnglish.pm: update perl version where perf fixed
David Mitchell [Wed, 24 Jul 2013 13:18:22 +0000 (14:18 +0100)]
English.pm: update perl version where perf fixed

It still said that the performance of $`, $&, $' was fixed in 5.18.
Update that to 5.20, since COW wasn't enabled by default in 5.18.

11 years agoUpdate ExtUtils-MakeMaker to CPAN version 6.70
Chris 'BinGOs' Williams [Wed, 24 Jul 2013 07:04:25 +0000 (08:04 +0100)]
Update ExtUtils-MakeMaker to CPAN version 6.70

  [DELTA]

6.70 Tue Jul 23 21:55:23 BST 2013
    No changes from 6.69_09

6.69_09 Sun Jul 21 09:22:40 BST 2013
    Bug Fixes:
    * RT#86976 Fix version parsing bug introduced in 6.69_05
      Part Deux :)

6.69_08 Wed Jul 17 00:36:28 BST 2013
    Bug Fixes:
    * RT#86976 Fix version parsing bug introduced in 6.69_05

6.69_07 Tue Jul 16 15:32:25 BST 2013
    New features:
    * RT#4550 report the file created after make dist

    Bug Fixes:
    * RT#66113 strip control characters from ABSTRACT
    * RT#20662 Don't check for config.h if it doesn't exist

6.69_06 Fri Jul 12 14:49:32 BST 2013
    Bug Fixes:
    * RT#64163 clean_subdirs infinite loop if subdir already gone
    * RT#79348 doesn't support miniperl in installation paths

    Doc Fixes:
    * Fix META_MERGE example
    * RT#31053 Mention configure_requires in PREREQ_FATAL documentation
    * RT#14680 Document TEST_FILES usage with 'make test'
    * RT#21285 Document 'make veryclean'

6.69_05 Thu Jul 11 22:10:10 BST 2013
    Bug Fixes:
    * Resolve RT#9452 regression with
      parse_version() (Victor Efimov)
    * RT#28632 use LD and OPTIMIZE in recursive Makefile.PL
      invocations (Niko Tyni)

6.69_04 Wed Jul 10 11:48:22 BST 2013
    Cygwin Fixes:
    * Revert RT#54703 and apply patch from RT#69401 to
      resolve /cygdrive issues (Reini Urban)

6.69_03 Tue Jul  9 22:39:54 BST 2013
    Bug Fixes:
    * RT#61419 Avoid invisible interactive question when
      rebuilding Makefile (Slaven Rezic)
    * VERSION also now really handles v-strings correctly.

    Cygwin Fixes:
    * RT#54703 - Don't hardcode /cygdrive (Jerry Hedden)

    Misc:
    * Install into site when 5.12 or above

6.69_02 Tue Jul  2 13:12:51 BST 2013
    Bug Fixes:
    * [RT#86609] VERSION_FROM now handles v-strings correctly.
    * VERSION also now handles v-strings correctly.

    Misc:
    * Updated bundled CPAN::Meta and removed Version::Requirements

6.69_01 Thu Jun 20 12:49:45 BST 2013
    Win32 Fixes:
    * resolve regression on Win32 introduced in 6.67_01
      (bingos)

11 years agoMerge work automating generation of lib/.gitignore and lib/ subdir cleanup.
Nicholas Clark [Wed, 24 Jul 2013 07:36:18 +0000 (09:36 +0200)]
Merge work automating generation of lib/.gitignore and lib/ subdir cleanup.

This makes no changes to any installed code.

11 years agoGenerate the lib/ cleanup rules in the Win32 Makefiles from MANIFEST.
Nicholas Clark [Tue, 23 Jul 2013 08:16:08 +0000 (10:16 +0200)]
Generate the lib/ cleanup rules in the Win32 Makefiles from MANIFEST.

11 years agoGenerate the lib/ cleanup rules in Makefile.SH automatically from MANIFEST.
Nicholas Clark [Mon, 22 Jul 2013 20:10:09 +0000 (22:10 +0200)]
Generate the lib/ cleanup rules in Makefile.SH automatically from MANIFEST.

11 years agoRe-order clean-up rules to give a line for regen/lib_cleanup.pl to key off.
Nicholas Clark [Sat, 20 Jul 2013 19:18:05 +0000 (21:18 +0200)]
Re-order clean-up rules to give a line for regen/lib_cleanup.pl to key off.

The Win32 line C<-del /f *.def *.map> and the start of the Unix line
C<rm -f so_locations> are unlikely to change.

11 years agoRemove the EXTUTILSDIR macro from the Win32 makefiles.
Nicholas Clark [Sat, 20 Jul 2013 19:04:16 +0000 (21:04 +0200)]
Remove the EXTUTILSDIR macro from the Win32 makefiles.

It hasn't been used since commit e3160748789c8366 in Sept 2009 eliminated
the XSUBPP macro.

11 years agoDelete obsolete clean rules from Makefile.SH
Nicholas Clark [Sat, 20 Jul 2013 19:02:56 +0000 (21:02 +0200)]
Delete obsolete clean rules from Makefile.SH

Rules to clean lib/ExtUtils/CBuilder/t and lib/ExtUtils/ParseXS/t haven't
been needed since the modules were moved to cpan/ and dist/

11 years agoMove process() from Porting/pod_rules.pl to Porting/pod_lib.pl
Nicholas Clark [Mon, 22 Jul 2013 19:23:11 +0000 (21:23 +0200)]
Move process() from Porting/pod_rules.pl to Porting/pod_lib.pl

And document it.

11 years agoSome tidying of Porting/pod_rules.pl
Nicholas Clark [Sat, 20 Jul 2013 20:46:34 +0000 (22:46 +0200)]
Some tidying of Porting/pod_rules.pl

Iterate over the files in sorted order, instead of hash iteration order.
This means that in TAP mode test failures will have consistent numbers.
Provide a description for the first test when outputting TAP.
Use clearer variable names in process(), and avoid using // as this code will
soon be exposed to pre-5.10

11 years agoExtract the main processing loop of Porting/pod_rules/pl into process().
Nicholas Clark [Sat, 20 Jul 2013 20:08:37 +0000 (22:08 +0200)]
Extract the main processing loop of Porting/pod_rules/pl into process().

11 years agoMove verify_contiguous() from Porting/pod_rules.pl to Porting/pod_lib.pl
Nicholas Clark [Sat, 20 Jul 2013 14:55:37 +0000 (16:55 +0200)]
Move verify_contiguous() from Porting/pod_rules.pl to Porting/pod_lib.pl

And document it.

11 years agoRefactor the use of verify_contiguous() in pod_rules.pl
Nicholas Clark [Sat, 20 Jul 2013 14:46:02 +0000 (16:46 +0200)]
Refactor the use of verify_contiguous() in pod_rules.pl

Move the substitution from the callers in into verify_contiguous().
Pass in a regex object for the substitution.
Return the modified file contents from verify_contiguous().
Load Carp when verify_contiguous() is called, instead of at compile time.

11 years agoRemove 3 redundant lines from .gitignore
Nicholas Clark [Sat, 20 Jul 2013 12:08:41 +0000 (14:08 +0200)]
Remove 3 redundant lines from .gitignore

These test files are no longer generated in directories beneath lib/

11 years agoGenerate lib/.gitignore from MANIFEST.
Nicholas Clark [Sat, 20 Jul 2013 10:50:21 +0000 (12:50 +0200)]
Generate lib/.gitignore from MANIFEST.

It's possible to programmatically determine almost all the files and
directories which will be created in lib/ by building the extensions.
Hence add a new script regen/lib_cleanup.pl to do this.

This saves having to manually update lib/.gitignore to reflect changes in
the build products of extensions, which has become a small but reoccurring
instance of scut-work.

11 years agoOn failure, regen_lib.pl now generates diagnostics, not just "not ok".
Nicholas Clark [Mon, 22 Jul 2013 07:26:24 +0000 (09:26 +0200)]
On failure, regen_lib.pl now generates diagnostics, not just "not ok".

We have to stop using File::Compare's compare(), as it doesn't return
diagnostics about what went wrong.

11 years agoMove all the "special case" build products from lib/.gitignore to .gitignore
Nicholas Clark [Sat, 20 Jul 2013 09:08:53 +0000 (11:08 +0200)]
Move all the "special case" build products from lib/.gitignore to .gitignore

These are all the build products that we can't programmatically infer will be
generated from extensions in ext, dist and cpan.

11 years agoMake .gitignore and lib/.gitignore more consistent.
Nicholas Clark [Sat, 20 Jul 2013 08:33:00 +0000 (10:33 +0200)]
Make .gitignore and lib/.gitignore more consistent.

Move the ignore of lib/App/, lib/mro.pm, lib/TAP/, lib/Test/Harness.pm,
lib/File/DosGlob.pm, lib/inc/, Win32.pm, Win32API/ and Win32Core.pm from
.gitignore to lib/.gitignore, where they more logically belong.
Consistently use trailing / for ignored directories.
Add a leading / to the ignore of unicore/TestProp.pl
(The line was added by commit 3df51b85ce4a5664 in Nov 2009, and it's not
clear why it did not have a leading / from the start.)

Re-sort lib/.gitignore lexically.

11 years agoPrune some .gitignore files.
Nicholas Clark [Sat, 20 Jul 2013 08:10:12 +0000 (10:10 +0200)]
Prune some .gitignore files.

Class::ISA was removed by 3df51b85ce4a5664 in April 2010.
Module::Pluggable was removed by commit 482cac4d574f8c6c in May 2013.
Module/Build/ConfigData.pm was moved from lib/ to cpan/ by commit
0b93a7997e668a67 in Nov 2009.
Pod::Plainer was removed by commit afbe215fcafe7a92 in April 2010.
Shell was removed by commit a1e75797c204ade8 in June 2011.
Switch was removed by commit 75108aefc8b50fcf in April 2010.

11 years agoperldelta for ea382fac4c7
Tony Cook [Wed, 24 Jul 2013 07:31:03 +0000 (17:31 +1000)]
perldelta for ea382fac4c7

The versioning for dist/bignum was a little confused, hopefully I've
unconfused it