Karl Williamson [Mon, 9 Jul 2012 20:25:03 +0000 (14:25 -0600)]
regcomp.c: Move table to wider scope
This table will be used in future commits outside this block's scope
Karl Williamson [Mon, 9 Jul 2012 19:59:09 +0000 (13:59 -0600)]
regcomp.c: Silence compiler warning
I suspect this being an IV stemmed from an earlier version. It always
contains unsigneds
Karl Williamson [Mon, 9 Jul 2012 19:54:13 +0000 (13:54 -0600)]
regcomp.c: Change macro name to better indicate its purpose
Karl Williamson [Sat, 7 Jul 2012 16:10:30 +0000 (10:10 -0600)]
Optimize a single character [class] into EXACTish
Things like /[s]/ or /[s]/i can be optimized as if they did not have the
brackets, /s/ or /s/i.
Karl Williamson [Mon, 9 Jul 2012 19:10:00 +0000 (13:10 -0600)]
regcomp.c: Extract some code into an inline function
This code will be used in future commits in multiple places
Karl Williamson [Sat, 7 Jul 2012 17:46:40 +0000 (11:46 -0600)]
regcomp.c: shrink some optimized [class] nodes
Various bracketed character class specifications don't need the full
generality, and can be optimized into smaller, faster nodes. Recent
commits, such as
3a64b5154fffec75126d34d25954f0aef30d9f8a have
introduced some such optimizations. However, their commit messages are
wrong, in that they don't end taking up any less space than the original
ANYOF node, as there is no provision for giving it back, once reserved.
This commit corrects that for non-locale nodes. Restructuring of the
code, more than I care to do now, would be required to extend this to
locale nodes.
Only optimizations that are determined in pass1 of the regex compilation
are eligible for this, as once the space is calculated, it is reserved
before pass2 begins. There are now two sections where optimization is
done in this routine. The final section is after all the data is
examined and processed, and we know exactly what is to be in the ANYOF
node. Currently, most of this calculation processing is skipped in pass
1. We could do everything in both passes, greatly slowing down the
first, in order to figure out the exact space requirements.
But instead, I've chosen to add a separate optimization section that
looks at only the optimizations that are easily computable in the
current first pass, and to apply those early, in time for the shrinking
to occur. This commit adds that shrinking.
Locale nodes can't be shrunk because the code currently writes into
their larger buffer before this decision to optimize is made. To
illustrate, say that the node is at the end of the regex, and the data
is written at x+20, within a generic locale ANYOF node's space. Pass 1
doesn't write anything, but calculates the space needed. At the point
that this commit addresses, we would shrink the amount of space to be
allocated to be allocated. Then we carve out space for the regex from
the heap. That x+20 could be pointing to something entirely different,
which Pass 2 would destroy. This can be avoided by storing the stuff
that would be written into a temporary until the optimization decision
has been made. But there is extra work involved in doing this, that I
don't think is worth it at this time.
The same problem doesn't occur in non-locale situations, even though the
flags field of the node is written before the optimization decision.
This is because every node has the space for a flags field, so it just
gets overwritten as necessary when the optimization is done.
Karl Williamson [Sat, 7 Jul 2012 17:42:30 +0000 (11:42 -0600)]
regcomp.c: Delay some initialization until needed
This delays the initialization of the bitmap in ANYOF nodes until just
before it is needed, and to after where we make a decision to optimize
that node to a node which takes less space. Currently, the space is
not given up, once reserved in pass 1, so the write is harmless. This
will allow a future commit to shrink the space.
Karl Williamson [Sat, 7 Jul 2012 14:15:56 +0000 (08:15 -0600)]
regcomp.c: Remove duplicate assignments
These variables are already set to the same values a few lines up.
Karl Williamson [Tue, 3 Jul 2012 04:18:47 +0000 (22:18 -0600)]
handy.h: Move bit shifting into base macro
This changes the #defines to be just the shift number, while doing
the shifting in the macro that the number is passed to. This will prove
useful in future commits
Karl Williamson [Tue, 3 Jul 2012 03:39:56 +0000 (21:39 -0600)]
handy.h: Renumber character class bits
These are renumbered so that the ones that correspond to character
classes in regcomp.h are related numerically as well. This will prove
useful in future commits.
Karl Williamson [Tue, 3 Jul 2012 03:31:31 +0000 (21:31 -0600)]
handy.h: Reorder some #defines
They are now ordered in the same order as the similar #defines in
regcomp.h. This will be useful in later commits
Karl Williamson [Tue, 3 Jul 2012 03:09:18 +0000 (21:09 -0600)]
handy.h: l1_charclass.h: Add bit for matching ASCII
This does not replace the isASCII macro definition, as I think the
current one is more efficient than this one provides. But future
commits will rely on all the named character classes (e.g.,
/[[:ascii:]]/) having a bit, and this is the only one missing.
Karl Williamson [Tue, 3 Jul 2012 03:04:16 +0000 (21:04 -0600)]
handy.h: refactor some macros to use a new one in common.
This creates a new, unpublished, macro to implement most of the other
macros. This macro will be useful in future commits.
Karl Williamson [Sat, 7 Jul 2012 03:41:07 +0000 (21:41 -0600)]
regcomp.c: Extract code to inline function
Future commits will use this paradigm in additional places, so extract
it to a function, so they all do things right. This isn't a great API,
but it works for the few places this will be called.
Karl Williamson [Fri, 6 Jul 2012 21:14:19 +0000 (15:14 -0600)]
regcomp.sym: Correct and add comments
Karl Williamson [Fri, 6 Jul 2012 17:31:11 +0000 (11:31 -0600)]
regen/regcomp.pl: Allow ';' in comments
If a comment contained a semi-colon, the regular expression's greedy
quantifier would think the portion of the comment before it was part of
the data to be processed
Karl Williamson [Wed, 4 Jul 2012 21:22:59 +0000 (15:22 -0600)]
regcomp.c: Optimize [^\n] into \N
This optimization is a big win, as it takes less space, and completely
avoids any swash hash creation, and use.
Karl Williamson [Wed, 4 Jul 2012 20:49:22 +0000 (14:49 -0600)]
regcomp.c: White-space, comments only
This fixes some nits in a some comments, adds some comments, but mostly
just indents and outdents to reflect a new outer block, and to fit
within 80 columns
Karl Williamson [Wed, 4 Jul 2012 20:16:29 +0000 (14:16 -0600)]
regcomp.c: Refactor new charclass optimizations
Commits
3a64b5154fffec75126d34d25954f0aef30d9f8a and
3172e3fd885a9c54105d3b6156f18dc761fe29e5 introduced some optimizations
into the handling of bracketed character classes with just a single
element.
In working on other optimizations, I realized that it would be better to
put these all in one spot, instead of doing things partially and setting
flags to pass to other areas of the routine.
This commit moves all the processing to a single spot, which gets called
only after we know that there will be just one element in the character
class.
I also realized that the [0-9] optimization should strictly not be done
under locale. There is no test for this, as actually this would only be
a problem if a locale was in violation of the C standard. But (most) of
the rest of Perl doesn't assume that locales are well-behaved in this
regard, so now this code doesn't either.
Karl Williamson [Tue, 3 Jul 2012 02:50:33 +0000 (20:50 -0600)]
regcomp.c: Use data structure properties to remove tests
The ANYOF_foo character class #defines really form an enum, with the
property that the regular one is n, and its complement is n+1. So
we can replace the tests in each case: of the switch, with a single test
afterwards.
Karl Williamson [Sun, 1 Jul 2012 18:37:04 +0000 (12:37 -0600)]
regcomp.c: Use macro for clarity
It's kind of obscure what this test is doing, so change it into a macro
to clarify things
Karl Williamson [Thu, 28 Jun 2012 23:13:18 +0000 (17:13 -0600)]
regcomp.c: Only try to fold foldable chars
This uses the new table that a previous commit caused mktables to
generate which more precisely determines which Unicode characters
participate in folds. This avoids trying to calculate a fold that we
can know beforehand doesn't have a fold.
Karl Williamson [Thu, 28 Jun 2012 19:32:17 +0000 (13:32 -0600)]
mktables: Generate new table for foldable chars
This table consists of all characters that participate in any way in a
fold in the current Unicode version. regcomp.c currently uses the Cased
property as a proxy for these. This information is used to limit the
number of characters whose folds have to be dealt with in compiling
bracketed regex character classess. It turns out that Cased contains
more than 1300 more code points than actually do appear in folds, which
means potential extra work for compiling. Hence this patch allows that
work to be avoided.
There are a few characters in this new table that aren't in Cased, which
are potential bugs in the old way of doing things. In Unicode 6.1,
these are: U+02BC MODIFIER LETTER APOSTROPHE, U+0308 COMBINING
DIAERESIS, U+0313 COMBINING COMMA ABOVE, and U+0342 COMBINING GREEK
PERISPOMENI. I can't figure out how these might be currently causing a
bug, but this patch fixes any such.
Karl Williamson [Wed, 27 Jun 2012 23:18:20 +0000 (17:18 -0600)]
regcomp.c: Correct outdated comment
Karl Williamson [Wed, 27 Jun 2012 22:57:25 +0000 (16:57 -0600)]
regcomp.c: Change and comment a problematic #define
As noted in the new comments, there is no out-of-bounds code point, so
this should not be used as such; and it turns out, it really isn't.
But this is a fall-back in case code is changed to not set the variable
that this initializes, and the comment will prevent someone else from
wasting their time trying to figure out why this is like this.
Karl Williamson [Wed, 27 Jun 2012 22:37:56 +0000 (16:37 -0600)]
embed.fnc: Remove duplicate entry
Karl Williamson [Wed, 27 Jun 2012 22:31:36 +0000 (16:31 -0600)]
utf8.h, regcomp.c: Use mnemonics for Unicode chars
Add a mnemonic definition for these three code points. They are
currently used in only one place, but future commits will use them
elsewhere.
Karl Williamson [Wed, 25 Jul 2012 00:35:40 +0000 (18:35 -0600)]
embed.fnc: Add const to remove compiler warning
This should have been declared const.
David Mitchell [Tue, 24 Jul 2012 14:11:29 +0000 (15:11 +0100)]
lex_grow_linestr(): update re_eval_start
As seen in [perl #114242], the TryCatch test suite triggers this bug.
lex_grow_linestr() was reallocing the PL_linestr buffer and updating all
pointers within it, but was failing to update
PL_sublex_info.re_eval_start.
Unfortunately, lex_grow_linestr() doesn't seem to be used in core outside
of hereto docs, and due to a separate parser bug, hereto docs can't
currently be used within /(?{})/, so I can't add tests for it yet.
Dave Rolsky [Fri, 20 Jul 2012 16:28:07 +0000 (11:28 -0500)]
Update core to Time::Local 1.2300 from CPAN
David Mitchell [Tue, 24 Jul 2012 10:21:25 +0000 (11:21 +0100)]
[perl #114248] Newxz? doc wrong in perlclib.pod
Commit
9f653bb54868b8547466924d4ce483acb8987efb changed the docs from
New/Newz to the newer Newx/Newxz, but forgot to remove the
no-longer-present 'id' arg.
Nicholas Clark [Tue, 24 Jul 2012 08:39:08 +0000 (10:39 +0200)]
Merge B 1.37 to blead (more SV flag constants exposed).
Nicholas Clark [Mon, 23 Jul 2012 11:39:05 +0000 (13:39 +0200)]
Bump B's VERSION and note the changes in perldelta.pod.
Nicholas Clark [Mon, 23 Jul 2012 11:27:32 +0000 (13:27 +0200)]
Expose all GV flags matching qr/GVf_/ as constants in B.
Previously only those matching qr/GVf_IMPORTED/ were exposed.
Nicholas Clark [Mon, 23 Jul 2012 11:15:51 +0000 (13:15 +0200)]
Expose all CV flags matching qr/CVf_/ as constants in B.
Previously most were exposed as constants, but often B was not taught about
flags added to cv.h. Determining the flags by parsing cv.h also permits the
removal of various version-specific logic from the Makefile.PL
Nicholas Clark [Mon, 23 Jul 2012 09:30:17 +0000 (11:30 +0200)]
Expose all SV flags matching qr/SV(?:[fps]|pad)_/ as constants in B.
Previously only a subset were exposed as constants.
Nicholas Clark [Mon, 23 Jul 2012 10:36:27 +0000 (12:36 +0200)]
In ext/B/Makefile.PL, order the list of files to scan lexically.
It doesn't actually matter which order the files are scanned for constants,
but it's neater and slightly clearer where to add new files if there is an
obvious order.
Chip Salzenberg [Tue, 24 Jul 2012 07:39:46 +0000 (00:39 -0700)]
ensure that the env var SV after C<{FOO}='x'> is PV only
Chip Salzenberg [Tue, 24 Jul 2012 05:53:49 +0000 (22:53 -0700)]
reduce magic overhead of tainting (maybe other magic later)
Chip Salzenberg [Tue, 24 Jul 2012 05:40:46 +0000 (22:40 -0700)]
Unify code that initializes constants yes, no, and undef
Chris 'BinGOs' Williams [Mon, 23 Jul 2012 10:05:39 +0000 (11:05 +0100)]
Sync Module-CoreList version in Maintainers.pl with teh CPAN
Karl Williamson [Sat, 21 Jul 2012 19:11:07 +0000 (13:11 -0600)]
re_tests: Add tests for [perl #114220]
This was fixed as a side effect of other patches, so no tests were
created at the time.
Chip Salzenberg [Sat, 21 Jul 2012 05:13:12 +0000 (22:13 -0700)]
in sv_chop(), add use SvPOK_only_UTF8() to clear obsolete NIOK
Chip Salzenberg [Sat, 21 Jul 2012 05:11:23 +0000 (22:11 -0700)]
make SvOOK_offset macro safer, with parens and underscores
Robin Barker [Thu, 19 Jul 2012 15:25:59 +0000 (16:25 +0100)]
rewrite a regex in lib/DB.t using \Q
The regexp for the 'eval BLOCK' test should match explicit '...'.
So avoid the \{ issue and put \Q before all the punctuation.
Tony Cook [Fri, 20 Jul 2012 15:34:40 +0000 (17:34 +0200)]
bump to version 5.17.3
Tony Cook [Fri, 20 Jul 2012 15:24:19 +0000 (17:24 +0200)]
new perldelta
Tony Cook [Fri, 20 Jul 2012 15:15:10 +0000 (17:15 +0200)]
update epigraphs.pod
Tony Cook [Fri, 20 Jul 2012 12:35:09 +0000 (14:35 +0200)]
add releaase 5.17.2 to perlhist
Tony Cook [Fri, 20 Jul 2012 12:32:19 +0000 (14:32 +0200)]
update Module::CoreList for 5.17.2
Tony Cook [Fri, 20 Jul 2012 12:18:45 +0000 (14:18 +0200)]
Porting/corelist.pl didn't handle newlines in the pod version list
Tony Cook [Fri, 20 Jul 2012 10:59:25 +0000 (12:59 +0200)]
finalize perldelta
Karl Williamson [Wed, 18 Jul 2012 23:22:33 +0000 (17:22 -0600)]
Only generate above-Uni warning for \p{}, \P{}
This warning was being generated inappropriately during some internal
operations, such as parsing a program; spotted by Tom Christiansen.
The solution is to move the check for this situation out of the common
code, and into the code where just \p{} and \P{} are handled.
As mentioned in the commit's perldelta, there remains a bug
[perl #114148], where no warning gets generated when it should
Karl Williamson [Wed, 18 Jul 2012 21:14:54 +0000 (15:14 -0600)]
regcomp.c: Refactor code into a function
Future commits will use this functionality in additional places beyond
the single one currently. It makes sense to abstract it into a
function.
Karl Williamson [Wed, 4 Jul 2012 19:42:15 +0000 (13:42 -0600)]
regcomp.c: set local flag in pass1 of charclass inversion
Previously, this flag was not looked at in pass 1, but future commits
will require it to be. The regnode is not actually allocated in pass1,
so set a local variable with the value, and set the flag in the regnode
after everything affecting the flag is done.
Karl Williamson [Wed, 18 Jul 2012 20:06:31 +0000 (14:06 -0600)]
regcomp.c: Keep separate list for [:word:] from \p{Word}
This commit separates out the building up of code points that match the
posix properties (including \w, \d, \s) from those that match Unicode
properties. This will prove useful in future commits
Karl Williamson [Mon, 16 Jul 2012 04:08:22 +0000 (22:08 -0600)]
regcomp.c: Convert boolean variable from a UV
It's a little clearer to use boolean for a true/false valued variable
Karl Williamson [Mon, 16 Jul 2012 04:01:52 +0000 (22:01 -0600)]
utf8.c: Create API so internals can be hidden
This creates a function to hide some of the internal details of swashes
from the regex engine, which is the only authorized user, enforced
through #ifdefs in embed.fnc. These work closely together, but it's
best to have a clean interface.
Karl Williamson [Sun, 15 Jul 2012 22:11:45 +0000 (16:11 -0600)]
regcomp.h: Free up bit; downside is makes locale ANYOF nodes large
There have been two flavors of ANYOF nodes under /l (locale) (for
bracketed character classes). If a class didn't try to match things
like [:word:], it was smaller by 4 bytes than one that did.
A flag bit was used to indicate which size it was. By making all such
nodes the larger size, whether needed or not, that bit can be freed to
be used for other purposes.
This only affects ANYOF nodes compiled under locale rules. The hope is
to eventually git rid of these nodes anyway, by taking the suggestion of
Yves Orton to compile regular expressions using the current locale, and
automatically recompile the next time they are used after the locale
changes.
This commit is somewhat experimental, done early in the development
cycle to see if there are any breakages. There are other ways to free
up a bit, as explained in the comments. Best would be to split off
nodes that match everything outside Latin1, freeing up the
ANYOF_UNICODE_ALL bit. However, there currently would need to be two
flavors of this, one also for ANYOFV. I'm currently working to
eliminate the need for ANYOFV nodes (which aren't sufficient,
[perl #89774]), so it's easiest to wait for this work to be done before
doing the split, after which we can revert this change in order to gain
back the space, but in the meantime, this will have had the opportunity
to smoke out issues that I would like to know about.
Karl Williamson [Sun, 15 Jul 2012 22:11:02 +0000 (16:11 -0600)]
regcomp.h: Fix up comment
Karl Williamson [Sun, 15 Jul 2012 20:35:52 +0000 (14:35 -0600)]
regcomp.c: Clarify, update comments, white-space reflow
Karl Williamson [Sun, 15 Jul 2012 23:02:19 +0000 (17:02 -0600)]
perlapi: Clarify hv_fetch() docs
I was confused by the earlier documentation. Thanks to Leon Timmermans
for clarifying, and to Vicent Pitt for most of the wording
David Mitchell [Thu, 19 Jul 2012 10:40:49 +0000 (11:40 +0100)]
op/join.t: don't use done_testing
since the number of tests is known in advance.
Jan Dubois [Wed, 18 Jul 2012 22:47:44 +0000 (15:47 -0700)]
Fixup indentation
Daniel Dragan [Mon, 16 Jul 2012 20:02:45 +0000 (16:02 -0400)]
Adding support for Visual C's __declspec(noreturn) function declarations to perl
This will reduce the machine code size on Visual C Perl, by removing C stack
clean up opcodes and possible jmp opcodes after croak() and similar
functions. Perl's existing __attribute__noreturn__ macro (and therefore
GCC's __attribute__((noreturn)) ) is fundamentally incompatible with MS's
implementation for noreturn functions. win32.h already has _MSC_VER
aware code blocks, so adding more isn't a problem.
Tony Cook [Wed, 18 Jul 2012 11:34:30 +0000 (21:34 +1000)]
perldelta updates
Tony Cook [Tue, 17 Jul 2012 05:48:02 +0000 (15:48 +1000)]
sync() on a read-only file handle doesn't work on cygwin either
Cygwin fsync() is implemented in terms of the Win32 FlushFileBuffers()
API which requires GENERIC_WRITE access.
Chip Salzenberg [Sun, 15 Jul 2012 23:20:14 +0000 (16:20 -0700)]
perldelta description of magic flags patch
Chip Salzenberg [Sun, 15 Jul 2012 23:19:57 +0000 (16:19 -0700)]
mark blead-only modifications of Compress::Raw::{Bzip2,Zlib} with version bump
Chip Salzenberg [Fri, 22 Jun 2012 22:18:18 +0000 (15:18 -0700)]
Magic flags harmonization.
In restore_magic(), which is called after any magic processing, all of
the public OK flags have been shifted into the private OK flags. Thus
the lack of an appropriate public OK flags was used to trigger both get
magic and required conversions. This scheme did not cover ROK, however,
so all properly written code had to make sure mg_get was called the right
number of times anyway. Meanwhile the private OK flags gained a second
purpose of marking converted but non-authoritative values (e.g. the IV
conversion of an NV), and the inadequate flag shift mechanic broke this
in some cases.
This patch removes the shift mechanic for magic flags, thus exposing (and
fixing) some improper usage of magic SVs in which mg_get() was not called
correctly. It also has the side effect of making magic get functions
specifically set their SVs to undef if that is desired, as the new behavior
of empty get functions is to leave the value unchanged. This is a feature,
as now get magic that does not modify its value, e.g. tainting, does not
have to be special cased.
The changes to cpan/ here are only temporary, for development only, to
keep blead working until upstream applies them (or something like them).
Thanks to Rik and Father C for review input.
Father Chrysostomos [Sun, 15 Jul 2012 02:13:18 +0000 (19:13 -0700)]
perldelta updates
Father Chrysostomos [Sun, 15 Jul 2012 02:00:48 +0000 (19:00 -0700)]
dump.c: Dump op->op_s(labbed|avefree)
Father Chrysostomos [Sun, 15 Jul 2012 02:00:17 +0000 (19:00 -0700)]
Remove op_latefree(d)
This was an early attempt to fix leaking of ops after syntax errors,
disabled because it was deemed to fragile. The new slab allocator
(8be227a) has solved this problem another way, so latefree(d) no
longer serves any purpose.
Father Chrysostomos [Sun, 15 Jul 2012 01:45:41 +0000 (18:45 -0700)]
perly.y: Remove use of latefree from package foo {}
It is not necessary for the op containing the sv containing the name
of the package to last until the end of the block. Perl_package can
free the op immediately, as the only information it needs from it it
copies to the sv in PL_curstname. The version number can be treated
the same way.
Father Chrysostomos [Sat, 14 Jul 2012 21:16:42 +0000 (14:16 -0700)]
op.c: ck_grep does not need to call listkids
It calls ck_fun, which applies list context to all the arguments,
since grepstart and mapstart have an L in regen/opcodes.
Father Chrysostomos [Sat, 14 Jul 2012 21:10:44 +0000 (14:10 -0700)]
op.c: ck_fun does not need to call LINKLIST
The branch in question is only reached when it is called from ck_grep,
which itself calls LINKLIST on exactly the same op.
Father Chrysostomos [Sat, 14 Jul 2012 20:28:57 +0000 (13:28 -0700)]
op.c:ck_grep: Remove unnecessary op_next assignments
ck_grep is a tangled mess and I am trying to simplify it, but at each
step it is not at all obvious what is happening.
grep/map with a block starts out like this:
grepstart
pushmark
null
scope/leave
block contents...
arg1
arg2
...
The if (o->op_flags & OPf_STACKED) at the top of ck_grep runs for
blocks. The firstkid var refers to the null above, and gets its
op_next set (this code was in ck_sort until recently [ck_grep used to
call ck_sort], and this particular op_next assignment was specific to
grep and map).
Later, the thing is fed through ck_fun, whose OA_CVREF case transforms
the tree into this:
grepstart
pushmark
null ← new op
null ← original null
scope/leave
block contents...
arg1
arg2
...
Then cUNOPx(cLISTOP->op_first->op_sibling)->op_first gets its op_next
set. By that point, that expression refers to the original null op,
so setting its op_next pointer to begin with seems pointless.
But it is not actually pointless. Removing that statement breaks
things. It turns out, as usual, that everything is more complicated
than it seems. Setting kid->op_next = (OP*)gwop in the block-specific
if statement after setting the first null op’s op_next pointer results
in op_next pointers like this (the newly-created grepwhile doesn’t
link to the grepstart yet at this point):
[grepwhile]
grepstart
pushmark
null -> block contents
scope/leave -> grepwhile
block contents...
arg1
arg2
...
So ck_fun’s OA_CVREF handling, when it calls LINKLIST, sees that the
original null op already has its op_next set and does nothing. With-
out it set, it copies it from the first kid, resulting in this (when
LINKLIST copies the op_next pointer out, it makes the kid it was cop-
ied from point to its sibling or its parent):
[grepwhile]
grepstart
pushmark
null
null -> grepwhile
scope/leave -> null (prev line)
block contents...
arg1
arg2
...
That nonsensical arrangement of op_next pointers basically prevents
the block from running, because the grepwhile’s other pointer, copied
from the first null’s kid, ends up pointing to the grepwhile itself.
If we also remove the kid->op_next = (OP*)gwop assignment from the
if(OPf_STACKED) block, then we end up with this after ck_fun:
[grepwhile]
grepstart
pushmark
null
null -> first op in block
scope/leave -> null (prev line)
block contents...
arg1
arg2
...
Then the op_next poiner from the first null’s kid is copied to
grepwhile’s op_other pointer, and everything works.
This also means we can remove the now-redundant LINKLIST call from the
if(OPfSTACKED) block, since ck_fun’s OA_CVREF handling also does that.
So now every vestige of the original call to ck_sort is gone.
This also means we no longer have to repeat NewOp(1101, gwop...).
Father Chrysostomos [Sat, 14 Jul 2012 19:28:15 +0000 (12:28 -0700)]
op.c: ck_grep does not need to check num of args
It calls ck_fun first, which does the same check, so it is
unnecessary.
Father Chrysostomos [Sat, 14 Jul 2012 19:28:08 +0000 (12:28 -0700)]
pp_hot.c: Mention that pp_grepstart calls pp_pushmark
Father Chrysostomos [Sat, 14 Jul 2012 13:58:29 +0000 (06:58 -0700)]
Simplify ck_grep
Back in perl 5.000, ck_grep would call ck_sort (which was still the
case until
354dd559d99 just recently) and the latter would traverse
its way through the op_next pointers to find an op that tried to
escape the block, setting its op_next pointer to null. Then ck_grep
would traverse op_next pointers itself to find the place where ck_sort
stopped. That caused problems for grep which were fixed in
748a93069b
(perl 5.001). It was fixed by setting op_next to 0 on the first op,
so that the loop in ck_grep would not do anything. But that loop was
left there. This commit removes it.
There are also a couple of things I missed when disentangling
ck_grep and ck_sort in commit /
354dd559d9. I accidentally put
if (o->op_flags & OPf_STACKED) inside if (o->op_flags & OPf_STACKED).
And the OPf_SPECIAL flag was only being set for sort’s use, so ck_grep
doesn’t need to copy that.
Father Chrysostomos [Sat, 14 Jul 2012 13:41:30 +0000 (06:41 -0700)]
op.c: Further simplify ck_sort
This code currently chases op_next pointers in the sort block to make
sure there is none that can point outside. To avoid getting stuck in
loops, it has to check for those explicitly.
Instead of nulling out any op_next pointer that points to the leave
op, we can simply turn the leave into a null op (which we already do)
and have the leave op’s op_next pointer point to nothing.
That produces the same result in the end: Execution of the sort block
is prevented from running rampant and escaping out of it, but exits
the runloop instead, returning control to pp_sort.
Tony Cook [Sun, 8 Jul 2012 01:12:51 +0000 (11:12 +1000)]
Upgrade Socket to 2.002
Father Chrysostomos [Sat, 14 Jul 2012 07:51:09 +0000 (00:51 -0700)]
op.c: Consistent tweak; podchecker complaints
Shlomi Fish [Fri, 13 Jul 2012 19:27:24 +0000 (22:27 +0300)]
Update perlop's bignum modules list.
Removed some out-of-date modules and add Math::GMPq, Math::GMPz and
Math:GMPf.
Father Chrysostomos [Sat, 14 Jul 2012 07:36:06 +0000 (00:36 -0700)]
op.c: Missing line break
Father Chrysostomos [Sat, 14 Jul 2012 07:35:13 +0000 (00:35 -0700)]
Disentangle ck_sort and grep
Originally, sort and grep/map used the same code for handling the
block’s ops.
But that didn’t quite work, so exceptions were added over time. Now
the thing is a complex sprawling mess. By folding the grep-specific
code into ck_grep, things are greatly simplified.
Father Chrysostomos [Sat, 14 Jul 2012 07:07:03 +0000 (00:07 -0700)]
[perl #113710] Make __SUB__ work in sort block
When the peephole optimiser encounters a __SUB__, it looks to see
whether the current sub is clonable. If it is not, it inlines the
__SUB__ as a const op.
This works most of the time. A forward declaration will cause the sub
definition to reuse the existing stub. When that happens, the sub
visible during compilation in PL_compcv is not the sub that the
op tree will finally be attached to. But the peephole optimiser
is called after that, with PL_compcv set to the other CV (what
was a stub).
ck_sort was calling the peephole optimiser on the sort block ahead of
time. So this caused __SUB__ to point to the wrong subroutine.
By removing the CALL_PEEP call from ck_sort and adding logic to the
peephole optimiser itself to traverse the sort block (it is not in the
usual op_next chain), this bug is eliminated.
I modified the DEFER macro to work as a single statement. You don’t
want to know how much time I spent debugging the bus errors that were
occurring because if(foo) DEFER; didn’t do what I though.
It turns out that grepstart and mapstart, which also use ck_sort,
had their blocks go through the peephole optimiser twice, because
grepwhile already has special-casing in the peephole optimiser.
This also has the side-effect of making map and grep slightly more
efficient, in that they no longer execute a scope op (which is just
pp_null). By temporarily disconnecting the subtree before running the
optimiser, ck_sort was hiding a possible optimisation (skipping the
scope op).
Yves Orton [Wed, 11 Jul 2012 07:03:09 +0000 (09:03 +0200)]
fix RT#114068 optimizer handles MEOL in middle of pattern improperly
It seems that under certain circumstances the optimiser handles the
MEOL operator (what $ turns into under /m), improperly including
things that follow. This results in compilation like this:
Compiling REx "( [^z] $ [^z]+ )"
Final program:
1: OPEN1 (3)
3: ANYOF[\x00-y{-\xff][{unicode}0100-INFINITY] (14)
14: MEOL (15)
15: PLUS (27)
16: ANYOF[\x00-y{-\xff][{unicode}0100-INFINITY] (0)
27: CLOSE1 (29)
29: END (0)
anchored ""$ at 2 stclass ANYOF[\x00-y{-\xff][{unicode}0100-INFINITY]
Where the '""$ at 2' is sign of the bug. The problem is that the optimiser
does not "commit" the string when it encounters an MEOL, which means that
text that follows it is included. This has probably always been wrong as
$ is a multichar pattern (it matches before an \n or including an \n). This
failure to commit then interacts with the implementation for PLUS leading to
an incorrect offset. By adding a SCAN_COMMIT() as part of the optimisers
handling of EOL constructs this problem is avoided. Note that most uses of
$ were ok due to other reasons.
Father Chrysostomos [Sat, 14 Jul 2012 01:16:43 +0000 (18:16 -0700)]
[perl #113576] Restore err msg for &{+undef}
This ‘Can't use an undefined value as a subroutine reference’ message
used to occur for &{+undef}, until commit
15ff848f77796 in 1997.
Then it started happening only for magic variables.
Non-magical variables would treat it the same as "", possibly dying
with ‘Undefined subroutine main:: called’, and possibly calling the
subroutine with that name.
Magical variables (&{$tied_undef}) started behaving the same way
(treating undef as "") with commit
7c75014e, in 2010.
This commit restores that message.
Father Chrysostomos [Sat, 14 Jul 2012 01:10:38 +0000 (18:10 -0700)]
[perl #113470] Constant folding for pack
This takes the pessimistic approach of skipping it for any first argu-
ment that is not a plain non-magical PV, just in case there is a 'p'
or 'P' in the stringified form.
Otherwise it scans the PV for 'p' or 'P' and skips the folding if either
is present.
Then it falls through to the usual op-filtering logic.
I nearly made ‘pack;’ crash, so I added a test to bproto.t.
Father Chrysostomos [Sat, 14 Jul 2012 00:00:53 +0000 (17:00 -0700)]
[perl #113020] INSTALL: Clarify CPAN::autobundle
Robin Barker [Tue, 10 Jul 2012 23:32:36 +0000 (00:32 +0100)]
silence override warning
The test is trying to test the behaviour being warned about,
so the code is right but the warning can be suppressed.
Father Chrysostomos [Fri, 13 Jul 2012 16:37:23 +0000 (09:37 -0700)]
mro/basic.t: Squelch warning
Robin Barker [Tue, 10 Jul 2012 23:31:05 +0000 (00:31 +0100)]
silence warning about use of --libpods
--lipods warns, and I don't think it is needed in this test,
so I have removed it
Robin Barker [Tue, 10 Jul 2012 23:29:56 +0000 (00:29 +0100)]
silence compiler warning - casting void* to IV
This warns when void* and IV have different sizes
There is already a macro to do this conversion cleanly: PTR2IV
Father Chrysostomos [Fri, 13 Jul 2012 06:15:29 +0000 (23:15 -0700)]
mg_vtable.pl: Mention all generated files
Father Chrysostomos [Fri, 13 Jul 2012 00:50:51 +0000 (17:50 -0700)]
Fix @{*ISA} autovivification
It was not attaching magic to the array, preventing subsequent changes
to the array from updating isa caches.
Father Chrysostomos [Fri, 13 Jul 2012 00:35:37 +0000 (17:35 -0700)]
Fix *ISA = *glob_without_array
I broke this in 5.14 with commit
6624142a.
In trying to make *ISA = *Other::ISA work, I added logic to make
@Other::ISA’s existing magic now point to *ISA’s stash. I skipped
that logic if *Other::ISA did not contain an array. But in so
doing, I inadvertently skipped the call to mro_isa_changed_in at the
same time.
Father Chrysostomos [Thu, 12 Jul 2012 21:34:03 +0000 (14:34 -0700)]
op.c: Make slabs sizes powers of two
It wasn’t exactly doubling the size of the previous slab, but making
it two less than that. I’m assuming that malloc implementations round
things up to powers of two, and trying to take advantage of that, so
we don’t have wasted gaps at the ends of slabs.
Father Chrysostomos [Thu, 12 Jul 2012 21:20:31 +0000 (14:20 -0700)]
perldelta update