Karl Williamson [Mon, 3 Sep 2012 22:54:56 +0000 (16:54 -0600)]
regen/regcharclass.pl: Add new output macro type
The new type 'high' is used on only above-Latin1 code points. It is
designed for code that already knows the tested code point is not
Latin1, and avoids unnecessary tests.
Karl Williamson [Mon, 3 Sep 2012 00:29:42 +0000 (18:29 -0600)]
regen/regcharclass.pl: Add documentation
Karl Williamson [Mon, 3 Sep 2012 00:28:19 +0000 (18:28 -0600)]
regen/regcharclass.pl: Error check input better
This makes sure that the modifiers specified in the input are known to
the program.
Karl Williamson [Sun, 2 Sep 2012 22:48:14 +0000 (16:48 -0600)]
regen/regcharclass.pl: Allow comments in input
Lines whose first non-blank character is a '#' are now considered to be
comments, and ignored. This allows the moving of some lines that have
been commented out back to after the __DATA__ where they really belong.
Karl Williamson [Sun, 2 Sep 2012 21:58:41 +0000 (15:58 -0600)]
regen/unicode_constants.pl: Add name parameter
A future commit will want to use the first surrogate code point's UTF-8
value. Add this to the generated macros, and give it a name, since
there is no official one. The program has to be modified to cope with
this.
Karl Williamson [Sun, 2 Sep 2012 21:29:32 +0000 (15:29 -0600)]
Move 2 functions from utf8.c to regexec.c
One of these functions is currently commented out. The other is called
only in regexec.c in one place, and was recently revised to no longer
require the static function in utf8.c that it formerly called. They can
be made static inline.
Karl Williamson [Sun, 2 Sep 2012 20:46:38 +0000 (14:46 -0600)]
regexec.c: Use new macros instead of swashes
A previous commit has caused macros to be generated that will match
Unicode code points of interest to the \X algorithm. This patch uses
them. This speeds up modern Korean processing by 15%.
Together with recent previous commits, the throughput of modern Korean
under \X has more than doubled, and is now comparable to other
languages (which have increased themselved by 35%)
Karl Williamson [Sun, 2 Sep 2012 20:31:59 +0000 (14:31 -0600)]
regen/regcharclass.pl: Generate macros for \X processing
\X is implemented in regexec.c as a complicated series of property
look-ups. It turns out that many of those are for just a few code
points, and so can be more efficiently implemented with a macro than a
swash. This generates those.
Karl Williamson [Sun, 2 Sep 2012 20:26:20 +0000 (14:26 -0600)]
regen/regcharclass.pl: Change to work on an empty class
Future commits will add Unicode properties for this to generate macros,
and some of them may be empty in some Unicode releases. This just
causes such a generated macro to evaluate to 0.
Karl Williamson [Fri, 31 Aug 2012 23:04:30 +0000 (17:04 -0600)]
regen/regcharclass.pl: Fix bug for character '0'
The character '0' could be omitted from some generated macros due to
it's testing the value of a hash entry (getting 0 or false) instead
of if it exists or not.
Karl Williamson [Fri, 31 Aug 2012 23:00:27 +0000 (17:00 -0600)]
regen/regcharclass.pl: Work on EBCDIC platforms
This will now automatically generate macros for non-ASCII platforms,
by mapping the Unicode input to native output.
Doing this will allow several cases of EBCDIC dependencies in other code
to be removed, and fixes the bug that this previously had with non-ASCII
platforms.
Karl Williamson [Mon, 3 Sep 2012 22:22:32 +0000 (16:22 -0600)]
regen/regcharclass.pl: Remove Encode:: dependency
Newer options to unpack alleviate the need for Encode, and run faster.
Karl Williamson [Fri, 31 Aug 2012 22:39:31 +0000 (16:39 -0600)]
regen/regcharclass.pl: Handle ranges, \p{}
Instead of having to list all code points in a class, you can now use
\p{} or a range.
This changes some classes to use the \p{}, so that any changes Unicode
makes to the definitions don't have to manually be done here as well.
Karl Williamson [Sun, 2 Sep 2012 19:09:48 +0000 (13:09 -0600)]
utf8.h: Save a branch in a macro
By adding a mask, we can save a branch. The two expressions match the
exact same code points.
Karl Williamson [Sun, 2 Sep 2012 19:08:21 +0000 (13:08 -0600)]
utf8.h: White-space only
This reflows some lines to fit into 80 columns
Karl Williamson [Sun, 2 Sep 2012 19:01:50 +0000 (13:01 -0600)]
utf8.h: Correct improper EBCDIC conversion
These macros were incorrect for EBCDIC. The relationships are based on
I8, the intermediate-utf8 defined for UTF-EBCDIC, not the final encoding.
I was the culprit who did this orginally; I was confused by the names of
the conversion macros. I'm adding names that are clearer to me; which
have already been defined in utfebcdic.h, but weren't defined for
non-EBCDIC platforms.
Karl Williamson [Sun, 2 Sep 2012 16:37:26 +0000 (10:37 -0600)]
ext/B/B.xs: Remove EBCDIC dependency
These are unnecessary EBCDIC dependencies: It uses isPRINT() on EBCDIC,
and an expression on ASCII, but isPRINT() is defined to be precisely
that expression on ASCII platforms.
Karl Williamson [Sun, 2 Sep 2012 16:30:32 +0000 (10:30 -0600)]
Remove some EBCDIC dependencies
A new regen'd header file has been created that contains the native
values for certain characters. By using those macros, we can eliminate
EBCDIC dependencies.
Karl Williamson [Sun, 2 Sep 2012 15:58:43 +0000 (09:58 -0600)]
Rename regen'd hdr to reflect expanded capabilities
The recently added utf8_strings.h has been expanded to include more than
just strings. I'm renaming it to avoid confusion.
Karl Williamson [Sun, 2 Sep 2012 15:44:22 +0000 (09:44 -0600)]
regen/utf8_strings.pl: Add ability to get native charset
This adds a new capability to this program: to input a Unicode code point and
create a macro that expands to the platform's native value for it.
This will allow removal of a bunch of EBCDIC dependencies in the core.
Karl Williamson [Sun, 2 Sep 2012 15:28:55 +0000 (09:28 -0600)]
regen/utf8_strings.pl: Allow explicit default on input
An input line without a command is considered to be a request for the
UTF-8 encoded string of the code point. This allows an explicit
'string' to be used.
Karl Williamson [Sun, 2 Sep 2012 15:22:16 +0000 (09:22 -0600)]
regen/utf8_strings.pl: Copy empty input lines to output
This allows the generated .h to look better.
Karl Williamson [Fri, 31 Aug 2012 23:41:14 +0000 (17:41 -0600)]
/regcharclass.pl, utf8_strings.pl: Add guard to .h
Future commits will have other headers #include the headers generated by
these programs. It is best to guard against the preprocessor from
trying to process these twice
Karl Williamson [Fri, 31 Aug 2012 23:39:04 +0000 (17:39 -0600)]
Unicode/UCD.pm: Clarify pod
Karl Williamson [Tue, 28 Aug 2012 23:41:41 +0000 (17:41 -0600)]
Fix \X handling for Unicode 5.1 - 6.0
Commit
27d4fc33343f0dd4287f0e7b9e6b4ff67c5d8399 neglected to include a
change required for a few Unicode releases where the \X prepend property
is not empty. This does that, and suppresses a mktables warning for
Unicode releases prior to 6.2
Karl Williamson [Thu, 6 Sep 2012 16:01:38 +0000 (10:01 -0600)]
regcomp.c: Wrap some long lines
Steve Hay [Thu, 13 Sep 2012 22:27:22 +0000 (23:27 +0100)]
Steve Hay [Thu, 13 Sep 2012 22:09:19 +0000 (23:09 +0100)]
Document how to create and use smoke-me branches
The instructions are based on the following helpful email from Tony Cook:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2012-09/msg00747.html
after I tested them myself in course of commit
8700fd3876.
Steve Hay [Thu, 13 Sep 2012 21:16:44 +0000 (22:16 +0100)]
Fix a couple of headings in perlgit.pod which look to be the wrong level
Steve Hay [Wed, 12 Sep 2012 22:36:41 +0000 (23:36 +0100)]
Avoid POSIX::close when closing files by descriptor in IPC::Open3
Closing a file descriptor with POSIX::close bypasses PerlIO's ref-counting
of file descriptors and leads to MSVC++'s invalid parameter handler being
triggered when the PerlIO stream is closed later because that attempts to
close the underlying file descriptor again, but it's already closed.
So instead, we effectively fdopen() a new PerlIO stream and then close it
again to effect the closure of the file descriptor.
Jesse Luehrs [Thu, 13 Sep 2012 00:15:59 +0000 (19:15 -0500)]
whoops, move this back where it was
apparently utf8->SWASHNEW calls "require 'unicore/Heavy.pl'" too
Father Chrysostomos [Wed, 12 Sep 2012 23:19:01 +0000 (16:19 -0700)]
op.c: Document newGIVENOP(..., 0)
Something I missed in
b5a648148c.
Father Chrysostomos [Wed, 12 Sep 2012 21:03:08 +0000 (14:03 -0700)]
Fix listop-hash-infix parsing
With some list operators, this happens:
$ ./miniperl -e 'warn({$_ => 1} + 1) if 0'
syntax error at -e line 1, near "} +"
Execution of -e aborted due to compilation errors.
Putting + before the { or changing warn to print makes the prob-
lem go away.
The lexer is losing track of what token it expects next, so it ends
up interpreting the + as a unary plus, instead of an infix plus. The
parser doesn’t like that.
It happens because of this logic under case '{' (aka leftbracket:) in
toke.c:yylex:
switch (PL_expect) {
case XTERM:
if (PL_oldoldbufptr == PL_last_lop)
PL_lex_brackstack[PL_lex_brackets++] = XTERM;
else
PL_lex_brackstack[PL_lex_brackets++] = XOPERATOR;
PL_lex_allbrackets++;
OPERATOR(HASHBRACK);
The value we put on the brackstack is what we expect to find after the
closing brace (case '}' pops it off).
This particular if/else goes all the back to
ef6361f9c226 (perl
5.000), or at least that was when it moved inside the XTERM case.
Before that, we had this:
if (oldoldbufptr == last_lop)
lex_brackstack[lex_brackets++] = XTERM;
else
lex_brackstack[lex_brackets++] = XOPERATOR;
if (expect == XTERM)
OPERATOR(HASHBRACK);
So it appears that the XTERM/XOPERATOR distinction, based on last_lop
was the ‘old’ (and wrong) way of doing it, but it had to be changed in
perl 5.000 for cases other than XTERM. That it remained for XTERM was
probably an oversight, which is easy to understand, since I seem to be
the first one to stumble across this after 18 years (what’s the rele-
vant Klortho number?).
Removing this last_lop check causes no tests to fail. And it makes
sense, since anything coming right after an anonymous hash that could
be either an infix or prefix operator must be infix.
Father Chrysostomos [Wed, 12 Sep 2012 20:31:40 +0000 (13:31 -0700)]
toke.c: Under -DT, dump complement properly
Before:
$ ./miniperl -DT -e '~foo'
....
### 0:LEX_NORMAL/XSTATE ""
### <== ?? 126
....
After:
$ ./miniperl -DT -e '~foo'
....
### 0:LEX_NORMAL/XSTATE ""
### <== '~'
....
Peter Martini [Sun, 9 Sep 2012 14:45:11 +0000 (10:45 -0400)]
Add PL_subname to the save stack
Otherwise, PL_subname is left as utf8::SWASHNEW after isIDFIRST_lazy_if
(etc) is called in UTF context
Leon Timmermans [Wed, 12 Sep 2012 13:38:44 +0000 (15:38 +0200)]
Eradicate race condition in t/op/sigsystem.t (#114562)
David Mitchell [Wed, 12 Sep 2012 11:36:08 +0000 (12:36 +0100)]
stop ""-overloaded Regex recursing
There was code to detect this, but it checked for the returned value being
the same as before, but in this case it was returning a *new* temporary
reference to the same Regexp object; so check for that too.
David Mitchell [Wed, 12 Sep 2012 11:03:22 +0000 (12:03 +0100)]
add test for 6502e08, s/(.)/die/e
Forgot to add a test along with the commit that fixed this
David Mitchell [Wed, 12 Sep 2012 10:51:03 +0000 (11:51 +0100)]
perldelta: add recent regex API changes
David Mitchell [Wed, 12 Sep 2012 10:32:12 +0000 (11:32 +0100)]
update docs for $`, $&, $' changes
mention that they're now detected individually, and mention in reapi
the new RX_BUFF_IDX_* symbolic constants.
Colin Kuskie [Sun, 9 Sep 2012 20:26:49 +0000 (13:26 -0700)]
Refactor to use test.pl instead of making TAP by hand. Add test names.
Father Chrysostomos [Wed, 12 Sep 2012 03:22:57 +0000 (20:22 -0700)]
Unify CvDEPTH for formats and subs
As Dave Mitchell pointed out, while putting the CvDEPTH field for for-
mats in the SvCUR slot might save memory for formats, it slows down
sub calls because CvDEPTH is used on subs in very hot code paths.
Checking the SvTYPE to determine which field to use should not be
necessary.
Father Chrysostomos [Mon, 3 Sep 2012 05:27:52 +0000 (22:27 -0700)]
pad.c: Share pad name lists between clones
Pad names are immutable once the sub is compiled. They are shared
between clones. Instead of creating a new array containing the same
pad name SVs, just share the whole array.
cv_undef does not need to modify the pad name list when removing an
anonymous sub, so we can just delete that code. That was the only
thing modifying them between compilation and freeing, as far as I
could tell.
David Golden [Fri, 30 Mar 2012 18:02:37 +0000 (20:02 +0200)]
Updated Search::Dict to 1.07 as on CPAN
Florian Ragwitz [Tue, 11 Sep 2012 14:53:37 +0000 (10:53 -0400)]
Florian Ragwitz [Tue, 11 Sep 2012 14:36:31 +0000 (10:36 -0400)]
Text::Abbrev has been synchronised to CPAN
Florian Ragwitz [Tue, 11 Sep 2012 14:32:12 +0000 (10:32 -0400)]
Term::ReadLine has been synchronised to CPAN
Florian Ragwitz [Tue, 11 Sep 2012 14:26:29 +0000 (10:26 -0400)]
ExtUtils::Manifest has been synchronised to CPAN
Florian Ragwitz [Tue, 11 Sep 2012 14:21:18 +0000 (10:21 -0400)]
Dumpvalue has been synchronised to CPAN
Florian Ragwitz [Tue, 11 Sep 2012 14:14:46 +0000 (10:14 -0400)]
Synchronise bignum with CPAN
Florian Ragwitz [Tue, 11 Sep 2012 14:06:36 +0000 (10:06 -0400)]
Automatically create core-cpan-diff cache dir
Florian Ragwitz [Tue, 11 Sep 2012 14:02:58 +0000 (10:02 -0400)]
B::Lint hsa been synchronised to CPAN
Florian Ragwitz [Tue, 11 Sep 2012 13:56:22 +0000 (09:56 -0400)]
autouse has synchronised to CPAN
Florian Ragwitz [Tue, 11 Sep 2012 13:44:23 +0000 (09:44 -0400)]
Tell Maintainers.pl about the Storable 2.39 upgrade
Steve Hay [Tue, 11 Sep 2012 07:51:11 +0000 (08:51 +0100)]
Update perldelta entry for [perl #114496].
Improved text by Tony C, from the bug report.
Steve Hay [Tue, 11 Sep 2012 07:36:03 +0000 (08:36 +0100)]
Silence invalid parameter messages from win32_signal
This is the first step towards enabling the invalid parameter handler
without it causing undue noise. In this case the invalid parameters are
intentional, so provide a means to silence messages about them.
There is still noise from win32_close() and win32_select() which needs
resolving by some means too before the handler can be switched on without
its output causing test failures.
Steve Hay [Tue, 11 Sep 2012 07:32:41 +0000 (08:32 +0100)]
ANSIfy output from invalid parameter handler, and write it to stderr
The function, file and expression are very unlikely to contain anything
requiring UTF-16 output, and the output is less likely to interfere with
anything when written to stderr rather than stdout.
Note that the function doesn't currently do anything without hacking the
makefiles because we don't currently build with _DEBUG and the debug CRT.
I haven't changed that yet (other than locally) because there is actually
some output from it which causes a couple of tests to fail.
Steve Hay [Tue, 11 Sep 2012 07:31:34 +0000 (08:31 +0100)]
Forward declare static functions in win32/win32.c
This makes calling them easier without worrying about the order of
definition.
Craig A. Berry [Tue, 11 Sep 2012 01:40:08 +0000 (20:40 -0500)]
Identify MallocCfg* globals as variables, not functions.
Otherwise building on VMS with -Dusemymalloc=y fails because we
enter them as procedures in the linker options file and the linker
knows we're lying and will have none of it.
Abhijit Menon-Sen [Tue, 11 Sep 2012 01:34:06 +0000 (07:04 +0530)]
Bump version to 2.39 because I botched the 2.38 release
Abhijit Menon-Sen [Tue, 11 Sep 2012 01:24:17 +0000 (06:54 +0530)]
Add changelog entry for 2.38
Shlomi Fish [Tue, 11 Sep 2012 01:08:05 +0000 (21:08 -0400)]
Add more tests, Revert back to C-style for loops
This patch to lib/perl5db.pl and lib/perl5db.t adds more tests for the L
and S commands and reverts some changes from C-style for loops to
while+continue loops which were not very popular.
Florian Ragwitz [Mon, 10 Sep 2012 21:14:59 +0000 (17:14 -0400)]
Remove some set but unused variables
Thanks, gcc, for letting me know.
Florian Ragwitz [Mon, 10 Sep 2012 17:22:10 +0000 (13:22 -0400)]
Florian Ragwitz [Sat, 26 May 2012 21:15:43 +0000 (23:15 +0200)]
Stop CPAN from indexing mad/
Dominic Hargreaves [Mon, 10 Sep 2012 18:33:00 +0000 (19:33 +0100)]
Correct obvious typos in acknowledgements list
Andy Dougherty [Mon, 10 Sep 2012 12:35:16 +0000 (08:35 -0400)]
Fix [perl #114812] Configure not finding isblank().
Configure would not find isblank() when run with g++ because
the probe used exit() without including <stdlib.h>. The simplest fix
is to have the probe use return instead.
Colin Kuskie [Sun, 9 Sep 2012 20:33:05 +0000 (13:33 -0700)]
Refactor t/op/my.t to use test.pl instead of making TAP by hand
Colin Kuskie (via RT) [Sat, 8 Sep 2012 22:31:53 +0000 (15:31 -0700)]
Refactor t/op/cond.t to use test.pl instead of making TAP by hand
Colin Kuskie (via RT) [Mon, 10 Sep 2012 00:32:53 +0000 (17:32 -0700)]
Refactor t/porting/customized to use test.pl instead of making TAP by hand
Craig A. Berry [Mon, 10 Sep 2012 02:27:44 +0000 (21:27 -0500)]
Fix C++, MYMALLOC, sdbm combination.
The prototypes for the home-grown malloc replacements were not
protected with extern "C" declarations, so linking the SDBM_File
extension failed when configuring with -Dusemymalloc=y and building
with C++.
Craig A. Berry [Mon, 3 Sep 2012 02:30:55 +0000 (21:30 -0500)]
Out of memory message should not allocate memory.
This fixes [perl #40595]. When Perl_malloc reports an out of
memory error, it should not make calls to PerlIO functions that
may turn around and allocate memory using Perl_malloc. A simple
write() should be ok, though. Inspired by S_write_no_mem() from
util.c. Also replaces the local write2 function, which did the
same thing slightly differently.
Under -DDEBUGGING, there are other calls to PerlIO_printf that are
also likely unsafe, but that problem is not addressed here.
David Mitchell [Sat, 8 Sep 2012 19:17:42 +0000 (20:17 +0100)]
fix s/(.)/die/e
Commit
6502e08109cd003b2cdf39bc94ef35e52203240b introduced copying just
the part of the regex string that were needed; but piggy-backing on that
commit was a temporary change I made that I forgot to undo, which - it
turns out - causes SEGVs and similar when the replacement part of a
substitution dies.
This commits reverts that change.
Spotted as
Bleadperl v5.17.3-255-g6502e08 breaks GAAS/URI-1.60.tar.gz
(not assigned an RT ticket number yet)
David Mitchell [Sat, 8 Sep 2012 14:42:56 +0000 (15:42 +0100)]
[MERGE] only copy bits of regex match string
When making a copy of the string being matched against (so that $1, $&
et al continue to show the correct value even if the original string is
subsequently modified), only copy that substring of the original string
needed for the capture variables, rather than copying the whole string.
This is a big win for code like
$&;
$_ = 'x' x 1_000_000;
1 while /(.)/;
Also, when pessimizing if the code contains $`, $& or $', record
the presence of each variable separately, so that the determination of the
substring range is based on each variable separately. So performance-wise,
$&; /x/
is now roughly equivalent to
/(x)/
whereas previously it was like
/^(.*)(x)(.*)$/
and
$&; $'; /x/
is now roughly equivalent to
/(x)(.*)$/
etc.
Finally, this code (when not in the presence of $& etc)
$_ = 'x' x 1_000_000;
1 while /(.)/;
used to skip the buffer copy for performance reasons, but suffered from $1
etc changing if the original string changed. That's now been fixed too.
David Mitchell [Fri, 7 Sep 2012 12:32:11 +0000 (13:32 +0100)]
fix a bug in handling $+[0] and unicode
The code to decide what substring of a pattern target to copy for the
sake of $1, $& etc, would, in the absence of $&, only copy the minimum
range needed to cover $1,$2,...., which might be a shorter range than
what $& covers. This is fine most of the time, but, when calculating
$+[0] on a unicode string, it needs a copy of the whole part of the string
covered by $&, since it needs to convert the byte offest into a char
offset.
So to fix this, always copy as a minimum, the $& range.
I suppose we could be more clever about this: detect the presence
of @+ in the code, only do it for UTF8 etc; but this is simple
and non-fragile.
David Mitchell [Sat, 1 Sep 2012 10:43:53 +0000 (11:43 +0100)]
m// and s///; don't copy TEMP/AMAGIC strings
Currently pp_match and pp_subst make a copy of the match string if it's
SvTEMP(), and in the case of pp_match, also if it's SvAMAGIC().
This is no longer necessary, as the code will always copy the string
anyway if its actually needed after the match, i.e. if it detects the
presence of $1, $& or //p etc. Until a few commits ago, this wasn't the
case for pp_match: it would sometimes skip copying even in the presence of
$1 et al for efficiency reasons. Now that that's fixed, we can remove the
SvTEMP() and SvAMAGIC() tests.
As to why pp_subst did the SvTEMP test, I don't know: but removing it
didn't make any tests fail!
David Mitchell [Sat, 1 Sep 2012 10:23:58 +0000 (11:23 +0100)]
tidy up patten match copying code
(no functional changes).
1. Remove some dead code from pp_split; it's protected by an assert
that it could never be called.
2. Simplify the flags settings for the call to CALLREGEXEC() in
pp_substcont: on subsequent matches we always set REXEC_NOT_FIRST,
which forces the regex engine not to copy anyway, so passing the
REXEC_COPY_STR is pointless, as is the conditional code to set it.
3. (whitespace change): split a conditional expression over 2 lines
for easier reading.
David Mitchell [Fri, 24 Aug 2012 15:17:47 +0000 (16:17 +0100)]
stop $foo =~ /(bar)/g skipping copy
Normally in the presence of captures, a successful regex execution
makes a copy of the matched string, so that $1 et al give the right
value even if the original string is changed; i.e.
$foo =~ /(123)/g;
$foo = "bar";
is("$1", "123");
Until now that test would fail, because perl used to skip the copy for
the scalar /(...)/g case (but not the C<$&; //g> case). This was to
avoid a huge slowdown in code like the following:
$x = 'x' x 1_000_000;
1 while $x =~ /(.)/g;
which would otherwise end up copying a 1Mb string a million times.
Now that (with the last commit but one) we copy only the required
substring of the original string (a 1-byte substring in the above
example), we can remove this fast-but-incorrect hack.
David Mitchell [Fri, 24 Aug 2012 14:49:21 +0000 (15:49 +0100)]
rationalise t/re/pat_psycho.t
Do some cleanup of this file, without changing its functionality.
Once upon a time, the psycho tests were scattered throughout a single
pat.t file, before being moved into their own file. Now that they're all
in a single file, make the $PERL_SKIP_PSYCHO_TEST test a single "skip_all"
test at the beginning of the file, rather than testing it separately in
each code block.
Also, make some of the test descriptions more useful, and add a bit of
debugging output.
David Mitchell [Thu, 26 Jul 2012 15:04:09 +0000 (16:04 +0100)]
Don't copy all of the match string buffer
When a pattern matches, and that pattern contains captures (or $`, $&, $'
or /p are present), a copy is made of the whole original string, so
that $1 et al continue to hold the correct value even if the original
string is subsequently modified. This can have severe performance
penalties; for example, this code causes a 1Mb buffer to be allocated,
copied and freed a million times:
$&;
$x = 'x' x 1_000_000;
1 while $x =~ /(.)/g;
This commit changes this so that, where possible, only the needed
substring of the original string is copied: in the above case, only a
1-byte buffer is copied each time. Also, it now reuses or reallocs the
buffer, rather than freeing and mallocing each time.
Now that PL_sawampersand is a 3-bit flag indicating separately whether
$`, $& and $' have been seen, they each contribute only their own
individual penalty; which ones have been seen will limit the extent to
which we can avoid copying the whole buffer.
Note that the above code *without* the $& is not currently slow, but only
because the copying is artificially disabled to avoid the performance hit.
The next but one commit will remove that hack, meaning that it will still
be fast, but will now be correct in the presence of a modified original
string.
We achieve this by by adding suboffset and subcoffset fields to the
existing subbeg and sublen fields of a regex, to indicate how many bytes
and characters have been skipped from the logical start of the string till
the physical start of the buffer. To avoid copying stuff at the end, we
just reduce sublen. For example, in this:
"abcdefgh" =~ /(c)d/
subbeg points to a malloced buffer containing "c\0"; sublen == 1,
and suboffset == 2 (as does subcoffset).
while if $& has been seen,
subbeg points to a malloced buffer containing "cd\0"; sublen == 2,
and suboffset == 2.
If in addition $' has been seen, then
subbeg points to a malloced buffer containing "cdefgh\0"; sublen == 6,
and suboffset == 2.
The regex engine won't do this by default; there are two new flag bits,
REXEC_COPY_SKIP_PRE and REXEC_COPY_SKIP_POST, which in conjunction with
REXEC_COPY_STR, request that the engine skip the start or end of the
buffer (it will still copy in the presence of the relevant $`, $&, $',
/p).
Only pp_match has been enhanced to use these extra flags; substitution
can't easily benefit, since the usual action of s///g is to copy the
whole string first time round, then perform subsequent matching iterations
against the copy, without further copying. So you still need to copy most
of the buffer.
David Mitchell [Thu, 26 Jul 2012 14:35:39 +0000 (15:35 +0100)]
Separate handling of ${^PREMATCH} from $` etc
Currently the handling of getting the value, length etc of ${^PREMATCH}
etc is identical to that of $` etc.
Handle them separately, by adding RX_BUFF_IDX_CARET_PREMATCH etc
constants to the existing RX_BUFF_IDX_PREMATCH set.
This allows, when retrieving them, to always return undef if the current
match didn't use //p. Previously the result depended on stuff such
as whether the (non-//p) pattern included captures or not.
The documentation for ${^PREMATCH} etc states that it's only guaranteed to
return a defined value when the last pattern was //p.
As well as making things more consistent, this is a necessary
prerequisite for the following commit, which may not always copy the
whole string during a non-//p match.
David Mitchell [Fri, 22 Jun 2012 15:26:08 +0000 (16:26 +0100)]
regexec_flags(): simplify length calculation
The code to calculate the length of the string to copy was
PL_regeol - startpos + (stringarg - strbeg);
This is a hangover from the original (perl 3) regexp implementation
that under //i, copied and folded the original buffer: so startpos might
not equal stringarg. These days it always is (except under a match failure
with (*COMMIT), and the code we're interested is only executed on success).
So simplify to just PL_regeol - strbeg.
David Mitchell [Fri, 22 Jun 2012 11:36:03 +0000 (12:36 +0100)]
PL_sawampersand: use 3 bit flags rather than bool
Set a separate flag for each of $`, $& and $'.
It still works fine in boolean context.
This will allow us to have more refined control over what parts
of a match string to copy (we currently copy the whole string).
David Mitchell [Wed, 20 Jun 2012 13:17:05 +0000 (14:17 +0100)]
document args to regexec_flags and API
Document in the API, and clarify in the source code, what the arguments
to Perl_regexec_flags are.
NB: this info is based on code inspection, not any real knowledge on my
part.
Jerry D. Hedden [Wed, 5 Sep 2012 17:23:00 +0000 (13:23 -0400)]
Upgrade to threads::shared 1.41
Andy Dougherty [Tue, 4 Sep 2012 21:13:34 +0000 (17:13 -0400)]
Fix alignment for darwin with -Dusemorebits.
By default, the darwin build assumes a "multiarchitecture" build.
Configure has a hardwired default of '8' for alignbytes (and then
proceeds to ignore it with another hard-wired '8' in config.h).
That '8' was supposed to be a safe value, in case perl was built
on one architecture but run on another with a stricter constraint.
With darwin and -Dusemorebits, however, the alignment should be on
16-byte boundaries. We don't want to penalize all darwin builds for
this unlikely configuration, but we do want to allow it.
This patch causes Configure to compute alignbytes even for multiarch
builds, but if the result is less than 8, it sets it to 8 (which preserves
the previous behavior). If, however, alignbytes is 16, Configure won't
decrease it. Then, this patch also fixes config_h.SH so that it uses
the value determined by Configure instead of the previous hardwired value.
Chris 'BinGOs' Williams [Wed, 5 Sep 2012 18:22:27 +0000 (19:22 +0100)]
Update Archive-Tar to CPAN version 1.90
[DELTA]
* important changes in version 1.90 05/09/2012 (Tom Jones)
- documentation fixes
Shlomi Fish [Wed, 5 Sep 2012 02:40:38 +0000 (22:40 -0400)]
perl5db: more tests
This patch adds more tests for lib/perl5db.pl on lib/perl5db.t. One note
is that I'm a bit uncomfortable about the test for ".", which did
not initially work exactly as I expected, due to debugger quirks.
This patch also fixes a bug where the /pattern/ command (and possibly
the ?pattern? command as well) got broken due to the addition of "use
strict;", and adds tests for them.
Shlomi Fish [Wed, 5 Sep 2012 02:37:13 +0000 (22:37 -0400)]
perl5db: fix an accidental effect of strictures
see https://rt.perl.org/rt3/Ticket/Display.html?id=114284
Jerry D. Hedden [Tue, 4 Sep 2012 17:19:26 +0000 (13:19 -0400)]
Fix compiler warning about empty if body
This is meant to correct the following 'blead' build warning:
op.c: In function 'Perl_op_free':
op.c:713:30: warning: suggest braces around empty body in an 'if' statement
Andy Dougherty [Tue, 4 Sep 2012 15:36:53 +0000 (11:36 -0400)]
Collapse duplicate settings in hints/solaris_2.sh
Andy Dougherty [Tue, 4 Sep 2012 15:35:56 +0000 (11:35 -0400)]
Avoid garbled sed command in hints/solaris_2.sh
Solaris sed does not understand the GNU /i flag.
Nicholas Clark [Tue, 4 Sep 2012 10:54:35 +0000 (12:54 +0200)]
Document the reason for the early return in Perl_newPROG() for OP_STUB.
Nicholas Clark [Tue, 4 Sep 2012 10:07:35 +0000 (12:07 +0200)]
Merge improvements to -DPERL_DEBUG_READONLY_OPS into blead.
All tests pass with -Dusethreads -DPERL_DEBUG_READONLY_OPS (on this system)
Nicholas Clark [Tue, 4 Sep 2012 09:54:06 +0000 (11:54 +0200)]
In Perl_cv_forget_slab(), simplify the conditionally compiled code.
This refactoring reduces the line count and makes it clear that the basic
logic is the same with or without -DPERL_DEBUG_READONLY_OPS. It make no
change to the generated assembler on a normal build.
Nicholas Clark [Mon, 3 Sep 2012 14:47:15 +0000 (16:47 +0200)]
Perl_magic_setdbline() should clear and set read-only OP slabs.
The debugger implements breakpoints by setting/clearing OPf_SPECIAL on
OP_DBSTATE ops. This means that it is writing to the optree at runtime,
and it falls foul of the enforced read-only OP slabs when debugging with
-DPERL_DEBUG_READONLY_OPS
Avoid this by removing static from Slab_to_rw(), and using it and Slab_to_ro()
in Perl_magic_setdbline() to temporarily make the slab re-write whilst
changing the breakpoint flag.
With this all tests pass with -DPERL_DEBUG_READONLY_OPS (on this system)
Nicholas Clark [Tue, 14 Aug 2012 12:24:34 +0000 (14:24 +0200)]
In op.c, change S_Slab_to_rw() from an OP * parameter to an OPSLAB *.
This makes it consistent with Perl_Slab_to_ro(), which takes an OPSLAB *.
Nicholas Clark [Tue, 14 Aug 2012 12:10:30 +0000 (14:10 +0200)]
With -DPERL_DEBUG_READONLY_OPS, changing a slab refcnt shouldn't make it r/w.
Perl_op_refcnt_inc() and Perl_op_refcnt_dec() now both take care to leave the
slab in the same state as they found it. Previously both would
unconditionally make the slab read-write.
Nicholas Clark [Wed, 8 Aug 2012 10:37:48 +0000 (12:37 +0200)]
Under -DPERL_DEBUG_READONLY_OPS don't work around glibc 2.2.5 _moddi3 bugs.
The work around involves a runtime check and substituting OP pointers based
on the result. The substitution fails if the optree is mapped read-only.
Sébastien Aperghis-Tramoni [Tue, 4 Sep 2012 05:42:26 +0000 (07:42 +0200)]
Make dual-lived constant.pm work on 5.8 again
Before releasing the version of constant.pm from bleadperl to the CPAN,
I tested it with the versions of Perl I have by hand, and it appears
that the current code fails to compile on 5.8:
Bareword "_DOWNGRADE" not allowed while "strict subs" in use at
lib/constant.pm line 142.
Added by
bd8cb5529605f33aa9cf95d6c471386b3a0e015d
Removing the short-circuit return allows the code to compile and the
tests to pass on all stable Perl from 5.8.2 to 5.16.1.