Karl Williamson [Thu, 29 Nov 2012 03:16:06 +0000 (20:16 -0700)]
Make isIDFIRST_uni() return identically as isIDFIRST_utf8()
These two macros should have the same results for the same input code
points. Prior to this patch, the _uni() macro returned the official
Unicode ID_Start property, and the _utf8() macro returned Perl's
slightly restricted definition. Now both return Perl's.
Karl Williamson [Thu, 29 Nov 2012 02:51:43 +0000 (19:51 -0700)]
Remove double underscore in internal function name
This function was added in 5.16, and has no callers in CPAN. It is
undocumented and marked as changeable. Its name has two underscores in
a row by mistake. This removes one of them.
Karl Williamson [Thu, 29 Nov 2012 03:40:12 +0000 (20:40 -0700)]
XS-APItest/t/handy.t: Turn off non_unicode warnings
Tests here use above-Unicode code points, so the warnings these might
otherwise generate should be forced off.
Karl Williamson [Thu, 29 Nov 2012 03:35:45 +0000 (20:35 -0700)]
charnames: Check for enabled warnings before warning
This message should be suppressed if non_unicode warnings are turned
off.
Karl Williamson [Wed, 28 Nov 2012 22:01:29 +0000 (15:01 -0700)]
mktables: Sort some outputs for repeatability
The recent change to random hash ordering caused some of the files
output by mktables to vary from run to run. Everything still worked.
However, one of the ways I debug mktables is to make a change, and then
compare the tables it generates with those from before the change. That
tells me the precise effect of the change. That no longer works if the
tables come out in random order from run to run.
This patch just sorts certain things so that the tables are output in
the same order each time.
Karl Williamson [Wed, 28 Nov 2012 15:46:52 +0000 (08:46 -0700)]
embed.fnc, mathoms.c: Add comments
Karl Williamson [Tue, 27 Nov 2012 22:24:17 +0000 (15:24 -0700)]
perlapi: Don't mention internal function
This function is undocumented, and is for internal core use only. Cause
it to not be mentioned in perlapi
Father Chrysostomos [Tue, 27 Nov 2012 15:08:08 +0000 (07:08 -0800)]
[Merge] New COW mechanism
This branch makes string copying faster by introducing a new copy-on-
write mechanism. A reference count for the string buffer is now
stored inside the string buffer itself. This can be disabled with
-Accflags=-DPERL_NO_COW.
It also disables the PL_sawampersand mechanism, as copy-on-write
can now be used for the pre-match ‘copy’, resulting in no slow-
down from using $& and f(r)iends. This can be reënabled with
-Accflags=-DPERL_SAWAMPERSAND.
Father Chrysostomos [Tue, 27 Nov 2012 06:23:53 +0000 (22:23 -0800)]
Don’t share TARGs between recursive ops
I had to change the definition of IS_PADCONST to account for the
SVf_IsCOW flag. Previously, anything marked READONLY would be consid-
ered a pad constant, to be shared by pads of different recursion lev-
els. Some of those READONLY things were not actually read-only, as
they were copy-on-write scalars, which are never read-only. So I
changed the definition of IS_PADCONST in
e3918bb703c to accept COWs
as well as read-only scalars, since I was removing the READONLY flag
from COWs.
With the new copy-on-write scheme, it is easy for a TARG to turn into
a COW. If that happens and then the same subroutine calls itself
recursively for the first time after that, pad_push will see that this
is a pad ‘constant’ and allow the next recursion level to share it.
If pp_concat calls itself recursively, the recursive call can modify
the scalar the outer call is in the middle of using, causing the
return value to be doubled up (‘tmptmp’) in the test case added here.
Since pad constants are marked PADTMP (I would like to change that
eventually), there is no way to distinguish them from TARGs when the
are COWs, except for the fact that pad constants that are COWs are
always shared hash keys (SvLEN==0).
Father Chrysostomos [Mon, 26 Nov 2012 17:40:34 +0000 (09:40 -0800)]
subst.t: Test something I nearly broke
The saving and restoring of $@ when utf8 tables were looked up was
causing pp_subst’s string pointers to go stale. The existing mechanism
of copying it temporarily to another scalar was already very fragile,
and the new COW mechanism broke it (but I fixed it in the same commit
that introduced the new COW mechanism).
Father Chrysostomos [Sun, 25 Nov 2012 22:50:48 +0000 (14:50 -0800)]
Update docs to concur with $`,$&,$' changes
plus a couple of other pod tweaks.
Father Chrysostomos [Sun, 25 Nov 2012 22:31:25 +0000 (14:31 -0800)]
Increase $English::VERSION to 1.06
Father Chrysostomos [Sun, 25 Nov 2012 22:31:04 +0000 (14:31 -0800)]
English.pm: Update -no_match_vars docs
Father Chrysostomos [Sun, 25 Nov 2012 22:28:25 +0000 (14:28 -0800)]
Test perl #4289
This was fixed by the disabling of PL_sawampersand a few commits ago.
The output used to be like this:
$ perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$&|, "\n"'
e
$ perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$`|, "\n"'
h
$ perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$'\''|, "\n"'
l
Now it’s like this:
$ ./perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$&|, "\n"'
b
$ ./perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$`|, "\n"'
a
$ ./perl -e '$_ = "abc"; /b/g; $_ = "hello"; print eval q|$'\''|, "\n"'
c
Father Chrysostomos [Sun, 25 Nov 2012 22:04:05 +0000 (14:04 -0800)]
test_bootstrap.t: Skip PL_sawampersand tests
unless PERL_SAWAMPERSAND is defined.
Father Chrysostomos [Sun, 25 Nov 2012 21:58:40 +0000 (13:58 -0800)]
Fix up Peek.t to account for preceding commits
Father Chrysostomos [Sun, 25 Nov 2012 21:52:27 +0000 (13:52 -0800)]
perl.h: Mention PERL_SAWAMPERSAND in perl -V output
Father Chrysostomos [Sun, 25 Nov 2012 20:57:04 +0000 (12:57 -0800)]
Disable PL_sawampersand
PL_sawampersand actually causes bugs (e.g., perl #4289), because the
behaviour changes. eval '$&' after a match will produce different
results depending on whether $& was seen before the match.
Using copy-on-write for the pre-match copy (preceding patches do that)
alleviates the slowdown caused by mentioning $&. The copy doesn’t
happen unless the string is modified after the match. It’s now a
post- match copy. So we no longer need to do things differently
depending on whether $& has been seen.
PL_sawampersand is now #defined to be equal to what it would be if
every program began with $',$&,$`.
I left the PL_sawampersand code in place, in case this commit proves
immature. Running Configure with -Accflags=PERL_SAWAMPERSAND will
reënable the PL_sawampersand mechanism.
Father Chrysostomos [Wed, 21 Nov 2012 20:45:33 +0000 (12:45 -0800)]
Enable PERL_NEW_COPY_ON_WRITE by default
One can disable this with -Accflags=-DPERL_NO_COW.
I am leaving this in for debugging purposes. If it causes no problems
in 5.18, we might remove the defines and enable it unconditionally in
5.20, but then again we might not.
Father Chrysostomos [Sun, 4 Nov 2012 07:07:31 +0000 (00:07 -0700)]
Allow COW with magical and blessed scalars (among others)
Under PERL_NEW_COPY_ON_WRITE (and I suspect under
PERL_OLD_COPY_ON_WRITE, too, but have not confirmed) it is harmless to
do copy-on-write with a magical or blessed scalar.
Also, under PERL_NEW_COPY_ON_WRITE, it is safe to do copy-on-write
with scalars that have numbers in them as well as strings (though not
under PERL_OLD_COPY_ON_WRITE).
So redefine CAN_COW_MASK under PERL_NEW_COPY_ON_WRITE to be less
restrictive. We still can’t do it when the SvOOK hack is in place,
and I don’t feel comfortable doing it with regexps, even if it could
be proven feasible (regexps are SVf_FAKE, so that covers them).
Anything SvROK cannot be SvPOK, so obviously we can’t COW with that,
but I left SVf_ROK in for good measure.
This change to CAN_COW_MASK affects whether non-cow scalars will be
turned into cows in sv_setsv_flags. It is already possible for exist-
ing cows to become magical, blessed or numeric elsewhere.
Also, we don’t need to check the flags on the lhs in sv_setsv_flags,
except for SVf_BREAK. This is similar to
ecd5fa70f3, but applies to
another branch just below it.
pp_subst needs a little bit of adjustment, as it is not expecting a
vstring to turn into a cow.
Father Chrysostomos [Fri, 19 Oct 2012 16:52:03 +0000 (09:52 -0700)]
Min string length for COW
We have two separate length thresholds for when copy-on-write kicks
in, one for when a buffer would have had to be (re)allocated
(SV_COW_THRESHOLD) and another for when there is already a large
enough buffer available (SV_COWBUF_THRESHOLD).
Benchmarking against mktables and against Test.Simple’s test suite
(see JS::Test::Simple on CPAN) run with WWW::Scripter and JE shows
that 0/1250 is the best combination, at least on 32-bit darwin.
Apparently, copying into an existing buffer is much faster than the
bookkeeping overhead of sv_force_normal_flags (which I see no way to
speed up).
I have defined these conditionally with #ifndef, so that platform-spe-
cific hints can override them with values appropriate to the platform.
Also, refactor things in sv_setsv_flags slightly to avoid using SvLEN
and SvCUR repeatedly.
Father Chrysostomos [Mon, 8 Oct 2012 07:20:21 +0000 (00:20 -0700)]
New COW mechanism
This was discussed in ticket #114820.
This new copy-on-write mechanism stores a reference count for the
PV inside the PV itself, at the very end. (I was using SvEND+1
at first, but parts of the regexp engine expect to be able to do
SvCUR_set(sv,0), which causes the wrong byte of the string to be used
as the reference count.) Only 256 SVs can share the same PV this way.
Also, only strings with allocated space after the trailing null can
be used for copy-on-write.
Much of the code is shared with PERL_OLD_COPY_ON_WRITE. The restric-
tion against doing copy-on-write with magical variables has hence been
inherited, though it is not necessary. A future commit will take
care of that.
I had to modify _core_swash_init to handle $@ differently. The exist-
ing mechanism of copying $@ to a new scalar and back again was very
fragile. With copy-on-write, $@ =~ s/// can cause pp_subst’s string
pointers to become stale. So now we remove the scalar from *@ and
allow the utf8-table-loading code to autovivify a new one. Then we
restore the untouched $@ afterwards if all goes well.
Matthew Horsfall (alh) [Sun, 25 Nov 2012 16:13:05 +0000 (11:13 -0500)]
Fix comment referencing pp_iterinit (should be pp_enteriter)
Karl Williamson [Mon, 26 Nov 2012 23:18:47 +0000 (16:18 -0700)]
regexec.c: White space only; no code changes
Karl Williamson [Mon, 26 Nov 2012 23:06:53 +0000 (16:06 -0700)]
Remove 3 unused interpreter variables
These variables have been unused in the Perl core since
commit
4c88d5e0740d796bf5064336d280bba72897f385.
The variables are undocumented. The only real use of any of these I
found in CPAN is at
https://metacpan.org/source/ABERGMAN/Devel-GC-Helper-0.25/Helper.xs#L1
The uses there appear to be in a list of known Perl variables. Since
the module was published, more than a few new variables have been added,
making this code obsolete anyway.
Craig A. Berry [Mon, 26 Nov 2012 13:07:21 +0000 (07:07 -0600)]
Consider /... a directory component with EFS on VMS.
For some reason the omnibus patch (
360732b5267d5dfe) that brought
Extended Filename Syntax support to the VMS port considered three
dots part of the filename portion rather than part of the
directory portion when converting a Unix-format path to VMS format.
There's no reason this should be different with EFS, so make it
the same as without EFS, which gets two TODO tests passing.
Father Chrysostomos [Mon, 26 Nov 2012 01:13:21 +0000 (17:13 -0800)]
Add Bob Ernst to AUTHORS
Father Chrysostomos [Fri, 5 Oct 2012 20:00:35 +0000 (13:00 -0700)]
Move a CAN_COW_MASK comment from sv.c to sv.h
It got left behind in
ed25273444 when the macro moved.
Father Chrysostomos [Thu, 4 Oct 2012 19:45:45 +0000 (12:45 -0700)]
Missing dependency in XS::APItest’s Makefile
When core_or_not.inc is modified, core.c and notcore.c should
be recompiled.
Father Chrysostomos [Sun, 25 Nov 2012 21:03:07 +0000 (13:03 -0800)]
Stop cv-to-glob assignment redef warnings from leaking
We should not increment the reference count of the assignee until we
are past the warnings. It should only happen when the reference-
counted location is actually made to hold the assignee.
At the same time, I changed it to use a more specific variant of
SvREFCNT_inc, for speed.
Bob Ernst [Sun, 18 Nov 2012 00:03:58 +0000 (00:03 +0000)]
Add descriptions to tests for exp.t
Bob Ernst [Sat, 17 Nov 2012 22:14:53 +0000 (22:14 +0000)]
Add descriptions to tests for fh.t
Bob Ernst [Sat, 17 Nov 2012 21:18:20 +0000 (21:18 +0000)]
Added descriptions to tests in reverse.t
Bob Ernst [Sat, 17 Nov 2012 19:57:39 +0000 (19:57 +0000)]
Add descriptions to tests for int.t
Chris 'BinGOs' Williams [Sun, 25 Nov 2012 17:39:29 +0000 (17:39 +0000)]
Update Compress-Raw-Zlib to CPAN version 2.059
[DELTA]
2.059 24 November 2012
* Copy-on-write support
[#81353]
Chris 'BinGOs' Williams [Sun, 25 Nov 2012 17:38:06 +0000 (17:38 +0000)]
Update Compress-Raw-Bzip2 to CPAN version 2.059
[DELTA]
2.059 24 November 2012
* Copy-on-write support
[#81352]
Chris 'BinGOs' Williams [Sun, 25 Nov 2012 17:36:18 +0000 (17:36 +0000)]
Update Digest-SHA to CPAN version 5.74
[DELTA]
5.74 Sat Nov 24 03:10:18 MST 2012
- handle wide-string input by converting to bytes first
-- viz. use SvPVbyte instead of SvPV in SHA.xs
-- thanks to Eric Brine for summary and code
Craig A. Berry [Sun, 25 Nov 2012 16:03:25 +0000 (10:03 -0600)]
Bump Term::ReadLine version.
Craig A. Berry [Sun, 25 Nov 2012 15:09:59 +0000 (09:09 -0600)]
Add Sven Strickroth to AUTHORS.
Craig A. Berry [Sun, 25 Nov 2012 14:54:32 +0000 (08:54 -0600)]
Rational findConsole dispatch for Term::ReadLine.
Back in 5.002 or so, if we didn't find /dev/tty and weren't on
Windows, the console was assumed to be sys$command, which only
makes sense on VMS (possibly $^O didn't work yet on VMS?).
Later accretions have assumed that the sys$command default meant
something other than laziness and a second if block with various
specific overrides was added, some of which set the console back
to undef after its having been set to sys$command.
That can all be avoided by simply checking we're on VMS before
setting the console to sys$command and letting it default to
STDIN for cases where we don't know of something else specific
that it should be.
Sven Strickroth [Sun, 25 Nov 2012 14:44:02 +0000 (08:44 -0600)]
(msys) perl readline creates sys$command files w/o STDIN connected
This fixes [perl #115900].
Karl Williamson [Sun, 25 Nov 2012 14:58:21 +0000 (07:58 -0700)]
pp_hot.c: Comment typo, white-space only
No code changes
Karl Williamson [Sun, 25 Nov 2012 04:06:36 +0000 (21:06 -0700)]
Remove "register" declarations
This finishes the removal of register declarations started by
eb578fdb5569b91c28466a4d1939e381ff6ceaf4. It neglected the ones in
function parameter declarations, and didn't include things in dist, ext,
and lib, which this does include
Karl Williamson [Sun, 25 Nov 2012 03:59:39 +0000 (20:59 -0700)]
perlhack: Add note to not use "register" declarations
Matthew Horsfall (alh) [Sat, 24 Nov 2012 18:05:49 +0000 (13:05 -0500)]
RT-23180 - If we skip matching in pp_match for any reason, pos() must still be updated.
Craig A. Berry [Sun, 25 Nov 2012 01:06:45 +0000 (19:06 -0600)]
Clarify reporting of .DIR extension on VMS.
In readdir and start_glob, we were removing the .DIR extension from
VMS directory names when reporting results in Unix format, but also
when Extended Filename Syntax (EFS) was enabled. The former makes
sense, but the latter (by itself) doesn't.
Craig A. Berry [Sun, 25 Nov 2012 00:46:44 +0000 (18:46 -0600)]
Handle invalid directory spec with EFS in pathify_dirspec.
When Extended Filename Syntax is enabled on VMS (which is not [yet]
the default), we were allowing invalid directory specifications
consisting of a .DIR extension but some version other than ;1 to
be passed through.
Now we flag that as an invalid directory just as we were doing
without EFS. This gets a test passing in vms/ext/filespec.t that
was failing under EFS.
Father Chrysostomos [Sat, 24 Nov 2012 23:55:04 +0000 (15:55 -0800)]
Increase $Module::CoreList::VERSION to 2.79
Alexandr Ciornii [Sat, 24 Nov 2012 18:24:26 +0000 (20:24 +0200)]
Errno was added in 5.5, not in 5.5.4
Karl Williamson [Sat, 24 Nov 2012 18:18:31 +0000 (11:18 -0700)]
Request is_utf8_char_slow() be inlined
Karl Williamson [Sat, 24 Nov 2012 18:14:28 +0000 (11:14 -0700)]
regen/embed.pl: flag 'i' didn't work with 'n'
Yves Orton [Sat, 24 Nov 2012 18:21:38 +0000 (19:21 +0100)]
Add "buzzhash16" - a random hash function
This is just a toy. Probably not worth using in production. But
interesting enough I thought I would include it.
The idea is to use the hash seed as a table of random 16 bit integers
whose values are what we hash depending on the character we read.
It is pretty fast, I have no idea how secure it is. It will probably
work really badly if the seed is crap. YMMV.
Father Chrysostomos [Sat, 24 Nov 2012 08:31:01 +0000 (00:31 -0800)]
Stop sub decl redef warnings from leaking CVs
When newMYSUB and newATTRSUB are called, PL_compcv has an unclaimed
reference count, so any code that croaks must decrement the reference
count or make arrangements for such to happen.
This commit applies only to redefinition warnings triggered by sub
declarations, like ‘sub foo {}’ and ‘my sub foo {}’.
Father Chrysostomos [Sat, 24 Nov 2012 08:24:25 +0000 (00:24 -0800)]
perldiag: Correct wording of ‘Using just the first char...’
Father Chrysostomos [Sat, 24 Nov 2012 08:20:17 +0000 (00:20 -0800)]
perldiag: Add cat to ‘Using just the first char...’
Father Chrysostomos [Sat, 24 Nov 2012 08:19:05 +0000 (00:19 -0800)]
Increase $feature::VERSION to 1.32
Father Chrysostomos [Sat, 24 Nov 2012 08:10:15 +0000 (00:10 -0800)]
Warn when declaring lexsubs, not when enabling them
feature.pm has an ":all" tag. So if we warn when lexical subs are
enabled, then ‘use feature ":all"’ will also warn. That’s unkind.
Instead, warn when a lexical sub is declared via
‘my/our/state sub...’.
Father Chrysostomos [Sat, 24 Nov 2012 07:47:05 +0000 (23:47 -0800)]
op.c: Factor common ‘existing sub’ logic into static routine
newMYSUB and newATTRSUB are very similar but differ in small ways
throughout. This particular block of code is close enough it can be
moved into a separate static routine to avoid repetition.
Father Chrysostomos [Sat, 24 Nov 2012 07:44:49 +0000 (23:44 -0800)]
Warn by default for constant my sub redefinition
I apparently never had this working and never tested it either.
I was checking whether the new sub was a constant, rather than the one
it was clobbering.
Father Chrysostomos [Sat, 24 Nov 2012 07:32:55 +0000 (23:32 -0800)]
Prevent double frees with lexical constants
my sub foo() { 2 }
This produces a double free, because SAVEPADSVANDMORTALIZE causes the
reference count to go down on scope exit, and nothing was increment-
ing it to compensate.
Father Chrysostomos [Sat, 24 Nov 2012 04:40:39 +0000 (20:40 -0800)]
op.c:newATTRSUB: Change an if condition to an else
In one spot we have if(blah blah balh) {...} followed by
if (<exactly the opposite>). We can just change the second if to
an else, since the condition is not going to change here.
This brings newATTRSUB and newMYSUB slightly closer, allowing me
to factor some of it out into a static routine in the next commit.
Father Chrysostomos [Sat, 24 Nov 2012 04:32:49 +0000 (20:32 -0800)]
Stop ignored :lvalue warning from leaking CVs
When newMYSUB and newATTRSUB are called, PL_compcv has an unclaimed
reference count, so any code that croaks must decrement the reference
count or make arrangements for such to happen.
Yves Orton [Sat, 24 Nov 2012 10:16:48 +0000 (11:16 +0100)]
prevent memory exhaustion from hash attacks
We do not want to resize the hash every time the bucket length is
too long. Nor do we want to pay the price of checking how long
the bucket length is when there is nothing we can do about it anyway.
Daniel Dragan [Fri, 23 Nov 2012 21:15:04 +0000 (16:15 -0500)]
SvPVXtrue single eval->multiple eval
Make SvTRUE and SvPVXtrue smaller and faster in machine code on non GCC
compilers.
This commit implements my posts here,
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195720.html
and in my commit message in commit
4cc783efe0 . SvPVXtrue was added in
commit
4bac9ae47b . No reason was given why SvPVXtrue is single eval, but
its only use is in multi eval SvTRUE. A non GCC compiler will write to
PL_Xpv and PL_Sv, and still keep the SV * and PV *s in a register for the
next operations/instructions. The writes to PL_Xpv and PL_Sv are needless.
The use of PL_Xpv and PL_Sv is self explanatory C lang wise. As said in the
ML post, this commit causes overall code bloat because of incorrect uses
of passing macro args that make calls (ERRSV for example) to SvTRUE. This
will have to be fixed in the future. All of the pp opcode funcs decrease
tiny bit in size after this commit. See the ML list post for details.
Father Chrysostomos [Sat, 24 Nov 2012 01:54:09 +0000 (17:54 -0800)]
Stop toke.c:S_scan_const from leaking
Fatal warnings and errors can cause the string buffer used when
scanning a quote-like operator to leak. This commit fixes it
by using the savestack. There are still a few leaks from that
code path that are not fixed by this.
Daniel Dragan [Fri, 23 Nov 2012 04:37:29 +0000 (23:37 -0500)]
prevent multiple evaluations of ERRSV
Remove a large amount of machine code (~4KB for me) from funcs that use
ERRSV making Perl faster and smaller by preventing multiple evaluation.
ERRSV is a macro that contains GvSVn which eventually conditionally calls
Perl_gv_add_by_type. If a SvTRUE or any other multiple evaluation macro
is used on ERRSV, the expansion will, in asm have dozens of calls to
Perl_gv_add_by_type one for each test/deref of the SV in SvTRUE. A less
severe problem exists when multiple funcs (sv_set*) in a row call, each
with ERRSV as an arg. Its recalculated then, Perl_gv_add_by_type and all.
I think ERRSV macro got the func call in commit
f5fa9033b8, Perl RT #70862.
Prior to that commit it would be pure derefs I think. Saving the SV* is
still better than looking into interp->gv->gp to get the SV * after each
func call.
I received no responses to
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195724.html
explaining when the SV is replaced in PL_errgv, so took a conservative
view and assumed callbacks (with Perl stack/ENTER/LEAVE/eval_*/call_*)
can change it. I also assume ERRSV will never return null, this allows a
more efficiently version of SvTRUE to be used.
In Perl_newATTRSUB_flags a wasteful copy to C stack operation with the
string was removed, and a croak_notcontext to remove push instructions to
the stack. I was not sure about the interaction between ERRSV and message
sv, I didn't change it to a more efficient (instruction wise, speed, idk)
format string combining of the not safe string and ERRSV in the croak call.
If such an optimization is done, a compiler potentially will put the not
safe string on the first, unconditionally, then check PL_in_eval, and
then jump to the croak call site, or eval ERRSV, push the SV on the C stack
then push the format string "%"SVf"%s". The C stack allocated const char
array came from commit
e1ec3a884f .
In Perl_eval_pv, croak_on_error was checked first to not eval ERRSV unless
necessery. I was not sure about the side effects of using a more efficient
croak_sv instead of Perl_croak (null chars, utf8, etc) so I left a comment.
nocontext used to save an push instruction on implicit sys perl.
In S_doeval, don't open a new block to avoid large whitespace changes.
The NULL assignment should optimize away unless accidental usage of errsv
in the future happens through a code change. There might be a bug here from
commit
ecad31f018 since previous a char * was derefed to check for null
char, but ERRSV will never be null, so "Unknown error\n" branch will never
be taken.
For pp_sys.c, in pp_die a new block was opened to not eval ERRSV if
"well-formed exception supplied". The else if else if else blocks all used
ERRSV, so a "SV * errsv = NULL;" and a eval in the conditional with comma
op thing wouldn't work (maybe it would, see toke.c comments later in this
message). pp_warn, I have no comments.
In S_compile_runtime_code, a croak_sv question comes up same as in
Perl_eval_pv.
In S_new_constant, a eval in the conditional is done to avoid evaling
ERRSV if PL_in_eval short circuits. Same thing in Perl_yyerror_pvn.
Perl__core_swash_init I have no comments.
In the future, a SvEMPTYSTRING macro should be considered (not fully
thought out by me) to replace the SvTRUEs with something smaller and
faster when dealing with ERRSV. _nomg is another thing to think about.
In S_init_main_stash there is an opportunity to prevent an extra ERRSV
between "sv_grow(ERRSV, 240);" and "CLEAR_ERRSV();" that was too complicated
for me to optimize.
before perl517.dll
.text 0xc2f77
.rdata 0x212dc
.data 0x3948
after perl517.dll
.text 0xc20d7
.rdata 0x212dc
.data 0x3948
Numbers are from VC 2003 x86 32 bit.
Father Chrysostomos [Fri, 23 Nov 2012 03:18:57 +0000 (19:18 -0800)]
sv.c:S_curse: move assertions to make them useful
I added these when debugging something, and decided to keep them, as
they could be useful. So I committed them as
14eebc59.
But now I realise that they are quite useless where they are, as a
program will crash before the failed assertions are reached.
Father Chrysostomos [Thu, 22 Nov 2012 22:53:47 +0000 (14:53 -0800)]
sv.c:S_curse: remove unnecessary null check
If an SV has the OBJECT flag on but no STASH, it will cause crashes
elsewhere. So there has to be a stash here. I only put the null
check there in
8c34e50dc because I was copying what StashHANDLER
used to do.
8c34e50dc removed the use of StashHANDLER (which calls
gv_handler, which has a null check), replacing it with a different
caching mechanism inlined into S_curse.
Father Chrysostomos [Thu, 22 Nov 2012 06:52:14 +0000 (22:52 -0800)]
svleak.t: To-do tests for fatal warnings and some syntax errs
Daniel Dragan [Fri, 23 Nov 2012 08:57:41 +0000 (00:57 -0800)]
remove an EXTEND from XS_re_regexp_pattern
Replace 2 EXTENDs with 1. Whether the stack is extended by 1 or 2 makes
no signifigant memory difference, so use the large value of 2. Less
machine code is the purpose. This XSUB went from 0x1C2 long to 0x19E for me
after these changes on VC 2003 x86 32bit. The SP and items was moved so
items is tossed a tiny bit sooner by the compiler in case the compiler
tries to save it because it doesn't recogize noreturn declared funcs.
Nicholas Clark [Fri, 23 Nov 2012 13:29:05 +0000 (14:29 +0100)]
SuperFastHash needs to define PERL_HASH_SEED_BYTES appropriately.
Nicholas Clark [Fri, 23 Nov 2012 10:42:02 +0000 (11:42 +0100)]
The size of PL_hash_seed depends on the chosen hash algorithm.
For most 8 is fine, but SipHash needs 16.
Chris 'BinGOs' Williams [Fri, 23 Nov 2012 11:47:26 +0000 (11:47 +0000)]
Update Unicode-Collate to CPAN version 0.94
[DELTA]
0.94 Fri Nov 23 18:45:53 2012
- U::C::Locale newly supports locale: zh__zhuyin.
- added Unicode::Collate::CJK::Zhuyin for zh__zhuyin.
- doc: added CAVEAT to CJK/Stroke.pm
- modified tests: loc_cjk.t, loc_cjkc.t in t.
- added cjk_zy.t, loc_zhzy.t in t.
bulk88 (via RT) [Fri, 23 Nov 2012 00:33:34 +0000 (16:33 -0800)]
av_exists: dont make a mortal never to use it
Make av_exists slightly smaller and faster by reducing the liveness of a
mortal SV and using a NN SvTRUE_nomg.
There were 3 cases, where this mortal would be created, yet a return
happened and the mortal went unused and was wasted. So move the mortal
creation point closer to where it is first used. Also var sv will never be
null, so use a NN version of SvTRUE_nomg created in commit [perl #115870].
The retbool line isn't actually required for optimization reasons, but was
created just in case something in the future changes or some unknown
compiler does something inefficiently.
For me with 32 bit x86 VC 2003, before av_exists was 0x1C2, after 0x1B8.
Comment from committer: Includes SvTRUE_nomg_NN from [perl #115870].
l.mai@web.de [Fri, 23 Nov 2012 02:03:55 +0000 (18:03 -0800)]
Fix typo in perl5120delta
Daniel Dragan [Fri, 23 Nov 2012 07:02:18 +0000 (08:02 +0100)]
Reduce scope of SP in Perl_eval_pv
This commit has no effect on machine code, since dSP has no calls and
is removed as dead code by the compiler since SP is never read until after
the SPAGAIN. By reducing the scope of SP, accidentally lengthing SP's
liveness won't happen and also the code makes a little bit more sense than
the SPAGAIN which for a sec makes you think SVs were put on the Perl
stack before the eval_sv call. Clarity is the purpose.
Craig A. Berry [Fri, 23 Nov 2012 03:55:31 +0000 (21:55 -0600)]
Preserve the case of t/lib/vmsfspec.t.
The way this file has been getting copied from vms/ext/filespec.t
during the build involves the expansion of the standard macro
MMS$TARGET, a process which caused the name of the copied file to
always end up in upper case.
Before we started preserving case, all filenames were downcased
by readdir(), so .t matched .t and everything was peachy. But
when we started preserving case in Perl on VMS we started silently
skipping this test because .T does not match the pattern we look
for in t/TEST.
So take advantage of the fact that MMS and MMK don't upcase
user-written macros when expanded and use one of those as the
copy target, thus preserving the case of the copied file, which
then matches what t/TEST is looking for.
Karl Williamson [Thu, 22 Nov 2012 15:48:59 +0000 (08:48 -0700)]
podcheck.t: Was always giving failure under -regen
The tests added in commit
da33abaf8bbfaee9e713ac54f3355186650df952
should be skipped under -regen. No tests should be run under -regen.
Chris 'BinGOs' Williams [Thu, 22 Nov 2012 11:05:06 +0000 (11:05 +0000)]
Update with Module-CoreList-2.78
Nicholas Clark [Wed, 21 Nov 2012 15:12:57 +0000 (16:12 +0100)]
Skip the test for fork's undef return if ulimit -u doesn't work locally.
Commit
af2fe5eb7afec48a added a test for fork returning undef on failure,
which used ulimit -u to lower the number of user processes to provoke fork
failure. Whilst the test was careful to ensure that it only attempted this
if the shell is bash or zsh, it turns out that one some platforms (at least
HP-UX and AIX), bash offers ulimit -u, but will always error if its use is
attempted. So probe that ulimit -u can be used, and skip the test if it
can't.
Nicholas Clark [Thu, 22 Nov 2012 09:27:51 +0000 (10:27 +0100)]
Bump $XS::Typemap::VERSION after previous commit.
Steffen Mueller [Thu, 22 Nov 2012 07:03:16 +0000 (08:03 +0100)]
Add additional tests for T_BOOL typemap
Unlike the existing tests, these new tests don't use RETVAL.
Craig A. Berry [Thu, 22 Nov 2012 04:03:03 +0000 (22:03 -0600)]
Better pass-through handling for tovmsspec.
When translating filenames from Unix syntax to VMS syntax, there
are some unparseable cases that are best left unchanged. We were
doing this with extended filename syntax turned off, but we still
need it even when extended filename syntax is turned on, such as
for unescaped extended characters in a name that has no directory
delimiters.
Yves Orton [Wed, 21 Nov 2012 23:45:45 +0000 (00:45 +0100)]
previous patch forgot to bump the version on Locale::Maketext for CPAN
also updated Changelog
Yves Orton [Wed, 21 Nov 2012 23:43:14 +0000 (00:43 +0100)]
fix hash order dependency bug in Local-Maketext/t/09_compile.t
This would occasionally fail if it ended up encountering PERL5LIB in the environment hash
as the first value.
The test was actually broken anyway, as it would infinitie loop with a totally empty environment
Yves Orton [Wed, 21 Nov 2012 22:45:24 +0000 (23:45 +0100)]
Remove improper use of each() in B::walksymtable and fix ext/B/t/xref.t
Improper use of each() in walksymtable() makes behavior undefined.
As of the hash randomization patch ext/B/t/xref.t would occasionally
fail. A closer inspection revealed that the output that is parsed
in t/xref.t would vary greatly from run to run, with bizarre double
entries and sometimes missing packages, etc. So in 100 runs we would see
something like 25 of one variant, and then 25 of another, and then about
50 singletons. The notable difference between the two large groups is
that one was missing entire modules worth of output, the other appeared
to be correct. The singletons tended to differ from one of the other
two by a line or two.
Changing the each() to a keys() appears to fix this bug, making the
output consistent every time. My theory is that it is possible for the
symbol table logic to recurse and enter the same package twice, which
would result in its each iterator changing state but I have not verfied
this. In order to make sure that the traversal order is deterministic
I decided to use sort(keys()) (In other words the sort() is there to
guarantee a given output in the future, not to fix this bug).
Annoyingly many times the test would pass even though the output it was
parsing was grossly wrong. I think we need to figure out a better way to
test this module. We should probably check for the presence of various
packages, like the B package itsef, Errno.pm etc.
I cannot explain yet why this bug was sensitive to build options.
My normal build options seemed to not have any issue, wheras others did.
Apparently ok (with or without -Dusethreads):
git clean -dfX; ./Configure -Doptimize=-g -d -Dusedevel -Dusethreads
-Dprefix=~/bleadperl -Dcc=ccache\ gcc -Dld=gcc -DDEBUGGING
Regular fails:
git clean -dfx; ./Configure -des -Dusedevel -Dprefix=~/bleadperl
-Dcc=ccache\ gcc -Dld=gcc
My tests used the following one liners:
for file in test{1..100}; do ./perl -Ilib ext/B/t/xref.t > $file 2>&1; done;
md5sum test* | sort | uniq -c -w32 | sort -n
David Mitchell [Wed, 21 Nov 2012 17:01:38 +0000 (17:01 +0000)]
regmatch(): silence OpenWatcom compiler warnings
There are two MULTICALL variables which are assigned to in one branch,
but not the other. The values of these variables are never used.
OpenWatcom complains about this, and the easiest way to shut it up may be
to assign null values in the other branch. As bulk88 pointed out, these
assignments should be optimised away anyway.
Based on a patch originally submitted by Reini Urban, but without
removing the PERL_UNUSED_VAR's required for gcc.
See the thread <
50A2B8E5.5030401@gknw.net> for more info.
Father Chrysostomos [Wed, 21 Nov 2012 17:25:41 +0000 (09:25 -0800)]
sv.c: Remove aTHX from croak_no_modify call
This only applied to PERL_OLD_COPY_ON_WRITE. Commit
e3918bb703c
introduced this. That commit was written before croak_no_modify
lost its aTHX, but was not merged till after that. I missed this
when rebasing.
Father Chrysostomos [Wed, 21 Nov 2012 16:48:41 +0000 (08:48 -0800)]
Fix double free with stashes blessed into each other
When I added that extra pass in 5.16 that curses any remaining blessed
objects during global destruction, I caused this bug:
$ ./miniperl -e 'warn bless \%foo::, bar::; warn bless \%bar::, foo::'
bar=HASH(0x827260) at -e line 1.
foo=HASH(0x8272b0) at -e line 1.
Attempt to free unreferenced scalar: SV 0x8272b0, Perl interpreter: 0x800000 during global destruction.
By creating a circularity between stashes, with no RVs remaining, we
cause one of the two stashes, say foo, to be cursed during global
destruction. That causes it to lower the remaining reference count
on bar, which, when freed, lowers its reference count on foo, which
then tries to lower its reference count on bar, which has already
been freed.
The solution here is to turn off the object flag before decrementing
the stash’s reference count. So a recursive call won’t try to curse
the already accursed object.
Turning off the flag makes SvSTASH into a DESTROY cache. That won’t
work if the SvREFCNT_dec call tries to access that cache. So we have
to null the field before calling SvREFCNT_dec (which we should be
doing anyway).
Daniel Dragan [Tue, 20 Nov 2012 22:36:54 +0000 (17:36 -0500)]
refactor pp_stringify and pp_and
pp_stringify:
First, move all the SP/stack operations to before the first call in
pp_stringify (sv_copypv), this allows SP to never be saved across any calls.
SETTARG calls set magic, so that still has to be done. SETs does not ++/--
SP, so no need to do a PUTBACK. PL_op is read twice, once for TARG, once
for NORMAL. No point in caching it through the sv_copypv call since its not
worth saving a non-vol to C stack (x86) just to avoid 2 mem acesses. This
opcode now only has 2 vars saved across sv_copypv, my_perl and TARG.
pp_stringify dropped from 0x3F to 0x3C for me after these changes, 32 bit
x86 VC 2003.
pp_and:
Do the PERL_ASYNC_CHECK before anything else, calcing SP before
PERL_ASYNC_CHECK would mean saving it across the potential call. SvTRUE
macro checks its param for NULL. This SV * came off the Perl stack, it will
not be null since pp_and is not a core sub (see S_maybe_add_coresub) and
will not be called from pp_coreargs (pp_coreargs places (SV *)NULLs on
Perl stack). So create a SvTRUE_NN macro that does not check for NULL, this
saves a branch. Since the Perl stack is only touched twice, don't create
a local SP. See comment in code. This saves another variable to not be
saved across the sv_2bool_flags and removed PUTBACK instructions. PL_op is
only read once or twice (compiler choice) right before the 2 returns.
There is only 1 variable saved across any calls in pp_and now, and that is
my_perl. dSP also was not use to prevent an accidental use of a ++/-- SP
macro in pp_and in the future since there is no PUTBACK now. I guess for a
SPARC with register windowing and no direct memory instructions, accessing
PL_stack_sp twice will take more instructions 2 reads and a write to
PL_stack_sp vs 1 read and 1 write to PL_stack_sp with a dSP design. On
SPARC, with a register window, cross call regs have no cost per reg cost
aslong as you dont exceed their max number.
For me, pp_and went from 0x112 to 0xFF after this commit. Prior to dSP
removal, it was down to 0x109. SvTRUE_NN was named after SvREFCNT_inc_NN.
There remains an inefficiency in pp_and on non-GCC compilers due to
SvPVXtrue using PL_Xpv which will be dealt with in another commit.
Yves Orton [Wed, 21 Nov 2012 08:45:06 +0000 (09:45 +0100)]
fix a hash order dependency in cpan/List-Util tests
cpan/List-Util/t/tainted.t fails if the environment variable
it access is PERL5LIB as that is set inside the process.
We filter out env vars starting with PERL and bump the version
numbers to 1.25_01.
Father Chrysostomos [Wed, 21 Nov 2012 02:00:49 +0000 (18:00 -0800)]
perlhack: better word
At Aristotle’s suggestion
Father Chrysostomos [Tue, 20 Nov 2012 22:43:43 +0000 (14:43 -0800)]
Add assertions to S_curse in sv.c
If anything should go wrong with the order things are freed, we
could get crashes from this code. The assertions seem like a
good idea.
Father Chrysostomos [Tue, 20 Nov 2012 22:32:37 +0000 (14:32 -0800)]
scope.c: Remove XXX tmp comment from SAVEt_FREEOP
This assertion helped me to find and fix a crashing bug, so I don’t
want it to be removed.
Father Chrysostomos [Tue, 20 Nov 2012 21:47:27 +0000 (13:47 -0800)]
Revert "Revert "
8c34e50dc slowed down detruction with no DESTROY""
This reverts commit
95f9781bc2fad025553db0160ef9c2c5363312a1.
Now that the crash has been fixed by the preceding commit, we can
reinstate
7cc6787e9db.
Father Chrysostomos [Wed, 21 Nov 2012 01:52:13 +0000 (17:52 -0800)]
[perl #115830] Fix crash by not copying DESTROY cache
See commits
8c34e50dc and
7cc6787e9db (the latter was reverted by
95f9781bc).
If we are going to store a DESTROY cache in SvSTASH when !SvOBJECT, we
have to make sure not to copy that cache, otherwise other threads will
try to call a CV in the first thread, resulting in a crash.
8c34e50dc introduced this bug, but the crash didn’t start happening
until
7cc6787e9db, and only on Windows.
Father Chrysostomos [Tue, 20 Nov 2012 21:42:10 +0000 (13:42 -0800)]
sv.c: obsolete comment
This was resolved by the addition of S_curse and do_curse.
Father Chrysostomos [Tue, 20 Nov 2012 21:40:54 +0000 (13:40 -0800)]
Mention do_curse in alloc section of sv.c apidocs
Father Chrysostomos [Tue, 20 Nov 2012 20:28:57 +0000 (12:28 -0800)]
Fix panic/crash with sort { $not_num } and fatal warnings
I caused this in 5.15.4 in commit
1aa032b25ab:
$ ./miniperl -Ilib -e 'eval q|use warnings FATAL=>all=>; ()=sort{undef}1,2|'
panic: illegal pad in SAVEt_FREEOP: 0x803500[0x0] at -e line 1.
This panic only happens under debugging builds.
But it’s worse than that:
$ ./miniperl -Ilib -e 'eval { use warnings FATAL => all=>; ()=sort{undef}1,2}; my $x'
Bus error
It’s this piece of code in pp_sort.c that is the problem:
pad = PL_curpad; PL_curpad = 0;
if (PL_stack_sp != PL_stack_base + 1) {
assert(PL_stack_sp == PL_stack_base);
result = SvIV(&PL_sv_undef);
}
else result = SvIV(*PL_stack_sp);
PL_curpad = pad;
If SvIV dies, then PL_curpad will never be restored. That results in
a panic error when the string eval exits, under debugging builds, and
a crash for any subsequent pad ops, under any build.
So we need to use the savestack to protect PL_curpad. To avoid the
overhead most of the time, we should do this only if the result is not
already a number.
Sorting with a sub that has a ($$) prototype follows a different
code path that contains the same logic, but it is safe in that case,
because sort with a sub already localises the pad. I added tests for
it anyway.
Father Chrysostomos [Tue, 20 Nov 2012 17:56:15 +0000 (09:56 -0800)]
perldiag: Correct entry about sort sub and single values
Pure-Perl sort subroutines are always called in scalar context, so
it is not possible for them to return more or less than one item.
This entry implies that one would have to be careful about that
when writing a pure-Perl sort routine.
This only applies to XS sort routines, which *do* have to be
careful about that.