Jesse Luehrs [Wed, 4 Jul 2012 01:28:24 +0000 (20:28 -0500)]
fix perlobj SUPER example [perl #113972]
Father Chrysostomos [Tue, 3 Jul 2012 21:00:00 +0000 (14:00 -0700)]
parser.h: Add comments explaining *bufptr
Father Chrysostomos [Tue, 3 Jul 2012 20:56:42 +0000 (13:56 -0700)]
parser.h: Correct comment explaining last_lop_op
Father Chrysostomos [Tue, 3 Jul 2012 20:55:47 +0000 (13:55 -0700)]
sv.h: Improve docs of Sv[GS]ETMAGIC
Jesse Luehrs [Tue, 3 Jul 2012 18:06:50 +0000 (13:06 -0500)]
fix compile warnings in malloc.c [perl #75340]
Colin Kuskie [Fri, 22 Jun 2012 22:35:58 +0000 (15:35 -0700)]
Refactor t/op/splice.t to use t/test.pl instead of making TAP by hand.
Nicholas Clark [Tue, 3 Jul 2012 16:21:53 +0000 (18:21 +0200)]
Add another address for Colin Kuskie to checkAUTHORS.pl
Tony Cook [Tue, 3 Jul 2012 07:41:06 +0000 (17:41 +1000)]
[rt.cpan.org #61577] VMS doesn't support UNIX sockets
A casual reading of t/io_unix.t might lead you to believe it might,
but VMS also doesn't support fork, so the io_unix.t tests are skipped
anyway.
Eric Brine [Thu, 12 May 2011 05:21:50 +0000 (22:21 -0700)]
Avoid needless use of deprecated exists on array elements
Jesse Luehrs [Tue, 3 Jul 2012 05:50:34 +0000 (00:50 -0500)]
constant folding shouldn't change return value of while [perl #73618]
If the expression in while (EXPR) is a false constant, just return that
constant expression rather than OP_NULL during optimization.
Doesn't handle until loops yet, because "until (1)" is converted to
"while (!1)" by the parser, and so "!1" is already constant-folded to ''
by the time the while loop optree is constructed. Not sure what to do
about that.
Father Chrysostomos [Tue, 3 Jul 2012 05:27:47 +0000 (22:27 -0700)]
toke.c: Merge UNI2 and UNIBRACK
The only difference between them is the PL_expect assignment,
which can be controlled by a constant parameter that the C
compiler will optimise away.
Matthew Horsfall (alh) [Tue, 3 Jul 2012 05:20:39 +0000 (22:20 -0700)]
For #16249 - Overwrite PL_last_lop_op when eval() is called.
Otherwise, parsing later on down the road may use the previous value, which, if it was OP_PRINT, causes the parser to fail
Father Chrysostomos [Mon, 2 Jul 2012 19:34:10 +0000 (12:34 -0700)]
perlfunc: Fix do-sub mistake
do &foo() is the do-file operator on the return value of the sub,
not just a sub call.
Father Chrysostomos [Mon, 2 Jul 2012 16:49:17 +0000 (09:49 -0700)]
op.c:newFOROP: Fall back to realloc for unslabbed ops
When an op is allocated, PL_compcv is checked to see whether it can
hold an op slab if it does not hold one already. If PL_compcv is not
usable, for whatever reason, it falls back to malloc.
Since the new slab allocator was added in commit 8be227a, newFOROP has
been assuming, probably correctly, that its listop which it needs to
enlarge to a loopop was allocated by slab.
Since newFOROP is an API function, we should err on the safe side and
check first whether the op is slab-allocated, falling back to realloc
if it is not.
To trigger this potential bug, one has to set things up such that
there is a usable pad available, but no usable PL_compcv. I said
‘probably correctly’ above because this situation is highly unlikely
and probably indicative of bugs elsewhere. (But we should still err
on the side of safety.)
Craig A. Berry [Mon, 2 Jul 2012 00:48:03 +0000 (19:48 -0500)]
Fix ill-named Test::Harness test and bump version.
env.opts.t by its very existence causes the test suite to die on
VMS with:
$ perl TEST ../cpan/Test-Harness/t/compat/env.opts.t
Can't read ../cpan/test-harness/t/compat/env.opts.t.
%RMS-F-SYN, file specification syntax error
Enabling the extended filename character set will fix this but that's
not (yet) the default setting. So here we simply rename the file to
something legal.
Reported upstream as [rt.cpan.org #78127].
Jesse Luehrs [Mon, 2 Jul 2012 16:58:47 +0000 (11:58 -0500)]
fix 64-bit compiler warning
Father Chrysostomos [Mon, 2 Jul 2012 15:41:25 +0000 (08:41 -0700)]
pad.c: Improve intro_my docs
Father Chrysostomos [Sun, 1 Jul 2012 00:37:25 +0000 (17:37 -0700)]
Put a cap on op slab sizes
If a subroutine is *really* big, we don’t want to allocate, say, 4MB
for ops when just over 2 will do, just because there was one op more
than could fit in 2MB.
Father Chrysostomos [Sat, 30 Jun 2012 21:34:42 +0000 (14:34 -0700)]
Use find_runcv_where for pp_coreargs and pp_runcv
Nicholas Clark [Mon, 2 Jul 2012 12:44:13 +0000 (14:44 +0200)]
s/thinngy/thingy/ in a comment in sv.c
Tony Cook [Mon, 2 Jul 2012 10:19:52 +0000 (20:19 +1000)]
perldelta for
18042359,
9adbac0b
Tony Cook [Mon, 2 Jul 2012 10:14:58 +0000 (20:14 +1000)]
bump IO.pm version
cmpVERSION doesn't pick this up - should it?
Tony Cook [Mon, 2 Jul 2012 09:41:19 +0000 (19:41 +1000)]
[rt.cpan.org #61577] try harder to get socket information
also [perl #112736][debian #659075]
One of the tests may fail on HP-UX (but doesn't on the machine I have
access to) I plan to monitor smokes and add skips as needed.
Dominic Hargreaves [Wed, 9 May 2012 18:09:18 +0000 (19:09 +0100)]
add Test::More as a prereq to Makefile.PL
Tony Cook [Fri, 22 Jun 2012 10:57:09 +0000 (20:57 +1000)]
bump IO::Socket version
Tony Cook [Fri, 22 Jun 2012 10:25:06 +0000 (20:25 +1000)]
document the limitations of protocol(), sockdomain(), socktype()
Determining these for a new_from_fd() socket has the following problems:
protocol() depends on SO_PROTOCOL, and socktype() on SO_TYPE, not
implemented on all systems.
sockdomain() depends on sockname(), which is documented as
unimplemented for AF_UNIX sockets on HP-UX.
I'm not sure that detail is useful in the documentation.
Tony Cook [Wed, 13 Jun 2012 11:21:49 +0000 (21:21 +1000)]
[rt.cpan.org #61577] try to populate socket info when not cached
The fixes are originally by Daniel Kahn Gillmor
<dkg@fifthhorseman.net>, but I've made other changes.
Tony Cook [Wed, 13 Jun 2012 09:32:33 +0000 (19:32 +1000)]
[rt.cpan.org #61577] propagate socket details on accept
Tony Cook [Wed, 13 Jun 2012 09:27:22 +0000 (19:27 +1000)]
[rt.cpan.org #61577] sockdomain and socktype undef on newly accepted sockets
There appears to be a flaw in IO::Socket where some IO::Socket objects
are unable to properly report their socktype, sockdomain, or protocol
(they return undef, even when the underlying socket is sufficiently
initialized to have these properties).
The attached patch should cover IO::Socket objects created via accept(),
new_from_fd(), new(), and anywhere else whose details haven't been
properly cached.
No new code should be executed on IO::Socket objects whose details are
already cached and present.
These tests were original written by Daniel Kahn Gillmor
<dkg@fifthhorseman.net>, I've mangled them for use in a hopefully
final fix for the issue.
Karl Williamson [Sun, 1 Jul 2012 04:04:23 +0000 (22:04 -0600)]
Fix up pod references to deprecated function
Father Chrysostomos [Sat, 30 Jun 2012 19:43:26 +0000 (12:43 -0700)]
Cloning a format whose outside has been undefined
This has crashed ever since
71f882da8, because the format tries to
close over a pad that does not exist:
sub x {
{my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u)}
my $z;
format =
@<<<
$z
.
}
undef &x;
write;
This commit adds checks for nonexistent pads, producing the ‘Variable
is not available’ warning in cases like this.
Shlomi Fish [Sat, 30 Jun 2012 13:40:43 +0000 (16:40 +0300)]
Fix perl -d’s "l" command.
The "l" command (without any arguments) got broken in blead, due to the
"use strict" patch because "$max = ..." was changed into "my $max = ..."
while $max should always be a global.
Darin McBride [Sat, 30 Jun 2012 05:46:43 +0000 (22:46 -0700)]
perldelta for 9d7bf4
Father Chrysostomos [Sat, 30 Jun 2012 05:25:28 +0000 (22:25 -0700)]
op.c: S_op_integerize: -foo no longer needs an exception
Father Chrysostomos [Sat, 30 Jun 2012 05:16:22 +0000 (22:16 -0700)]
pad.c: Update comments
Father Chrysostomos [Sat, 30 Jun 2012 00:34:38 +0000 (17:34 -0700)]
[perl #113012] String negation under ‘use integer’
This makes the negation operator under the integer pragma (i_int) use
the same logic for determining whether to do string negation as the
regular negation operator.
Before, this did not happen at all under the integer pragma, except
for barewords, resulting in strange inconsistencies:
$ perl -le 'use integer; print -foo'
-foo
$ perl -le 'use integer; print -"foo"'
0
The code for string negation is now in a static routine in pp.c and is
used by both types of negation.
Father Chrysostomos [Fri, 29 Jun 2012 21:49:53 +0000 (14:49 -0700)]
[perl #113006] perllocale: change Spanish to traditional Spanish
Nowadays, Spanish collation does not treat ch as a separate letter.
Father Chrysostomos [Fri, 29 Jun 2012 20:18:06 +0000 (13:18 -0700)]
op.c: Remove unnecessary variable
This is left over from when I had the partially-filled slab at the end
of the chain, instead of second (which was never committed).
Father Chrysostomos [Fri, 29 Jun 2012 19:41:21 +0000 (12:41 -0700)]
Don’t crash with formats in special blocks
Commit
421f30ed1e9 didn’t go far enough. If a special block happens
to replace a stub, then a format trying to close over variables in the
special block will be pointing to the wrong outer sub.
Such stubs shouldn’t usually happen, but perl shouldn’t crash.
Karl Williamson [Sat, 23 Jun 2012 19:30:36 +0000 (13:30 -0600)]
perlguts: Document that PV can point to non-string
Karl Williamson [Wed, 27 Jun 2012 22:24:43 +0000 (16:24 -0600)]
regcomp.c: Optimize /[0-9]/ into /\d/a
The commonly used [0-9] can be optimized into a smaller, faster node
that means the same thing.
Karl Williamson [Wed, 27 Jun 2012 20:43:41 +0000 (14:43 -0600)]
regcomp.c: Optimize e.g., /[^\w]/, /[[^:word:]]/ into /\W/
This optimizes character classes that have a single element that is one
of the ops that have the same meaning outside (namely \d, \h, \s, \w,
\v, :word:, :digit: and their complements) to that op. Those
ops take less space than a character class and run faster. An initial
'^' for complementing the class is also handled.
Karl Williamson [Wed, 27 Jun 2012 19:48:16 +0000 (13:48 -0600)]
regcomp.c: Simply some node calculations
For the node types that have differing versions depending on the
character set regex modifiers, /d, /l, /u, /a, and /aa, we can use the
enum values as offsets from the base node number to derive the correct
one. This eliminates a number of tests.
Because there is no DIGITU node type, I added placeholders for it (and
NDIGITU) to avoid some special casing of it (more important in future
commits). We currently have many available node types, so can afford to
waste these two.
Karl Williamson [Wed, 27 Jun 2012 19:28:13 +0000 (13:28 -0600)]
regcomp.sym: Reorder a couple of nodes
This causes all the nodes that depend on the regex modifier, BOUND,
BOUNDL, etc. to have the same relative ordering. This will enable a
future commit to simplify generation of the correct node.
Karl Williamson [Wed, 27 Jun 2012 00:14:23 +0000 (18:14 -0600)]
reg_fold.t: Make test cases non-optimizable away
This commit changes the bracketed character classes to include a
non-related character. This is in preparation for a future commit which
would cause the current character classes to be optimized into EXACTish
nodes which would start passing TODO tests, but don't fix the underlying
problem with character classes. That bug is that you can't split a
multi-char fold across nodes. It probably is not fixable in Perl without
a total restructuring of the regular expression mechanism. For example,
"\N{LATIN SMALL LIGATURE FFI}" doesn't match /[f][f][i]/i. But it would
if those got optimized into a single EXACTF node. (The problem is not
limited to character classes, /(f)(f)(i)/i also doesn't match, and
can't, as $1, $2, and $3 are not well-defined.)
Karl Williamson [Sun, 24 Jun 2012 20:16:44 +0000 (14:16 -0600)]
regcomp.c: Simplify compile time [^..] complement
This simply moves the code that populates the bitmap and combines the
two inversion lists to after the inversion (the differences are shown
much greater than there really are, since a move is done.) This greatly
simplifies complementing the character class.
Karl Williamson [Sun, 24 Jun 2012 20:02:48 +0000 (14:02 -0600)]
regcomp.c: Rename variable to reflect new purpose
This variable really holds the list of all code points the bracketed
character class matches; it's not just the ones not in the bitmap.
Karl Williamson [Sun, 24 Jun 2012 03:25:36 +0000 (21:25 -0600)]
regcomp.c: Have a subroutine do the work
Since this code was originally written, the fold function has added
input flags that cause it to do the same thing this code does. So do it
in the subroutine.
Karl Williamson [Sat, 23 Jun 2012 21:48:42 +0000 (15:48 -0600)]
regcomp.c: Remove obsolete code
A previous commit has removed all calls to these two functions (moving a
large portion of the bit_fold() one to another place, and no longer sets
the variable.
Karl Williamson [Sat, 23 Jun 2012 20:19:02 +0000 (14:19 -0600)]
regcomp.c: White-space, comments only
This indents, outdents previous code, based on new/removed outer blocks.
It reflows comments and code to fit into 80 columns, add/removes blank
lines, minor comment rewording
Karl Williamson [Sat, 23 Jun 2012 21:24:38 +0000 (15:24 -0600)]
regcomp.c: Remove unnecessary 'if' test
A previous commit has refactored things, so this test is always true
Karl Williamson [Sat, 23 Jun 2012 21:00:26 +0000 (15:00 -0600)]
regcomp.c: Use more inversion lists in [] char classes
This changes the building of bracketed character classes to use
inversion lists instead of a bitmap/inversion list combination.
This will lead in later commits to simplification and extending
optimizations to beyond the Latin1 range.
Karl Williamson [Sat, 23 Jun 2012 18:57:54 +0000 (12:57 -0600)]
handy.h: Fix isBLANK_uni and isBLANK_utf8
These macros have never worked outside the Latin1 range, so this extends
them to work.
There are no tests I could find for things in handy.h, except that many
of them are called all over the place during the normal course of
events. This commit adds a new file for such testing, containing for
now only with a few tests for the isBLANK's
Karl Williamson [Sat, 23 Jun 2012 18:03:42 +0000 (12:03 -0600)]
no_utf8_pm.t: Add blank between 'not' and 'ok' in .t
Jesse Luehrs [Fri, 29 Jun 2012 16:23:59 +0000 (11:23 -0500)]
fix compiler warning
Father Chrysostomos [Fri, 29 Jun 2012 07:50:30 +0000 (00:50 -0700)]
Make formats close over the right closure
This was brought up in ticket #113812.
Formats that are nested inside closures only work if invoked from
directly inside that closure. Calling the format from an inner sub
call won’t work.
Commit
af41786fe57 stopped it from crashing, making it work as well
as 5.8, in that closed-over variables would be undefined, being
unavailable.
This commit adds a variation of the find_runcv function that can check
whether CvROOT matches an argument passed in. So we look not for the
current sub, but for the topmost sub on the call stack that is a clone
of the closure prototype that the format’s CvOUTSIDE field points to.
Father Chrysostomos [Fri, 29 Jun 2012 06:12:23 +0000 (23:12 -0700)]
[perl #113812] Always use find_runcv when cloning a sub
A closure prototype’s CvOUTSIDE pointer might have been modified if
its containing sub is freed first. When a sub is cloned, the enclos-
ing sub is always the currently-running sub (not so for formats).
So this commit makes subs always use find_runcv, the way they did
before
71f882da828.
So the closure logic which was needed for formats is now moved into an
else branch that is used only for them.
Father Chrysostomos [Fri, 29 Jun 2012 07:22:25 +0000 (00:22 -0700)]
[Merge] CV-based slab allocator for ops
This branch uses per-CV slabs for ops, so that ops can all be freed
after compilation errors, fixing memory leaks and a crash.
See commit
8be227ab5e for how it works.
Father Chrysostomos [Thu, 28 Jun 2012 16:13:40 +0000 (09:13 -0700)]
Teach diagnostics.pm about %p
Father Chrysostomos [Thu, 28 Jun 2012 16:10:56 +0000 (09:10 -0700)]
Increase $diagnostics::VERSION to 1.30
Father Chrysostomos [Thu, 28 Jun 2012 15:52:10 +0000 (08:52 -0700)]
perldiag: Document ‘Slab leaked from cv’
Father Chrysostomos [Thu, 28 Jun 2012 05:40:48 +0000 (22:40 -0700)]
When reusing op slots, only zero as much as needed
If an op slot is reused for a smaller op, we only need to zero out the
space used for the op, not the whole slot.
Father Chrysostomos [Thu, 28 Jun 2012 05:38:25 +0000 (22:38 -0700)]
-DS should not invoke warnhook
I was using Perl_warn, both for its convenience, and because the line
numbers were extremely helpful in tracking bugs.
But it invokes the warnhook, if present, and also respects tied
STDERR. We should be using Perl_debug_log.
Changing this also avoids the need for /* diag_listed_as: SKIPME */
all over the place.
Father Chrysostomos [Wed, 27 Jun 2012 03:27:37 +0000 (20:27 -0700)]
op.c: Memory funcs need dVAR
Father Chrysostomos [Tue, 26 Jun 2012 21:30:40 +0000 (14:30 -0700)]
fresh_perl.t: Skip #112312 tests on miniperl
They require attributes.pm.
Father Chrysostomos [Tue, 26 Jun 2012 20:24:13 +0000 (13:24 -0700)]
Enlarge the last slot on an op slab to fit
For simplicity, op slots are never resized once they are allocated.
But they are reused after they are freed, if they are big enough.
When allocating the last op slot that will fit on a slab, we might as
well enlarge the slot to contain whatever space is left over, so this
slot, after being freed, can be reused for a larger op.
Father Chrysostomos [Tue, 26 Jun 2012 17:08:58 +0000 (10:08 -0700)]
Define cv_forget_slab under PL_OP_SLAB_ALLOC
Instead of using #ifndef every time we call cv_forget_slab, just
define it as a no-op under PL_OP_SLAB_ALLOC.
Father Chrysostomos [Sun, 24 Jun 2012 06:34:13 +0000 (23:34 -0700)]
Test perl #112312, crash on syntax error
I am having difficulty getting these tests to fail. They crash when
run standalone, but always pass when run via fresh_perl.t. Hopefully,
they will fail somewhere. :-)
Yes, fresh_perl.t does begin with this:
# ** DO NOT ADD ANY MORE TESTS HERE **
But t/comp/parser.t does not (and should not) use test.pl, so it is
very hard to test something like this.
Putting it here seemed slightly better than putting it in
its own file.
Father Chrysostomos [Sun, 24 Jun 2012 01:24:52 +0000 (18:24 -0700)]
Test bug #111462, Safe + %^H + disallowed ops
Father Chrysostomos [Sun, 24 Jun 2012 00:47:33 +0000 (17:47 -0700)]
perlhacktips: Update PERL_DEBUG_READONLY_OPS
Father Chrysostomos [Sun, 24 Jun 2012 00:44:23 +0000 (17:44 -0700)]
PERL_IMPLICIT_SYS can use the new slab allocator
Father Chrysostomos [Sat, 23 Jun 2012 16:56:53 +0000 (09:56 -0700)]
Add slab allocation diagnostics (under perl -DS)
These proved extremely useful for getting this slab allocator to work.
We might as well leave them in place for future debugging.
Father Chrysostomos [Sat, 23 Jun 2012 16:56:07 +0000 (09:56 -0700)]
-DS option for slab allocation
Father Chrysostomos [Sat, 23 Jun 2012 16:54:31 +0000 (09:54 -0700)]
CV-based slab allocation for ops
This addresses bugs #111462 and #112312 and part of #107000.
When a longjmp occurs during lexing, parsing or compilation, any ops
in C autos that are not referenced anywhere are leaked.
This commit introduces op slabs that are attached to the currently-
compiling CV. New ops are allocated on the slab. When an error
occurs and the CV is freed, any ops remaining are freed.
This is based on Nick Ing-Simmons’ old experimental op slab implemen-
tation, but it had to be rewritten to work this way.
The old slab allocator has a pointer before each op that points to a
reference count stored at the beginning of the slab. Freed ops are
never reused. When the last op on a slab is freed, the slab itself is
freed. When a slab fills up, a new one is created.
To allow iteration through the slab to free everything, I had to have
two pointers; one points to the next item (op slot); the other points
to the slab, for accessing the reference count. Ops come in different
sizes, so adding sizeof(OP) to a pointer won’t work.
The old slab allocator puts the ops at the end of the slab first, the
idea being that the leaves are allocated first, so the order will be
cache-friendly as a result. I have preserved that order for a dif-
ferent reason: We don’t need to store the size of the slab (slabs
vary in size; see below) if we can simply follow pointers to find
the last op.
I tried eliminating reference counts altogether, by having all ops
implicitly attached to PL_compcv when allocated and freed when the CV
is freed. That also allowed op_free to skip FreeOp altogether, free-
ing ops faster. But that doesn’t work in those cases where ops need
to survive beyond their CVs; e.g., re-evals.
The CV also has to have a reference count on the slab. Sometimes the
first op created is immediately freed. If the reference count of
the slab reaches 0, then it will be freed with the CV still point-
ing to it.
CVs use the new CVf_SLABBED flag to indicate that the CV has a refer-
ence count on the slab. When this flag is set, the slab is accessible
via CvSTART when CvROOT is not set, or by subtracting two pointers
(2*sizeof(I32 *)) from CvROOT when it is set. I decided to sneak the
slab into CvSTART during compilation, because enlarging the xpvcv
struct by another pointer would make all CVs larger, even though this
patch only benefits few (programs using string eval).
When the CVf_SLABBED flag is set, the CV takes responsibility for
freeing the slab. If CvROOT is not set when the CV is freed or
undeffed, it is assumed that a compilation error has occurred, so the
op slab is traversed and all the ops are freed.
Under normal circumstances, the CV forgets about its slab (decrement-
ing the reference count) when the root is attached. So the slab ref-
erence counting that happens when ops are freed takes care of free-
ing the slab. In some cases, the CV is told to forget about the slab
(cv_forget_slab) precisely so that the ops can survive after the CV is
done away with.
Forgetting the slab when the root is attached is not strictly neces-
sary, but avoids potential problems with CvROOT being written over.
There is code all over the place, both in core and on CPAN, that does
things with CvROOT, so forgetting the slab makes things more robust
and avoids potential problems.
Since the CV takes ownership of its slab when flagged, that flag is
never copied when a CV is cloned, as one CV could free a slab that
another CV still points to, since forced freeing of ops ignores the
reference count (but asserts that it looks right).
To avoid slab fragmentation, freed ops are marked as freed and
attached to the slab’s freed chain (an idea stolen from DBM::Deep).
Those freed ops are reused when possible. I did consider not reusing
freed ops, but realised that would result in significantly higher mem-
ory using for programs with large ‘if (DEBUG) {...}’ blocks.
SAVEFREEOP was slightly problematic. Sometimes it can cause an op to
be freed after its CV. If the CV has forcibly freed the ops on its
slab and the slab itself, then we will be fiddling with a freed slab.
Making SAVEFREEOP a no-op won’t help, as sometimes an op can be
savefreed when there is no compilation error, so the op would never
be freed. It holds a reference count on the slab, so the whole
slab would leak. So SAVEFREEOP now sets a special flag on the op
(->op_savefree). The forced freeing of ops after a compilation error
won’t free any ops thus marked.
Since many pieces of code create tiny subroutines consisting of only
a few ops, and since a huge slab would be quite a bit of baggage for
those to carry around, the first slab is always very small. To avoid
allocating too many slabs for a single CV, each subsequent slab is
twice the size of the previous.
Smartmatch expects to be able to allocate an op at run time, run it,
and then throw it away. For that to work the op is simply mallocked
when PL_compcv has’t been set up. So all slab-allocated ops are
marked as such (->op_slabbed), to distinguish them from mallocked ops.
All of this is kept under lock and key via #ifdef PERL_CORE, as it
should be completely transparent. If it isn’t transparent, I would
consider that a bug.
I have left the old slab allocator (PL_OP_SLAB_ALLOC) in place, as
it is used by PERL_DEBUG_READONLY_OPS, which I am not about to
rewrite. :-)
Concerning the change from A to X for slab allocation functions:
Many times in the past, A has been used for functions that were
not intended to be public but were used for public macros. Since
PL_OP_SLAB_ALLOC is rarely used, it didn’t make sense for Perl_Slab_*
to be API functions, since they were rarely actually available. To
avoid propagating this mistake further, they are now X.
Father Chrysostomos [Sat, 23 Jun 2012 16:50:15 +0000 (09:50 -0700)]
Add OP_FREED op type
This is a dummy op type that should never be seen by any code except
op allocation code (to come).
So it is not in the usual list of opcodes, but is #defined outside the
range valid of opcodes.
Father Chrysostomos [Sat, 23 Jun 2012 16:48:34 +0000 (09:48 -0700)]
Flag ops that are on the savestack
This is to allow future commits to free dangling ops after errors.
If an op is on the savestack, then it is going to be freed by scope.c,
and op_free must not be called on it by anyone else.
So we flag such ops new.
Father Chrysostomos [Sat, 23 Jun 2012 16:43:33 +0000 (09:43 -0700)]
dump.c: Dump CVf_SLABBED
Father Chrysostomos [Sat, 23 Jun 2012 16:43:10 +0000 (09:43 -0700)]
Add CVf_SLABBED flag
This will indicate that a CV has a reference count on, and ownership
of, a slab used for allocating ops.
Jesse Luehrs [Fri, 29 Jun 2012 06:56:27 +0000 (01:56 -0500)]
fix 386a548 for fallback => undef
The default case for non-overloaded classes is fallback => 1, so saying
fallback => 1 on its own shouldn't enable overloading, but saying
fallback => undef on its own should (even though undef is the default
for overloaded classes).
Jesse Luehrs [Fri, 29 Jun 2012 05:40:42 +0000 (00:40 -0500)]
perldelta for 27c6f44
Jesse Luehrs [Fri, 29 Jun 2012 05:38:04 +0000 (00:38 -0500)]
"use overload fallback => 0" should enable overloading [perl #113010]
This makes
package Foo;
use overload fallback => 0;
and
package Bar;
use overload '+' => \&add, fallback => 0;
behave identically when an operator other than '+' is used.
Father Chrysostomos [Fri, 29 Jun 2012 03:28:09 +0000 (20:28 -0700)]
Formats in closures called outside closures → crash
If a format closing over lexical variables is defined inside a clo-
sure, it must only be called directly inside that closure, not from
any other eval, sub, or format.
Calling it from anywhere else started causing a crash in 5.10.0,
because the format would try to close over variables in the currently-
running sub, using padoffsets intended for a completely unrelated pad.
This commit stops it from crashing by checking whether the currently-
running sub is a clone of the format’s outer sub (a closure proto-
type). If it is not, the outer closure prototype is used, resulting
in ‘Variable is not available’ warnings.
This makes things work as well as they did in 5.8. Ideally, we should
search the call stack for the topmost clone of the format’s outer sub;
but I’m saving that for another commit.
Jesse Luehrs [Fri, 29 Jun 2012 03:17:23 +0000 (22:17 -0500)]
fix storing objects with reftype REF [perl #113880]
Jesse Luehrs [Fri, 29 Jun 2012 01:27:07 +0000 (20:27 -0500)]
perldelta updates for 6728836, d60d201, 82f9620, 7878705
Father Chrysostomos [Thu, 28 Jun 2012 23:31:17 +0000 (16:31 -0700)]
Don’t let formats outlive their outer subs
This began crashing in 5.11.3:
sub foo {
sub bar {
my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$x);
format =
@||||||
$x
.
}
}
undef *bar;
write;
(On some systems, you need more alphabet soup to make it crash.)
This commit (just the perly.y part shown) caused it to crash:
commit
421f30ed1e95009450bdc7905bf3433ee806ea4f
Author: Zefram <zefram@fysh.org>
Date: Tue Dec 15 11:48:31 2009 +0100
[perl #22977] Bug in format/write
diff --git a/perly.y b/perly.y
index 18e5875..a61a6b3 100644
--- a/perly.y
+++ b/perly.y
@@ -511,7 +511,9 @@ peg : PEG
;
format : FORMAT startformsub formname block
- { SvREFCNT_inc_simple_void(PL_compcv);
+ {
+ CV *fmtcv = PL_compcv;
+ SvREFCNT_inc_simple_void(PL_compcv);
#ifdef MAD
$$ = newFORM($2, $3, $4);
prepend_madprops($1->tk_mad, $$, 'F');
@@ -521,6 +523,10 @@ format : FORMAT startformsub formname block
newFORM($2, $3, $4);
$$ = (OP*)NULL;
#endif
+ if (CvOUTSIDE(fmtcv) && !CvUNIQUE(CvOUTSIDE(fmtcv))) {
+ SvREFCNT_inc_simple_void(fmtcv);
+ pad_add_anon((SV*)fmtcv, OP_NULL);
+ }
}
;
Unfortunately, adding the format to the pad like that (to allow
pad_fixup_inner_anons to fix up formats as well as subs) is proble-
matic. It causes the format’s CvOUTSIDE to be weak. Since the for-
mat does not hold a reference count on its outer sub, that sub can be
freed before the format. When that happens, regular subs are fixed
up by having CvOUTSIDE change to point to the grandparent. If you
do that for formats, you run into a problem: Formats can be cloned
even when the outer sub is not running. Formats are cloned whenever
invoked *by name* via write. If CvOUTSIDE points to a different sub,
then closing over the scalars in specific pad offsets in that sub can
result in reading past the end of the pad. If you don’t read past the
end of the pad, you are still making variables close over unrelated variables, so the inner $x could close over an outer @y, etc. Subrou-
tines don’t have that problem, as they can only be cloned when they
have an outer sub. (Even though the outer sub’s prototype, if it is a
closure, might have been freed, the outer sub itself is still running
and referenced by the context stack.)
This commit changes the direction of the weak reference between an
outer sub’s pad and an inner format, fixing the crash.
To do so, it has to store, not the format itself, but a weak RV point-
ing to the format, in the outer sub’s pad.
Father Chrysostomos [Thu, 28 Jun 2012 16:24:46 +0000 (09:24 -0700)]
diagnostics.t: Restore test name removed by f0e510f
Father Chrysostomos [Thu, 28 Jun 2012 04:32:08 +0000 (21:32 -0700)]
perldiag: Add missing regexp delims
Jesse Luehrs [Wed, 27 Jun 2012 02:12:18 +0000 (21:12 -0500)]
propagate context into overloads [perl #47119]
amagic_call now does its best to propagate the operator's context into
the overload callback. It's not always possible - for instance,
dereferencing and stringify/boolify/numify always have to return a
value, even if it's not used, due to the way the overload callback works
in those cases - but the majority of cases should now work. In
particular, overloading <> to handle list context properly is now
possible.
For backcompat reasons (amagic_call and friends are technically public
api functions), list context will not be propagated unless specifically
requested via the AMGf_want_list flag. If this is passed, and the
operator is called in list context, amagic_call returns an AV* holding
all of the returned values instead of an SV*. Void context always
results in amagic_call returning &PL_sv_undef.
Jesse Luehrs [Thu, 28 Jun 2012 05:39:11 +0000 (00:39 -0500)]
more in depth tests for 8e4ecf2
Jesse Luehrs [Wed, 27 Jun 2012 19:49:10 +0000 (14:49 -0500)]
Father Chrysostomos [Wed, 27 Jun 2012 19:49:28 +0000 (12:49 -0700)]
perly.*: update regen_perly checksum
Reini Urban [Thu, 21 Jun 2012 14:26:56 +0000 (09:26 -0500)]
regen_perly.pl: support latest bison-2.5.1
bison-2.5.1 adds less superfluous semicolons at the end of action blocks,
but works fine.
Father Chrysostomos [Wed, 27 Jun 2012 19:41:56 +0000 (12:41 -0700)]
pp.c: Restore uninit warning to study
Also, prevent a crash when SvCUR is used on a non-PV.
Jesse Luehrs [Wed, 27 Jun 2012 18:40:49 +0000 (13:40 -0500)]
clean up compilation warnings
Jesse Luehrs [Wed, 27 Jun 2012 18:10:58 +0000 (13:10 -0500)]
add a few comments to bisect-runner.pl docs
./perl -Ilib t/op/sort.t won't do what you want, because tests that
don't use Test::More don't set an error code on their own, you need to
run it under the harness
Father Chrysostomos [Wed, 27 Jun 2012 16:15:27 +0000 (09:15 -0700)]
[Merge] [perl #109408] Documentation that refers to Perl 5 as new
Quoting Brian Fraser:
So.
I more or less went ahead and did this, to some extent. To some other
extent the changes are stylistic, like consistently using v5.x.y instead of
5.x or 5.x.y or whatnot in perlvar (and only in perlvar, so as to avoid
bikeshedding). I also bumped most odd versions, post 5.6, to the next
stable release (so, for example, 5.7.1 became 5.8.0, and 5.9.0 became
5.10.0, but 5.005 is still 5.005).
There's only one big deletion, which was most of perltrap.pod -- It dealt
with traps for Perl 4 programmers migrating to Perl 5. It would be really
swell if someone could update perltrap for their other favorite language of
choice, since right now the document is severely lacking, only dealing with
awk, shell, C/C++, and Perl itself.
There's some stuff that I didn't really know about, so I left it alone,
including all of perlhack(tips)? and perl(re|deb)?guts.
One thing that came up in IRC while I was doing this is that having a table
in perlvar detailing in which version each variable became available would
be really swell. And I know that brian d foy compiled one for string/regex
escapes, which strikes me like a good candidate to get in as well.
Brian Fraser [Wed, 27 Jun 2012 15:55:08 +0000 (08:55 -0700)]
[perl #109408] Documentation that refers to Perl 5 as new
Regened known_pod_issues.dat for the previous commits.
Brian Fraser [Wed, 27 Jun 2012 15:54:06 +0000 (08:54 -0700)]
perlvar: #109408
Brian Fraser [Wed, 1 Feb 2012 02:43:19 +0000 (23:43 -0300)]
perlutil: #109408
Brian Fraser [Wed, 27 Jun 2012 15:51:26 +0000 (08:51 -0700)]
perluniintro: #109408