This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl5.git
9 years agoop.c:newMETHOP: Remove op_next check
Father Chrysostomos [Sun, 7 Dec 2014 19:34:24 +0000 (11:34 -0800)]
op.c:newMETHOP: Remove op_next check

This function is only called for OP_METHOD*.  It could conceivably be
called for OP_CUSTOM.

The only check functions in this case are ck_method, which does not
touch op_next, and ck_null, which does nothing.  So op_next could not
have been set.

9 years agoop.c:newUNOP_AUX: Rmv fold_constants/op_integerize
Father Chrysostomos [Sun, 7 Dec 2014 19:30:41 +0000 (11:30 -0800)]
op.c:newUNOP_AUX: Rmv fold_constants/op_integerize

This function is only called for OP_MULTIDEREF, which has no check
function.  It could conceivably be called for OP_CUSTOM.

Neither multideref nor custom ops have constant folding or integer
equivalents.

9 years agoop.c:newUNOP_AUX: Remove op_next check
Father Chrysostomos [Sun, 7 Dec 2014 19:29:00 +0000 (11:29 -0800)]
op.c:newUNOP_AUX: Remove op_next check

This function is only called for OP_MULTIDEREF, which has no check
function.  It could conceivably be called for OP_CUSTOM, but that also
has no check function.  So this op_next check is redundant, as nothing
could possibly have set op_next at this point.  (In fact, I think it‘s
redundant for newUNOP, too, but I’ll have to look into that.)

9 years agoop.c: Typo in docs for op_convert_list
Father Chrysostomos [Sun, 7 Dec 2014 18:58:07 +0000 (10:58 -0800)]
op.c: Typo in docs for op_convert_list

9 years agoop.c: Clarify newLISTOP docs
Father Chrysostomos [Sun, 7 Dec 2014 18:57:30 +0000 (10:57 -0800)]
op.c: Clarify newLISTOP docs

They seem to imply that you can call newLISTOP(OP_ANY_TYPE), but
almost all the time you want newLISTOP(OP_LIST) followed by
op_convert_list.

9 years agoConvert tabs to spaces and remove trailing space.
Shlomi Fish [Sat, 6 Dec 2014 17:17:36 +0000 (19:17 +0200)]
Convert tabs to spaces and remove trailing space.

For: RT #123377

9 years agoFix method assertion failures
Father Chrysostomos [Sun, 7 Dec 2014 18:37:50 +0000 (10:37 -0800)]
Fix method assertion failures

9 years agoTweak Deparse-core.t after the last two commits
Father Chrysostomos [Sun, 7 Dec 2014 14:52:23 +0000 (06:52 -0800)]
Tweak Deparse-core.t after the last two commits

9 years agoDeparse goto foo() correctly
Father Chrysostomos [Sun, 7 Dec 2014 06:41:43 +0000 (22:41 -0800)]
Deparse goto foo() correctly

See the previous commit.  The same applies to loop controls and similar
keywords.

9 years agoDeparse require(foo()) correctly
Father Chrysostomos [Sun, 7 Dec 2014 06:37:25 +0000 (22:37 -0800)]
Deparse require(foo()) correctly

require(foo()) deparses as require foo().  But require’s parsing is
eccentric, and does not allow require foo(), because ‘foo’ is treated
as a bareword there, and ‘require WORD’ does not allow () fol-
lowing it.

The same problem happens with do-file, which is fixed also by this
commit, since it follows the same code path.

9 years agoDeparse.pm:pp_entereval: Redundant func call
Father Chrysostomos [Sun, 7 Dec 2014 06:29:33 +0000 (22:29 -0800)]
Deparse.pm:pp_entereval: Redundant func call

unop calls $self->keyword, so we don’t need to.

9 years agoMake fileno() builtin work on directory handles
Aaron Crane [Fri, 17 Oct 2014 15:59:22 +0000 (16:59 +0100)]
Make fileno() builtin work on directory handles

This requires OS support in the form of either the dirfd() function, or a
dd_fd member in the DIR struct. POSIX.1-2008 specifies the former. If
neither is available, fileno() on a directory handle will return undef and
set errno.

9 years agoAdd OP_MULTIDEREF
David Mitchell [Fri, 24 Oct 2014 15:26:38 +0000 (16:26 +0100)]
Add OP_MULTIDEREF

This op is an optimisation for any series of one or more array or hash
lookups and dereferences, where the key/index is a simple constant or
package/lexical variable. If the first-level lookup is of a simple
array/hash variable or scalar ref, then that is included in the op too.

So all of the following are replaced with a single op:

    $h{foo}
    $a[$i]
    $a[5][$k][$i]
    $r->{$k}
    local $a[0][$i]
    exists $a[$i]{$k}
    delete $h{foo}

while these aren't:

    $a[0]       already handled by OP_AELEMFAST
    $a[$x+1]    not a simple index

and these are partially replaced:

    (expr)->[0]{$k}   the bit following (expr) is replaced
    $h{foo}[$x+1][0]  the first and third lookups are each done with
                      a multideref op, while the $x+1 expression and
                      middle lookup are done by existing add, aelem etc
                      ops.

Up until now, aggregate dereferencing has been very heavyweight in ops; for
example, $r->[0]{$x} is compiled as:

    gv[*r] s
    rv2sv sKM/DREFAV,1
    rv2av[t2] sKR/1
    const[IV 0] s
    aelem sKM/DREFHV,2
    rv2hv sKR/1
    gvsv[*x] s
    helem vK/2

When executing this, in addition to the actual calls to av_fetch() and
hv_fetch(), there is a lot of overhead of pushing SVs on and off the
stack, and calling lots of little pp() functions from the runops loop
(each with its potential indirect branch miss).

The multideref op avoids that by running all the code in a loop in a
switch statement. It makes use of the new UNOP_AUX type to hold an array
of

    typedef union  {
        PADOFFSET pad_offset;
        SV        *sv;
        IV        iv;
        UV        uv;
    } UNOP_AUX_item;

In something like $a[7][$i]{foo}, the GVs or pad offsets for @a and $i are
stored as items in the array, along with a pointer to a const SV holding
'foo', and the UV 7 is stored directly. Along with this, some UVs are used
to store a sequence of actions (several actions are squeezed into a single
UV).

Then the main body of pp_multideref is a big while loop round a switch,
which reads actions and values from the AUX array. The two big branches in
the switch are ones that are affectively unrolled (/DREFAV, rv2av, aelem)
and (/DREFHV, rv2hv, helem) triplets. The other branches are various entry
points that handle retrieving the different types of initial value; for
example 'my %h; $h{foo}' needs to get %h from the pad, while '(expr)->{foo}'
needs to pop expr off the stack.

Note that there is a slight complication with /DEREF; in the example above
of $r->[0]{$x}, the aelem op is actually

    aelem sKM/DREFHV,2

which means that the aelem, after having retrieved a (possibly undef)
value from the array, is responsible for autovivifying it into a hash,
ready for the next op. Similarly, the rv2sv that retrieves $r from the
typeglob is responsible for autovivifying it into an AV. This action
of doing the next op's work for it complicates matters somewhat. Within
pp_multideref, the autovivification action is instead included as the
first step of the current action.

In terms of benchmarking with Porting/bench.pl, a simple lexical
$a[$i][$j] shows a reduction of approx 40% in numbers of instructions
executed, while $r->[0][0][0] uses 54% fewer. The speed-up for hash
accesses is relatively more modest, since the actual hash lookup (i.e.
hv_fetch()) is more expensive than an array lookup. A lexical $h{foo}
uses 10% fewer, while $r->{foo}{bar}{baz} uses 34% fewer instructions.

Overall,
        bench.pl --tests='/expr::(array|hash)/' ...
gives:
              PRE   POST
           ------ ------

        Ir 100.00 145.00
        Dr 100.00 165.30
        Dw 100.00 175.74
      COND 100.00 132.02
       IND 100.00 171.11

    COND_m 100.00 127.65
     IND_m 100.00 203.90

with cache misses unchanged at 100%.

In general, the more lookups done, the bigger the proportionate saving.

9 years agoadd UNOP_AUX OP class
David Mitchell [Mon, 27 Oct 2014 17:33:32 +0000 (17:33 +0000)]
add UNOP_AUX OP class

This is the same as a UNOP, but with the addition of an op_aux field,
which points to an array of UNOP_AUX_item unions.

It is intended as a general escape mechanism for adding per-op-type extra
fields (or arrays of items) to UNOPs.

Its class character (for regen/opcodes etc) is '+'.

Currently there are no ops of this type; but shortly, OP_MULTIDEREF will
be added, which is the original motivation for this new op type.

9 years agoext/B/Makefile.PL: spot hex defines
David Mitchell [Sun, 2 Nov 2014 16:01:00 +0000 (16:01 +0000)]
ext/B/Makefile.PL: spot hex defines

The regex in ext/B/Makefile.PL was failing to find C constants of the
form

    #define FOO 0xNNN

where NNN contained one or more [a-fA-F] chars

With this change it imports a few more constants:

    CXTYPEMASK
    GVf_IMPORTED
    RV2CVOPCV_FLAG_MASK
    OPpARG4_MASK
    OPpPADRANGE_COUNTMASK

9 years agoPerl_op_sibling_splice(): update OPf_KIDS
David Mitchell [Thu, 30 Oct 2014 10:28:06 +0000 (10:28 +0000)]
Perl_op_sibling_splice(): update OPf_KIDS

Previously this function didn't update OPf_KIDS when altering the
children. This was only safe as long as the count of kids didn't transition
between 0 and !0.

9 years agoadd S_deb_padvar() to dump.c
David Mitchell [Fri, 24 Oct 2014 15:23:38 +0000 (16:23 +0100)]
add S_deb_padvar() to dump.c

factor out the code that prints a pad var name in -Dt output

9 years agoadd S_op_clear_gv() to op.c
David Mitchell [Thu, 7 Aug 2014 15:34:23 +0000 (16:34 +0100)]
add S_op_clear_gv() to op.c

Abstract out the code that clear an GV attached to an op,
since we will shortly need to do this in more than one place

9 years agocreate S_check_hash_fields() function
David Mitchell [Sun, 27 Jul 2014 19:59:48 +0000 (20:59 +0100)]
create S_check_hash_fields() function

factor out the code in S_finalize_op() that performs checks on hash keys
into a separate function, since we'll shortly need to call this code from
more than one place.

9 years agoIncrease $arybase::VERSION to 0.09
Father Chrysostomos [Sun, 7 Dec 2014 05:48:27 +0000 (21:48 -0800)]
Increase $arybase::VERSION to 0.09

9 years agogv_fetchmeth_sv now supports SV shared hashes
syber [Sun, 7 Dec 2014 00:26:04 +0000 (03:26 +0300)]
gv_fetchmeth_sv now supports SV shared hashes

gv_fetchmeth_internal added, which receives method name
both as SV and const char. Now it calls hv_common instead
of hv_fetch.

gv_fetchmeth_pvn and gv_fetchmeth_sv are now just wrappers
for gv_fetchmeth_internal

Result: x2 speedup for gv_fetchmeth_sv new SV is a shared hash

BEFORE
PVN - 28.5 Mcalls/s
SV SHARED HASH - 26 Mcalls/s

AFTER
PVN - 29.4 Mcalls/s
SV SHARED HASH - 51 Mcalls/s

9 years agoTweak sv_pos_b2u_flags check in pp_index
James Raspass [Sat, 6 Dec 2014 22:51:57 +0000 (22:51 +0000)]
Tweak sv_pos_b2u_flags check in pp_index

There's no need to run sv_pos_b2u_flags if the retval is one as
one byte can only be one character, therefore change the test to
"> 1". This makes index on unicode strings that match at 1 slightly
faster.

9 years agoRevert ‘Used pad name lists for pad ids’
Father Chrysostomos [Sun, 7 Dec 2014 01:21:13 +0000 (17:21 -0800)]
Revert ‘Used pad name lists for pad ids’

This reverts commit 8771da69db30134352181c38401c7e50753a7ee8.

Pad lists need to carry IDs around with them, so that when something
tries to close over a pad, it is possible to confirm that the right
pad is being closed over (either the original outer pad, or a clone of
it).  (See the commit message of db4cf31d1, in which commit I added an
ID to the padlist struct.)

In 8771da69 I found that I could use the memory address of the pad’s
name list (name lists are shared) and avoid the extra field.

Some time after 8771da69 I realised that a pad list could be freed,
and the same address reused for another pad list, so using a memory
address may not be so wise.  I thought it highly unlikely, though, and
put it on the back burner.

I have just run into that.  t/comp/form_scope.t is now failing
for me with test 13, added by db4cf31d1.  It bisects to 3d6de2cd1
(PERL_PADNAME_MINIMAL), but that’s a red herring.  Trivial changes
to the script make the problem go away.  And it only happens on non-
debugging builds, and only on my machine.  Stepping through with gdb
shows that the format-cloning is following the format prototype’s out-
side pointer and confirming that it is has the correct pad (yes, the
memory addresses are the same), which I know it doesn’t, because I can
see what the test is doing.

While generation numbers can still fall afoul of the same problem, it
is much less likely.

Anyway, the worst thing about 8771da69 is the typo in the first word
of the commit message.

9 years agoform_scope.t: Diagnostics for test 13
Father Chrysostomos [Sat, 6 Dec 2014 14:23:28 +0000 (06:23 -0800)]
form_scope.t: Diagnostics for test 13

9 years agoWin32 Intel C is always C99 now
Daniel Dragan [Sat, 6 Dec 2014 05:32:44 +0000 (00:32 -0500)]
Win32 Intel C is always C99 now

9 years agodeparse-skips.txt: Note why comp/parser.t fails
Father Chrysostomos [Sat, 6 Dec 2014 19:36:42 +0000 (11:36 -0800)]
deparse-skips.txt: Note why comp/parser.t fails

9 years agodeparse-skips.txt: comp/proto.t now passes
Father Chrysostomos [Sat, 6 Dec 2014 19:36:09 +0000 (11:36 -0800)]
deparse-skips.txt: comp/proto.t now passes

9 years agoDeparse & calls with scalar() where necessary
Father Chrysostomos [Sat, 6 Dec 2014 19:33:15 +0000 (11:33 -0800)]
Deparse & calls with scalar() where necessary

This is wrong:

$ ./perl -Ilib -mO=Deparse,-P -e 'sub foo($$){}; foo(bar(), baz())'
sub foo ($$) {

}
&foo(bar(), baz());
-e syntax OK

The resulting code calls bar and baz in list context.

9 years agoDeparse.pm:pp_entersub: Refactor repetition away
Father Chrysostomos [Sat, 6 Dec 2014 14:44:39 +0000 (06:44 -0800)]
Deparse.pm:pp_entersub: Refactor repetition away

I’m about to modify this code, and having two copies of the join(...)
is not so helpful.

9 years agoInitialize ab_op_info before use.
Jarkko Hietaniemi [Sun, 7 Dec 2014 00:03:45 +0000 (19:03 -0500)]
Initialize ab_op_info before use.

Balancing act between gcc/clang versions: some versions would
be happy with = { 0 }, some versions complain that with = { 0 }
some fields might be uninitialized.  (The latter might be known
stupidness with some gcc versions.)  But all versions I tested
seem to agree that Zero() (memset in disguise) will initialize.

9 years agoAdd a comment explaining what to do if this test fails.
Jarkko Hietaniemi [Sat, 6 Dec 2014 21:00:23 +0000 (16:00 -0500)]
Add a comment explaining what to do if this test fails.

9 years agothreads.pm version bump for 0c87ebb8.
Jarkko Hietaniemi [Sat, 6 Dec 2014 20:58:01 +0000 (15:58 -0500)]
threads.pm version bump for 0c87ebb8.

9 years agoFollowup 3f39ca90: those functions need no prototypes for ext/re.
Jarkko Hietaniemi [Sat, 6 Dec 2014 20:27:41 +0000 (15:27 -0500)]
Followup 3f39ca90: those functions need no prototypes for ext/re.

9 years agog++ groks __attribute__((unused)) at least since 4.3.6.
Jarkko Hietaniemi [Sat, 6 Dec 2014 15:14:30 +0000 (10:14 -0500)]
g++ groks __attribute__((unused)) at least since 4.3.6.

Cannot find the exact moment from gcc release notes, but tests fine in 4.3.6.
(not fine = "warning: unused ...")

9 years agoIf no lchown, not using the args.
Jarkko Hietaniemi [Sat, 6 Dec 2014 14:21:34 +0000 (09:21 -0500)]
If no lchown, not using the args.

9 years agoVariables possibly clobbered by longjmp/vfork.
Jarkko Hietaniemi [Sat, 6 Dec 2014 14:04:49 +0000 (09:04 -0500)]
Variables possibly clobbered by longjmp/vfork.

(my_perl in the line 480 has the same problem, but messier to fix.)

9 years agoThese functions are not used with ext/re.
Jarkko Hietaniemi [Sat, 6 Dec 2014 13:42:11 +0000 (08:42 -0500)]
These functions are not used with ext/re.

9 years agoB::Deparse: Escape non-ASCII printable chars
Father Chrysostomos [Sat, 6 Dec 2014 14:15:40 +0000 (06:15 -0800)]
B::Deparse: Escape non-ASCII printable chars

Before this, we were escaping all non-ASCII chars if the string con-
tained any non-printable chars.  So ".\x{100}" would come out exactly
like that, but "\x{100}" would be deparsed as "Ā", causing problems if
the script has no ‘use utf8’ in scope.

(It was also misbehaving on EBCDIC, causing the existing \x
test to fail.)

9 years agoDeparse.pm: Don’t call maybe_parens for sv_undef
Father Chrysostomos [Sat, 6 Dec 2014 14:01:03 +0000 (06:01 -0800)]
Deparse.pm: Don’t call maybe_parens for sv_undef

(LIST)[INDEX] is neat, but it doesn’t short-circuit, so it should not
be used if LIST contains method calls.

9 years agoRemove comp/opsubs.t from deparse-skips.txt
Father Chrysostomos [Sat, 6 Dec 2014 06:44:56 +0000 (22:44 -0800)]
Remove comp/opsubs.t from deparse-skips.txt

It passes.  Since when I don’t know.

9 years agoRemove comp/hints.t from deparse-skips.txt
Father Chrysostomos [Sat, 6 Dec 2014 06:43:40 +0000 (22:43 -0800)]
Remove comp/hints.t from deparse-skips.txt

It passes, probably due to BEGIN block fixes.

9 years agodeparse-skips.txt: Note some skip reasons
Father Chrysostomos [Sat, 6 Dec 2014 06:41:49 +0000 (22:41 -0800)]
deparse-skips.txt: Note some skip reasons

9 years agoRemove comp/form_scope.t from deparse-skips.txt
Father Chrysostomos [Sat, 6 Dec 2014 06:40:15 +0000 (22:40 -0800)]
Remove comp/form_scope.t from deparse-skips.txt

It passes!

9 years agoDeparse formats in the right spot
Father Chrysostomos [Sat, 6 Dec 2014 05:41:30 +0000 (21:41 -0800)]
Deparse formats in the right spot

Formats need the same logic applied in 34b54951568, to avoid this:

Input:

{
    my $x;
    format STDOUT =
@
$x
.
}
__END__

$ pbpaste|./perl -Ilib -MO=Deparse
{
    my $x;
}
format STDOUT =
@
$x
.
__DATA__
- syntax OK

That $x in the format is now global, not lexical.

Also, we need to make sure the sequence numbers are correct.  The
statement after the format stopped having a higher sequence number
than CvOUTSIDE_SEQ(format) in 8635e3c238f, because the ‘pending’
sequence number set aside for the nextstate op created just after com-
pile-time block exit (which nextstate op comes before the block) was
not actually being used by newFORM (unlike newATTRSUB), so the follow-
ing statement was using that number.

9 years agoAvoid extraneous ‘();’ when deparsing just subs
Father Chrysostomos [Sat, 6 Dec 2014 05:45:10 +0000 (21:45 -0800)]
Avoid extraneous ‘();’ when deparsing just subs

34b54951 caused a program that is empty apart from sub definitions to
be deparsed with ‘();’ for the main sub.  Previously it was omitted.
This commit removes it, not only for the sake of backward-compatibil-
ity, but also because ‘();’ is not a particularly sane way of dumping
an empty program.

9 years agoop.c: use GV_NOTQUAL in newATTRSUB_x
Father Chrysostomos [Sat, 6 Dec 2014 06:06:58 +0000 (22:06 -0800)]
op.c: use GV_NOTQUAL in newATTRSUB_x

If we are scanning for the package separator ourselves, then we can
notify gv_fetchsv that we found none, so it doesn’t have to scan
again.

9 years ago1 exit path for returning ptr in Perl_safesysmalloc and Perl_safesysrealloc
Daniel Dragan [Wed, 3 Dec 2014 09:59:46 +0000 (04:59 -0500)]
1 exit path for returning ptr in Perl_safesysmalloc and Perl_safesysrealloc

commit 6edcbed640 goto-ed around an initialization and was partially
reverted in commit c62df97fd6 . This patch restores the intention of
commit 6edcbed640 by having only 1 exit path that will be returning
a pointer (and not croaking).

9 years agoIncrease $NDBM_File::VERSION to 1.14
Father Chrysostomos [Sat, 6 Dec 2014 04:40:22 +0000 (20:40 -0800)]
Increase $NDBM_File::VERSION to 1.14

9 years agoIncrease $mro::VERSION to 1.17
Father Chrysostomos [Sat, 6 Dec 2014 04:39:52 +0000 (20:39 -0800)]
Increase $mro::VERSION to 1.17

9 years agoIncrease $Data::Dumper::VERSION to 2.155
Father Chrysostomos [Sat, 6 Dec 2014 04:39:29 +0000 (20:39 -0800)]
Increase $Data::Dumper::VERSION to 2.155

9 years agodont test for bootstrap file twice in XSLoader
Daniel Dragan [Sat, 6 Dec 2014 01:23:06 +0000 (20:23 -0500)]
dont test for bootstrap file twice in XSLoader

This saves ~8ms on my mech HD Win64 system per load() call.
See [perl #123373] for details.

9 years agocleanup logic in S_sv_uncow
Daniel Dragan [Fri, 5 Dec 2014 22:34:32 +0000 (17:34 -0500)]
cleanup logic in S_sv_uncow

I couldnt understand this code at first glance. Many empty conditional
blocks because of page protection ROing which isn't implemented on Win32,
caused erratic stepping in my debugger with CC optimizations *off*.

-read COWREFCNT only once
-save COWREFCNT to an auto for debugger visual inspection
-don't check len twice
-don't write sv_buf_to_rw() twice

No change in behavior is expected.

9 years agoRevert "toke.c: Remove redundant PL_expect check"
Father Chrysostomos [Sat, 6 Dec 2014 01:55:17 +0000 (17:55 -0800)]
Revert "toke.c: Remove redundant PL_expect check"

This reverts commit 8b4c5ad11955dc809ba3b7d6672b3a13ea54e770.

It caused bug #123372.

9 years agoTest bug #123372
Father Chrysostomos [Sat, 6 Dec 2014 01:55:08 +0000 (17:55 -0800)]
Test bug #123372

9 years agoInitialize possibly uninitialized.
Jarkko Hietaniemi [Sat, 6 Dec 2014 02:59:28 +0000 (21:59 -0500)]
Initialize possibly uninitialized.

9 years agoUnused expression + variable.
Jarkko Hietaniemi [Sat, 6 Dec 2014 01:16:54 +0000 (20:16 -0500)]
Unused expression + variable.

9 years agoSome versions of gcc -Wextra are too paranoid about { 0 }.
Jarkko Hietaniemi [Sat, 6 Dec 2014 01:14:20 +0000 (20:14 -0500)]
Some versions of gcc -Wextra are too paranoid about { 0 }.

9 years agoPOSIX math potentially unused vars.
Jarkko Hietaniemi [Sat, 6 Dec 2014 01:04:08 +0000 (20:04 -0500)]
POSIX math potentially unused vars.

9 years agogcc thinks it can see how 'entry' can be accessed uninitialized.
Jarkko Hietaniemi [Fri, 5 Dec 2014 03:08:28 +0000 (22:08 -0500)]
gcc thinks it can see how 'entry' can be accessed uninitialized.

9 years agoPOSIX nan: declaring s always potentially unused.
Jarkko Hietaniemi [Fri, 5 Dec 2014 02:58:56 +0000 (21:58 -0500)]
POSIX nan: declaring s always potentially unused.

9 years agoUnused hv_store() result.
Jarkko Hietaniemi [Fri, 5 Dec 2014 02:41:11 +0000 (21:41 -0500)]
Unused hv_store() result.

9 years agoUnused var.
Jarkko Hietaniemi [Fri, 5 Dec 2014 02:40:19 +0000 (21:40 -0500)]
Unused var.

9 years agoprintf type-matching continues. again.
Jarkko Hietaniemi [Fri, 5 Dec 2014 02:23:59 +0000 (21:23 -0500)]
printf type-matching continues. again.

9 years agoDeparse PVMG stubs
Father Chrysostomos [Fri, 5 Dec 2014 22:46:53 +0000 (14:46 -0800)]
Deparse PVMG stubs

Creating a weak reference to a stash entry will cause it to be of type
PVMG, if it was not a GV already.  B::Deparse was trying to determine,
based on the internal SV type, whether it had a sub stub.  It should
be checking flags instead, otherwise valid stubs get omitted.

9 years agoDeparse predeclared prototyped subs
Father Chrysostomos [Fri, 5 Dec 2014 14:21:35 +0000 (06:21 -0800)]
Deparse predeclared prototyped subs

A predeclared sub without a prototype works fine:

$ ./perl -Ilib -MO=Deparse -e 'sub f; sub f{}; foo()'
sub f {

}
foo();
-e syntax OK

A prototyped sub with no predeclaration is fine:

$ ./perl -Ilib -MO=Deparse -e ' sub f($){}; foo()'
sub f ($) {

}
foo();
-e syntax OK

A prototyped stub is fine:

$ ./perl -Ilib -MO=Deparse -e 'sub f($);  foo()'
sub f ($);
foo();
-e syntax OK

Only a predeclared prototyped sub seems to have trouble appear-
ing properly:

$ ./perl -Ilib -MO=Deparse -e 'sub f($); sub f($){}; foo()'
sub f;
foo();
-e syntax OK

The code that searches the stashes (stash_subs) was assuming that any-
thing of type B::PV was a prototype.  In this case, the stash entry
started as a string and then got ‘downgraded’ to a reference, so
internally it is of type PV (which can hold a ref), which B represents
as B::PV, so the assumption that a PV is a prototyped stub is wrong.

9 years agoRevert "Remove branch seemingly untaken"
Steffen Mueller [Fri, 5 Dec 2014 19:43:08 +0000 (20:43 +0100)]
Revert "Remove branch seemingly untaken"

This reverts commit 9349a6bbb9de151e5385038b962ceff7c7278b53.

It is taken. Sigh. I'm sorry.

9 years agoRemove branch seemingly untaken
Steffen Mueller [Fri, 5 Dec 2014 16:23:55 +0000 (17:23 +0100)]
Remove branch seemingly untaken

An HV* that is not an SVt_PVHV? Maybe I don't have sufficient fantasy.
This branch goes back to 1994, so things have changed ... a bit since
then.

9 years agoRestore profile dump under PERL_DESTRUCT_LEVEL
Father Chrysostomos [Fri, 5 Dec 2014 06:41:02 +0000 (22:41 -0800)]
Restore profile dump under PERL_DESTRUCT_LEVEL

$ ./perl -Ilib -DP -e0
filter_add func 1000dfa20 ()
filter_read 0: via function 7f8fd302fe88 ()
filter_read 0: via function 7f8fd302fe88 ()
filter_del func 1000dfa20
EXECUTING...

    1 nextstate
    1 enter
    1 leave
$ PERL_DESTRUCT_LEVEL=2 ./perl -Ilib -DP -e0
filter_add func 107b81a20 ()
filter_read 0: via function 7f81e882fea0 ()
filter_read 0: via function 7f81e882fea0 ()
filter_del func 107b81a20
EXECUTING...

The list of ops executed is omitted if I set PERL_DESTRUCT_LEVEL=2.
This was probably broken by bf9cdc68d2.

9 years agoCorrect dependencies for charclass_invlists.h
Father Chrysostomos [Fri, 5 Dec 2014 01:28:19 +0000 (17:28 -0800)]
Correct dependencies for charclass_invlists.h

regen.t should fail if Unicode tables are updated and this header is
not regenerated.

See commit 713f4b7fa and the thread beginning at
<20141204124705.472.qmail@lists-nntp.develooper.com>.

9 years agoop.c:fold_constants: Remove OP_RV2GV/newGVOP
Father Chrysostomos [Fri, 5 Dec 2014 00:13:19 +0000 (16:13 -0800)]
op.c:fold_constants: Remove OP_RV2GV/newGVOP

OP_RV2GV is not foldable, so it never reaches this code, which
goes back to 79072805 (perl 5.0 alpha 2).  Even back then it was
unreachable.

9 years agoop.c:fold_constants: Simplify OP_STRINGIFY logic
Father Chrysostomos [Fri, 5 Dec 2014 00:11:02 +0000 (16:11 -0800)]
op.c:fold_constants: Simplify OP_STRINGIFY logic

Don’t put the same condition in two places.  We are already using a bool-
ean.  We can put the result of the condition in it.

9 years agoReturn fresh scalar from join(const,const)
Father Chrysostomos [Fri, 5 Dec 2014 00:07:45 +0000 (16:07 -0800)]
Return fresh scalar from join(const,const)

$ perl5.20.1 -Ilib  -le 'for(1,2) { push @_, \join "x", 1 } print for @_'
SCALAR(0x7fb131005438)
SCALAR(0x7fb131005648)
$ ./perl -Ilib  -le 'for(1,2) { push @_, \join "x", 1 } print for @_'
SCALAR(0x7fe612831b30)
SCALAR(0x7fe612831b30)

Notice how we now get two references to the same scalar.  I broke this
accidentally in 987c9691.  If join has two arguments, it gets con-
verted to a stringify op.  The stringify op might get constant-folded,
and folding of stringify is special, because the parser uses it
itself to implement qq().  So I had ck_join set op_folded to flag
the op as being a folded join.  Only that came too late, because
op_convert_list(OP_STRINGIFY,...) folds the op before it returns it.
Hence, the folded constant was flagged the wrong way, and stopped
being implicitly copied by refgen (\).

9 years agoLocale-Maketext 1.26 is now on CPAN
Chris 'BinGOs' Williams [Fri, 5 Dec 2014 00:05:50 +0000 (00:05 +0000)]
Locale-Maketext 1.26 is now on CPAN

9 years agoSyncing back Changelog to be consistent with CPAN release
Todd Rinaldo [Thu, 4 Dec 2014 23:54:22 +0000 (18:54 -0500)]
Syncing back Changelog to be consistent with CPAN release

Whitespace corrections; update perldelta.

For: RT #121671

9 years agoUpdate Encode to CPAN version 2.67
Chris 'BinGOs' Williams [Thu, 4 Dec 2014 22:59:24 +0000 (22:59 +0000)]
Update Encode to CPAN version 2.67

  [DELTA]

$Revision: 2.67 $ $Date: 2014/12/04 20:13:00 $
! t/taint.t
  Now skips nonexistent methods like Encode::Detect->encode() should
  that be installed.  This resolves RT#100105.
  https://rt.cpan.org/Ticket/Display.html?id=100105

9 years agoDon’t deparse formats with #line directives
Father Chrysostomos [Thu, 4 Dec 2014 20:32:55 +0000 (12:32 -0800)]
Don’t deparse formats with #line directives

$ perl5.20.1 -mO=Deparse,-l -e 'format =' -e\@ -e'$foo' -e.
format STDOUT =
@
$foo
.
-e syntax OK
$ ./perl -Ilib -mO=Deparse,-l -e 'format =' -e\@ -e'$foo' -e.
format STDOUT =
@

#line 3 "-e"
; $foo
.
-e syntax OK

The second is not valid syntax.

I probably broke that when fixing BEGIN blocks.

9 years agodump.c: Don’t dump CvOUTSIDE SV when there is none
Father Chrysostomos [Thu, 4 Dec 2014 19:16:27 +0000 (11:16 -0800)]
dump.c: Don’t dump CvOUTSIDE SV when there is none

$ ./perl -Ilib -MDevel::Peek -Mfeature=:all -Xle 'my sub f; Dump \&f'
SV = IV(0x7fd7138312b0) at 0x7fd7138312c0
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x7fd713831b90
  SV = PVCV(0x7fd7138303d0) at 0x7fd713831b90
    REFCNT = 2
    FLAGS = (CLONED,DYNFILE,NAMED,LEXICAL)
    COMP_STASH = 0x7fd713807ce8 "main"
    ROOT = 0x0
    NAME = "f"
    FILE = "-e"
    DEPTH = 0
    FLAGS = 0x19040
    OUTSIDE_SEQ = 187
    PADLIST = 0x7fd7134067e8
    PADNAME = 0x7fd713411f88(0x7fd713406d48) PAD = 0x7fd713807e68(0x7fd71340d2f8)
    OUTSIDE = 0x0 (null)
    SV = 0

That final ‘SV = 0’ is very confusing!

9 years ago[perl #123357] Fix deparsing of $; at stmt end
Father Chrysostomos [Thu, 4 Dec 2014 16:39:28 +0000 (08:39 -0800)]
[perl #123357] Fix deparsing of $; at stmt end

Instead of sometimes appending ; to statements and then removing it
later, to avoid doubling it up, *only* append ; to a statement when
actually joining them together or emitting them.  That fixes bugs with
do{$;} becoming do {$} and ‘$_=$;; $;=7;’ becoming ‘$_=$; $;=7;’.

I also removed the boilerplate from pp_stub, since it was redundant
(and slow) and also partially wrong.  The $name var was bogus.

9 years agoDeparse.pm: Remove temp pre-PADNAME code
Father Chrysostomos [Thu, 4 Dec 2014 13:45:01 +0000 (05:45 -0800)]
Deparse.pm: Remove temp pre-PADNAME code

added in d4f1bfe749f, which got merged before the PADNAME changes.

9 years agoDeparse.pm: Remove special \0 marker
Father Chrysostomos [Thu, 4 Dec 2014 13:43:23 +0000 (05:43 -0800)]
Deparse.pm: Remove special \0 marker

In 4b1385ee6 I did not realise we already had \cK, which served almost
the same purpose.

9 years agoUnescape directory portion of path in unixify.
Craig A. Berry [Thu, 4 Dec 2014 14:02:09 +0000 (08:02 -0600)]
Unescape directory portion of path in unixify.

Basically I missed a spot in 812e68ff314e, so the escaped space
in [foo^_bar], for example, was not translated correctly.

9 years agoAdd checksum to regcharclass.h
Father Chrysostomos [Thu, 4 Dec 2014 06:41:45 +0000 (22:41 -0800)]
Add checksum to regcharclass.h

and check that checksum in t/porting/regen.t.  This makes the tests
run faster.

9 years agoAdd checksum to charclass_invlists.h
Father Chrysostomos [Thu, 4 Dec 2014 06:37:22 +0000 (22:37 -0800)]
Add checksum to charclass_invlists.h

and check that checksum in t/porting/regen.t.  This makes the tests
run faster.

9 years agoDeparse $x =~ (1?/$a/:0) under taint mode
Father Chrysostomos [Thu, 4 Dec 2014 06:07:39 +0000 (22:07 -0800)]
Deparse $x =~ (1?/$a/:0) under taint mode

This code deparses incorrectly under taint mode:

$ ./perl -Ilib -mO=Deparse  -e '$x =~ (1?/$a/:0)'
$x =~ ($_ =~ /$a/);
-e syntax OK
$ ./perl -Ilib -mO=Deparse -T -e '$x =~ (1?/$a/:0)'
$x =~ /$a/;
-e syntax OK

The branch folding makes it deparse as ‘$x =~ /$a/’, whereas the /$a/
on the rhs, since it was not the argument to =~, is bound to $_, not
to $x.  That’s why B::Deparse adds the $_ =~, but it fails to do so
under taint mode.

It was broken by:

commit 7fb31b92fa6bf56dff7d4240b7051b9158f7df43
Author: David Mitchell <davem@iabyn.com>
Date:   Sun Apr 1 10:21:22 2012 +0100

    make OP_REGCRESET only for taint handling

    The OP_REGCRESET op, which is sometimes prepended to the chain of ops
    leading to OP_REGCOMP, currently serves two purposes; first to reset the
    taint flag, and second to initialise PL_reginterp_cnt. The second purpose
    is no longer needed, and the first has a bug, in that the op isn't
    prepended when "use re 'eval'" is in scope.

    Fix this by prepending the op solely when PL_tainting is in effect.
    This also makes run-time regexes slightly more efficient in the
    non-tainting case.

which has a typo in it.

9 years agoperlfork.pod: convert "\t"s to spaces.
Shlomi Fish [Thu, 16 Oct 2014 09:25:30 +0000 (12:25 +0300)]
perlfork.pod: convert "\t"s to spaces.

For: RT #122987 (second part)

9 years agoRemove trailing whitespace.
Shlomi Fish [Thu, 16 Oct 2014 09:20:22 +0000 (12:20 +0300)]
Remove trailing whitespace.

For: RT #122987 (first part)

9 years agoConvert "\t"s to spaces in perlref.pod.
Shlomi Fish [Thu, 16 Oct 2014 08:43:06 +0000 (11:43 +0300)]
Convert "\t"s to spaces in perlref.pod.

For: RT #122986

9 years agoperldata: document corrected list slicing behaviour
Aristotle Pagaltzis [Thu, 10 Oct 2013 05:24:10 +0000 (07:24 +0200)]
perldata: document corrected list slicing behaviour

9 years ago[perl #114498] lslice returning empty vs undef
Father Chrysostomos [Wed, 3 Dec 2014 21:55:03 +0000 (13:55 -0800)]
[perl #114498] lslice returning empty vs undef

Formerly, list slice would return an empty list if all the indices
fell outside the actual list, but would return ‘undef’ for every index
specified if but one of them fell within the list.

This was not implemented according to the original design, according
to which list slice would give an empty list (for a non-zero number of
indices) only if the list on the left-hand side were empty.

This commit rectifies that.  See ticket #114498 for the discussion.

9 years ago[Merge] Deparse regexp code blocks
Father Chrysostomos [Thu, 4 Dec 2014 01:45:31 +0000 (17:45 -0800)]
[Merge] Deparse regexp code blocks

The actual ops that make up the code blocks are now deparsed.
B::Deparse no longer uses the stringified form stored in the regexp.
This fixes a few bugs.  See the individual commits for details.

9 years agoDeparse s/// with code blocks
Father Chrysostomos [Wed, 3 Dec 2014 20:52:13 +0000 (12:52 -0800)]
Deparse s/// with code blocks

Before, s/$a(?{die})// would deparse like this:

s/${a}do {
    die
}(?{die})//;

Now it deparses correctly.

9 years agoDeparse.pm: Fold some logic into sub code_list
Father Chrysostomos [Wed, 3 Dec 2014 06:25:59 +0000 (22:25 -0800)]
Deparse.pm: Fold some logic into sub code_list

Both callers were doing $op->first->sibling, so just have code_list
do that itself.

9 years agoDeparse qr// and m// with code blocks and vars
Father Chrysostomos [Wed, 3 Dec 2014 06:22:25 +0000 (22:22 -0800)]
Deparse qr// and m// with code blocks and vars

Before, this:

/$a(?{ die $b; })/;
qr/$a(?{ die $b; })/;

would deparse as this:

/${a}do {
    die $b
}(?{ die $b; })/;
qr/sub : lvalue {
    $a, do {
        die $b
    }, '(?{ die $b; })'
}
->()/;

Now it deparses correctly.

9 years agoDeparse regexp code blocks in m// and split //
Father Chrysostomos [Wed, 3 Dec 2014 02:10:35 +0000 (18:10 -0800)]
Deparse regexp code blocks in m// and split //

The blocks themselves are now deparsed, rather than the original strings
being emitted.  This fixes problems with newlines turning into \n and
here-docs missing their bodies.  It only applies to compile-time patterns.
Run-time patterns (with variables interpolated outside the code blocks)
are still unfixed and deparse with do{...} embedded in the pattern.

9 years agoDeparse.t: Put a line break after the test code
Father Chrysostomos [Tue, 2 Dec 2014 22:53:32 +0000 (14:53 -0800)]
Deparse.t: Put a line break after the test code

The line break gets removed when it is extracted from the __DATA__
section, and then it gets wrapped in sub{$input}.  That breaks
here-docs.

9 years agoDeparse qr/(?{code_blocks})/ with no interpolation
Father Chrysostomos [Tue, 2 Dec 2014 17:33:38 +0000 (09:33 -0800)]
Deparse qr/(?{code_blocks})/ with no interpolation

This is a preliminary patch that only applies when there are no varia-
bles interpolated into the pattern outside of the code blocks.

The code blocks are now actually deparsed, instead of the stringified
form just being reproduced.  This means the \n bug is gone:

Before:

$  ./perl -Ilib -mO=Deparse -e '{ qr/aaaaa\\\\\\(?{;' -e '$y})' -e '/}'
{
    qr/aaaaa\\\\\\(?{;\n\$y})\n/;
}
-e syntax OK

After:

$ ./perl -Ilib -mO=Deparse -e '{ qr/aaaaa\\\\\\(?{;' -e '$y})' -e '/}'
{
    qr/aaaaa\\\\\\(?{ $y; })\n/;
}
-e syntax OK

You can see the \n translation now happens only outside of the block.

It also means here-docs work:

Before:

$  ./perl -Ilib -mO=Deparse -e 'qr/(??{<<END})/' -efoo -eEND
qr/(??{<<END})/;
-e syntax OK

(The output is a syntax error.)

After:

$ ./perl -Ilib -mO=Deparse -e 'qr/(??{<<END})/' -efoo -eEND
qr/(??{ "foo\n"; })/;
-e syntax OK

9 years agoDeparse FOO =~ y///r correctly
Father Chrysostomos [Tue, 2 Dec 2014 14:06:05 +0000 (06:06 -0800)]
Deparse FOO =~ y///r correctly

Apparently anything =~ y///r with the /r never deparsed properly (just
the lhs deparsed) until 05a502dc, when lexicals on the lhs started
being emitted.

9 years agoTo-do tests for deparsing regexp code blocks
Father Chrysostomos [Tue, 2 Dec 2014 06:32:41 +0000 (22:32 -0800)]
To-do tests for deparsing regexp code blocks

Currently we have various bugs:
• Line breaks often come out as \n, changing the meaning.
• Some blocks are doubled up with do{...} for the first instance.
• qr/sub { .... }/ madness

9 years agoFix deparsing of $lexical =~ //
Father Chrysostomos [Tue, 2 Dec 2014 13:57:40 +0000 (05:57 -0800)]
Fix deparsing of $lexical =~ //

I broke this in 05a502dc.

9 years agoDeparse: matchop: Remove double method+function call
Father Chrysostomos [Tue, 2 Dec 2014 13:51:36 +0000 (05:51 -0800)]
Deparse: matchop: Remove double method+function call