Karl Williamson [Mon, 3 Dec 2012 01:48:33 +0000 (18:48 -0700)]
utf8.c: Combine 2 function calls into one
There is a function that does both these together, more efficiently
Karl Williamson [Mon, 3 Dec 2012 01:47:23 +0000 (18:47 -0700)]
utf8.c: Move ARGS_ASSERT to earlier in function
to a place where people more expect to see it.
Karl Williamson [Mon, 3 Dec 2012 04:20:36 +0000 (21:20 -0700)]
embed.fnc: Add missing entry
This function is defined in utf8.c, but isn't called by the core, and
there was no entry for it in embed.fnc
Karl Williamson [Fri, 7 Dec 2012 05:42:18 +0000 (22:42 -0700)]
Silence some g++ compiler warnings
Changing these slightly got rid of the warnings like:
toke.c:9168: warning: format not a string literal and no format arguments
Karl Williamson [Sun, 9 Dec 2012 04:42:23 +0000 (21:42 -0700)]
intrpvar.h: Use #define instead of hard-coded number
The number 12 is mysterious as to why we are using it otherwise.
Father Chrysostomos [Sun, 9 Dec 2012 02:38:46 +0000 (18:38 -0800)]
Suppress deprec. warning from Devel::PPPort’s tests
This has already been submitted to
<https://rt.cpan.org/Ticket/Display.html?id=81796>.
Father Chrysostomos [Sat, 8 Dec 2012 14:45:18 +0000 (06:45 -0800)]
leakfinder.pl: Skip push/unshift after { or (
Father Chrysostomos [Sat, 8 Dec 2012 14:40:52 +0000 (06:40 -0800)]
leakfinder.pl: Fix select skip
It wasn’t skipping select without parentheses, which was the purpose
of that (?:...) group.
Father Chrysostomos [Sat, 8 Dec 2012 14:36:59 +0000 (06:36 -0800)]
Stop invalid charnames from leaking
The tests I added earlier were failing for a different reason than the
test names suggested.
Invalid charnames are not leaking because of the ‘too many errors’
that yyerror croakingly utters, but are leaking even when yyerror
doesn’t croak.
S_get_and_check_backslash_N_name just needs to free the returned SV
before returning if it is undefined.
Father Chrysostomos [Sat, 8 Dec 2012 13:49:13 +0000 (05:49 -0800)]
toke.c:S_new_constant: Use NN SvREFCNT_inc in 2 places
The sv argument passed to new_constant is never null. If the function
it calls is naughty enough to push a null on the stack, new_constant’s
callers will crash anyway. So we can assume res is not null.
This eliminates needless null checks.
Father Chrysostomos [Sat, 8 Dec 2012 13:44:44 +0000 (05:44 -0800)]
Stop Constant(%s) errors from leaking
This error message uses yyerror, so it doesn’t abort immediately, but
adds it to the queue of error messages.
If there are ten accumulated errors, however, yyerror croaks with a
‘too many errors’ message.
In that circumstance these messages were leaking scalars.
Instead of creating an SV especially to hold the message to pass to
yyerror and then freeing it afterwards, we can instead use Perl_form,
which reuses the same SV every time (PL_mess_sv), eliminating that
leak. In doing so, we can also combine this with another yyerror/
return in the vicinity, avoiding duplicate code.
The sv passed to S_new_constant was also leaking. When there is no
error, it is currently mortalised. When there is an error, it also
needs to be mortalised, in case it is a fatal error. So this commit
changes it to mortalise it unconditionally. This means we have to
SvREFCNT_inc the return value on error.
Father Chrysostomos [Fri, 7 Dec 2012 17:25:49 +0000 (09:25 -0800)]
Change Constant(undef) error to something meaningful
Look at these errors:
$ perl5.16.0 -e 'use overload; BEGIN{overload::constant q => sub{}; } "aaa"'
Constant(q): Call to &{$^H{q}} did not return a defined value at -e line 1, near "} "aaa""
Execution of -e aborted due to compilation errors.
$ perl5.16.0 -e 'BEGIN{++$_ for @INC{<charnames.pm _charnames.pm>}} "\N{a}"'
Constant(\N{a}) unknown at -e line 1, within string
Execution of -e aborted due to compilation errors.
$ perl5.16.0 -e 'use overload; BEGIN{overload::constant q => sub{}; } tr"aaa""'
Constant(tr): Call to &{$^H{q}} did not return a defined value at -e line 1, within string
Execution of -e aborted due to compilation errors.
The (q) and (tr) might seem a bit odd, but are not completely meaning-
less. They match the third argument passed to the overload handler.
Now look at this:
$ perl5.16.0 -e 'use overload; BEGIN{overload::constant integer => sub{}; } 123'
Constant(undef): Call to &{$^H{integer}} did not return a defined value at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
$ perl5.16.0 -e 'use overload; BEGIN{overload::constant float => sub{}; } 1.23'
Constant(undef): Call to &{$^H{float}} did not return a defined value at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
$ perl5.16.0 -e 'use overload; BEGIN{overload::constant binary => sub{}; } 0x123'
Constant(undef): Call to &{$^H{binary}} did not return a defined value at -e line 1, at end of line
Execution of -e aborted due to compilation errors.
That Constant(undef) is not helpful. This commit changes it to show
the number itself, making these cases similar to \N{}.
Father Chrysostomos [Fri, 7 Dec 2012 14:25:24 +0000 (06:25 -0800)]
Test ‘Constant(%s) unknown’ error
This only happens if someone accidentally (or intentionally :-) unde-
fines %^H or *^H or stops charnames from loading.
Father Chrysostomos [Fri, 7 Dec 2012 14:09:45 +0000 (06:09 -0800)]
Test error when constant overload handler returns undef
Father Chrysostomos [Fri, 7 Dec 2012 04:24:34 +0000 (20:24 -0800)]
perldiag: Make Constant(%s) messages match reality
We no longer have an ‘in regex’ variant (if we ever did).
The Constant(%s)%s: %s represents three specific warnings, one of
which doesn’t have the colon any more. It’s clearer if we list all
three, especially since the one about returning undef can acciden-
tally happen with ‘normal’ code (as opposed to code that fiddles with
%^H entries it shouldn’t be touching).
Father Chrysostomos [Thu, 6 Dec 2012 21:26:01 +0000 (13:26 -0800)]
perldiag: s/about where/whereabouts/
Every time I see that ‘about where’ I wonder why it sounds so funny.
It just dawned on me that we should just use the word ‘whereabouts’,
which fits perfectly in this context, and doesn’t sound as though it
needs a rewrite.
Father Chrysostomos [Thu, 6 Dec 2012 07:10:25 +0000 (23:10 -0800)]
toke.c: Make _charnames check more robust
Assuming that $^H{charnames} exists and contains a code ref can result
in crashes. See the tests in the diff.
It’s not a good idea to do $INC{"_charnames.pm"}++, but perl still
shouldn’t crash.
Father Chrysostomos [Thu, 6 Dec 2012 05:49:02 +0000 (21:49 -0800)]
MANIFEST typo
Father Chrysostomos [Thu, 6 Dec 2012 02:27:18 +0000 (18:27 -0800)]
Fewer strEQ calls in toke.c:S_new_constant
There is a small fixed number of keys that can be passed to this
static function:
charnames
binary
float
integer
q
qr
In a few places, we check whether the key is "charnames". It would
be quicker just to check the first character, since, if it is 'c', the
key must be "charnames". (Under debugging builds, assert that that
assumption is true.)
Tony Cook [Sun, 9 Dec 2012 02:29:25 +0000 (13:29 +1100)]
getline $/ = \N now reads N characters not bytes
This was discussed for 5.16 but was not included as it was too late
for inclusion.
Tony Cook [Sun, 9 Dec 2012 02:27:12 +0000 (13:27 +1100)]
remove the warning added for 5.16 and indicate the count is chars not bytes
Craig A. Berry [Fri, 16 Mar 2012 19:20:29 +0000 (14:20 -0500)]
Only handle PL_rs differently on VMS for record-oriented files.
For stream-oriented files, the effects of buffering and other
layers should be exactly as they are on other platforms. For true,
record-oriented files, though, setting $/ = \number must provide
exactly one low-level read per record. If a read were ever to
return less than a full record (due to, for example, filling up
the perlio buffer), a subsequent read would get the *next* record,
losing whatever data remained in the partially-read record.
Tony Cook [Sat, 17 Mar 2012 02:10:29 +0000 (13:10 +1100)]
no need to FIXME, it behaves like read() which is the intent
except read() doesn't complain about the invalid characters like
sv_gets().
Tony Cook [Sat, 17 Mar 2012 01:54:17 +0000 (12:54 +1100)]
fix another boundary case and hopefully improve performance
The fix: the if we found ourselves at a charstart with only one
character to read, readsize would be zero, handle that correctly.
Performance: originally I read just the first byte of the next
character, which meant as many extra read calls as there are
characters left to read after the initial read. So O(Nleft) reads
where Nleft is the number of characters left to read after the initial
read.
Now read as many bytes as there are characters left to read, which
should mean the number of reads comes down to O(log(Nleft**2)) I think
(but don't ask me to justify that.)
Tony Cook [Fri, 16 Mar 2012 14:10:36 +0000 (01:10 +1100)]
fix a fencepost error I found trying to fall asleep
Tony Cook [Fri, 7 Dec 2012 23:23:20 +0000 (10:23 +1100)]
Incomplete implementation of $/ = \number acting like read()
It's under tested, and incomplete
- readline appears to ignore IN_BYTES, so this code continues to do so.
- currently :utf8 will return invalid utf8, which means this can too,
if we can be sure of :utf8 returning only valud utf-8 the FIXME can
be ignored
- VMS is the elephant in the room - the conditional means that the new
code is completely ignored for reading from files. If we can detect
record-oriented files in some way this could change.
Tony Cook [Fri, 7 Dec 2012 23:19:42 +0000 (10:19 +1100)]
die, evil [IU]32
It's still not as dead as I'd like.
James E Keenan [Sat, 8 Dec 2012 14:28:21 +0000 (09:28 -0500)]
Merge branch 'blead' of jkeenan@perl5.git.perl.org:/perl into blead
James E Keenan [Sat, 8 Dec 2012 14:24:31 +0000 (09:24 -0500)]
Add t/opbasic to list of test directories in one location.
For RT #115838; bulk88++.
Chris 'BinGOs' Williams [Sat, 8 Dec 2012 10:05:12 +0000 (10:05 +0000)]
Update Unicode-Collate to CPAN version 0.95
[DELTA]
0.95 Sat Dec 8 15:11:09 2012
- U::C::Locale newly supports locales: bs_Cyrl, ee.
- updated to CLDR 21: uk.
- updated to CLDR 22: th, to.
- added loc_bscy.t, loc_ee.t in t.
- modified tests: loc_th.t, loc_to.t, loc_uk.t in t.
James E Keenan [Sun, 2 Dec 2012 14:07:40 +0000 (09:07 -0500)]
Have each test print out its description.
Accomplished by modifying the hard-coded 'print ok'-type statements. (These
tests were written in too idiosyncratic a manner to make conversion to
t/test.pl simple.
Correct order of files in MANIFEST.
See: RT #115838
James E Keenan [Sun, 2 Dec 2012 13:45:43 +0000 (08:45 -0500)]
Add or amplify inline comments as to placement of file in t/opbasic.
For RT #115838
James E Keenan [Sun, 2 Dec 2012 13:25:42 +0000 (08:25 -0500)]
Adjust MANIFEST, Makefiles, test harnesses, documentation, etc., aware of new
directory t/opbasic.
For RT #115838
James E Keenan [Sun, 2 Dec 2012 13:11:13 +0000 (08:11 -0500)]
Create subdirectory t/opbasic. Move 5 test files there.
t/opbasic will hold files formerly held in t/op but which, unlike the vast
majority of tests in the latter directory, are ineligible to use t/test.pl as
a source of test functions. Affected files:
arith.t
cmp.t
concat.t
magic_phase.t
qq.t
This commit does nothing more than create the new subdirectory and move the
files into it.
For: RT #115838
Tony Cook [Fri, 7 Dec 2012 23:40:26 +0000 (10:40 +1100)]
fix dtrace (as emulated with systemtap) builds on linux
the stap branch of the #if was passing four arguments to
OP_ENTRY_PROBE, much hilarity ensued.
Since literal strings are never passed as the name parameter we can move
OP_ENTRY_PROBE out of the conditional and avoid duplication.
David Mitchell [Thu, 6 Dec 2012 16:42:20 +0000 (16:42 +0000)]
scope.c: silence some compiler warnings
clang didn't like %ld on I32's.
Yves Orton [Thu, 6 Dec 2012 10:11:47 +0000 (11:11 +0100)]
make regcharclass generate submacros if necessary to keep them short
Some compilers can't handle unexpanded macros longer than something
like 8000 characters. So we split up long ones into sub macros to work
around the problem
Daniel Dragan [Thu, 6 Dec 2012 04:39:44 +0000 (23:39 -0500)]
add PERL_NO_GET_CONTEXT to xs template in h2xs.PL
An XS module not using PERL_NO_GET_CONTEXT is extremely inefficient under
threaded Perls. Prevent PERL_NO_GET_CONTEXT-less modules in the future
by making it a default. Many XS modules are created with h2xs.
Also see this anonymous complaint http://perlmonks.org/?node_id=990732 .
Father Chrysostomos [Wed, 5 Dec 2012 20:53:30 +0000 (12:53 -0800)]
Stop renamed packages from making reset() crash
This only affected threaded builds. I think the comments in the added
test explain well enough what was happening.
The solution is to store a stashpad offset in the pmop, instead of the
name of the stash. This is similar to what was done with cop stashes
in
d4d03940c58a.
Not only does this fix the crash, but it also makes compilation faster
and saves memory (no separate malloc for every m?pat?).
I had to move Safefree(PL_stashpad) later on in perl_destruct, because
freeing a pmop causes the PL_stashpad to be accessed, and pmops can be
freed during sv_clean_all. Its previous location was not a problem
for cops, as PL_stashpad[cop->cop_stashoff] is only accessed when
PL_curcop==that_cop and Perl code is running, not when cops are freed.
Father Chrysostomos [Tue, 4 Dec 2012 22:52:45 +0000 (14:52 -0800)]
Don’t use PMf_ONCE flag for split-to-array
Currently the PMf_ONCE flag has two purposes. It is used to indicate
that m?? must match only once. That’s what distinguishes m?? and m//
internally. The other use indicates that @x = split... modifies the
array in place.
Whenever the split op is modified to point straight to the array, the
PMf_ONCE flag is set. pp_split checks both whether there is an array
attached to the op (via a GV in the pad under threads, or a pointer
from the op to the GV under non-threaded builds) and whether the
flag is set.
This makes the flag redundant in the split case.
Removing its use here not only simplifies the code and removes redun-
dant bit-fiddling, but also makes this comment in toke.c, added by
ad639bfb6, come true:
/* This is the only point in the code that sets PMf_ONCE: */
(That was actually harmless, as it doesn’t hurt to have a stash refer-
ring to pmops that don’t use the PMf_USED flag, and the PMf_ONCE flag
is set for split way after that code is run. It is also unnecessary
for split, as that bookkeeping code in toke.c only applies to the m??
use of PMf_ONCE.)
This commit also removes a gimme != G_ARRAY check that thas been
redundant since
a6d8037e26a.
Father Chrysostomos [Fri, 30 Nov 2012 17:54:08 +0000 (09:54 -0800)]
perldiag: -D message is a warning
Under non-debugging builds, I get this:
$ perl -D -e 'print "ok\n"'
Recompile perl with -DDEBUGGING to use -D switch (did you mean -d ?)
ok
It is a default warning (S), not a fatal error (F).
Father Chrysostomos [Fri, 30 Nov 2012 17:50:01 +0000 (09:50 -0800)]
perldiag: Remove category from ‘POSIX syntax [. .]...’
Warnings categories apply only to warnings.
Father Chrysostomos [Thu, 29 Nov 2012 06:42:57 +0000 (22:42 -0800)]
pp_goto: Call get-magic before choosing goto type
Deciding whether this is goto-label or goto-sub can only correctly
happen after get-magic has been invoked, as get-magic can cause the
argument to begin or cease to be a subroutine reference.
Sébastien Aperghis-Tramoni [Thu, 6 Dec 2012 00:04:25 +0000 (17:04 -0700)]
dist/constant/t/utf8.t: Skip tests for early Perls
Karl Williamson [Thu, 6 Dec 2012 00:02:23 +0000 (17:02 -0700)]
AUTHORS: Change email for Sébastien Aperghis-Tramoni
Father Chrysostomos [Wed, 5 Dec 2012 17:35:36 +0000 (09:35 -0800)]
regen pod issue
I don’t see how I could have made the number of potential errors
go down, but that’s what podcheck.t insists on saying, even after
I re-ren autodoc.pl to make sure.
Father Chrysostomos [Wed, 5 Dec 2012 14:09:42 +0000 (06:09 -0800)]
sv.c: Correct newSVpvn_share docs
something I overlooked
Father Chrysostomos [Wed, 5 Dec 2012 14:07:51 +0000 (06:07 -0800)]
sv.h: Warning about cows in SvPV_set apidocs
Father Chrysostomos [Wed, 5 Dec 2012 07:13:56 +0000 (23:13 -0800)]
Stop "\N{...}" from leaking after errors
After a syntax error, S_new_constant in toke.c was not mortalising as
promised.
In this case, it doesn’t need to mortalise the variable. It can sim-
ply free it.
Father Chrysostomos [Wed, 5 Dec 2012 06:09:29 +0000 (22:09 -0800)]
Use SvREFCNT_dec_NN in various cop.h macros
Many of these SVs are never null, and therefore need no null checks.
Father Chrysostomos [Wed, 5 Dec 2012 06:05:09 +0000 (22:05 -0800)]
Stop v111111111111111 from leaking under fatal warnings
Actually, you need more digits than that to get a leak.
This commit arranges for the SV passed to scan_vstring to be freed
in case scan_vstring triggers an integer overflow warning when fatal
warnings are enabled.
Father Chrysostomos [Wed, 5 Dec 2012 05:59:07 +0000 (21:59 -0800)]
toke.c apidocs: Note that scan_vstring might croak
Chris 'BinGOs' Williams [Wed, 5 Dec 2012 16:27:15 +0000 (16:27 +0000)]
Synchronise CPAN Locale-Maketest and core version
Chris 'BinGOs' Williams [Wed, 5 Dec 2012 16:25:26 +0000 (16:25 +0000)]
Update CPANPLUS-Dist-Build to CPAN version 0.68
[DELTA]
0.68 Wed Dec 5 00:17:04 GMT 2012
- Revert change to wrapper command-line
0.66 Tue Dec 4 23:05:53 GMT 2012
- Resolve an issue where Build.PL doesn't generate a
Build script
Daniel Dragan [Sat, 10 Nov 2012 02:58:22 +0000 (21:58 -0500)]
more dTHX optimizations in /win32/*
In some places, where there is a higher risk of a NULL my_perl happening
at an unknown point in the future IMO new scopes were created. In other
places dTHXa(NULL) and aTHXa were used to avoid large whitespace changes.
win32_rename and win32_getenv I determined would have no benefit from
changing them. More context passing was added to static funcs called by
win32_kill and win32_waitpid removing the need to move the dTHXs in the
2 funcs.
Yves Orton [Tue, 4 Dec 2012 14:22:28 +0000 (15:22 +0100)]
Switch default hash to SIPHASH on 64 bit builds and ONE_AT_A_TIME on 32 bit builds
Murmurhash has certain disadvantages that neither ONE_AT_A_TIME nor SIPHASH posses
Father Chrysostomos [Tue, 4 Dec 2012 22:40:26 +0000 (14:40 -0800)]
override.t: Suppress deprecation warning
If we have overridden CORE::GLOBAL::require for the sake of testing it,
we can’t do ‘no warnings’ obviously.
Father Chrysostomos [Tue, 4 Dec 2012 19:22:59 +0000 (11:22 -0800)]
Stop /[a-\d]/ from leaking under fatal warnings
This commit arranges for the regexp and one temporary sv in S_regclass
to be freed in case the ‘False [] range’ warning proves fatal.
Father Chrysostomos [Tue, 4 Dec 2012 19:18:36 +0000 (11:18 -0800)]
Stop /[:foo:]/ from leaking under fatal warnings
This commit arranges for the regexp and one temporary sv in S_regclass
to be freed in case the ‘POSIX syntax [: :] belongs inside character
classes’ warning proves fatal.
Father Chrysostomos [Tue, 4 Dec 2012 19:04:24 +0000 (11:04 -0800)]
[perl #115818] Don’t croak for /[.zog.]/
/[.zog.]/ produces a warning, because the POSIX syntax is not used
correctly. It must be /[[.zog.]]/.
/[[.zog.]]/ croaks, because that POSIX syntax has not been imple-
mented yet.
There is currently a croak for the former, too, even though it is
the latter syntax that is forbidden. There is no reason to forbid
the former.
The reason for warning is that /[.zog.]/ is a regular character
class (equivalent to [.zog]), so it might not do what the programmer
intended. If that is why we warn, it doesn’t make sense to croak.
After all, perl is only guessing that the programmer *might* have made
a mistake.
This makes /[.foo.]/ similar to /[:foo:]/, which warns and then acts
like /[:fo]/.
Sullivan Beck [Tue, 4 Dec 2012 21:32:45 +0000 (21:32 +0000)]
Update Locale-Codes to CPAN version 3.24
Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
Steffen Mueller [Sat, 1 Dec 2012 04:03:09 +0000 (23:03 -0500)]
add a note about security concerns in Storable
Storable is not a great way to pass data back and forth across security
boundaries. We have discussed the security implications of the
auto-loading and auto-blessing behaviors in Storable in the past, both
on the perl5-porters mailing list and at various conferences. Somehow,
though, these "well-known" probably have never actually been put into
the documentation. This patch corrects that.
The original version of this patch included a recommendation to use
Sereal in its most stringent configuration, but that text was removed
for the time being by Ricardo Signes, who hopes to add it back once
Sereal has been in public use for just a bit longer.
Brian Carlson [Wed, 28 Nov 2012 13:54:33 +0000 (08:54 -0500)]
Fix misparsing of maketext strings.
Case 61251: This commit fixes a misparse of maketext strings that could
lead to arbitrary code execution. Basically, maketext was compiling
bracket notation into functions, but neglected to escape backslashes
inside the content or die on fully-qualified method names when
generating the code. This change escapes all such backslashes and dies
when a method name with a colon or apostrophe is specified.
Father Chrysostomos [Tue, 4 Dec 2012 18:48:36 +0000 (10:48 -0800)]
embed.fnc: Explain how X is used for public macros
I don’t know whether my message to the list
(<
20121204012335.29409.qmail@lists-nntp.develooper.com>) was noticed.
In any case, here it is for posterity. Hopefully this will save
others from finding this out the hard way as I had to (making mistakes
and having others come and correct them).
Father Chrysostomos [Tue, 4 Dec 2012 18:44:08 +0000 (10:44 -0800)]
Mention in more places that my $_ is deprecated
Father Chrysostomos [Tue, 4 Dec 2012 17:53:55 +0000 (09:53 -0800)]
Deprecate lexical $_
See tickets #114020 and #75598 for why.
The changes to tests in cpan/Text-Tabs have been submitted upstream
at rt.cpan.org #81698.
Father Chrysostomos [Tue, 4 Dec 2012 15:04:48 +0000 (07:04 -0800)]
encoding.t: Skip 2 tests under debugging
Father Chrysostomos [Tue, 4 Dec 2012 14:57:58 +0000 (06:57 -0800)]
Increase $sigtrap::VERSION to 1.07
Father Chrysostomos [Tue, 4 Dec 2012 14:57:02 +0000 (06:57 -0800)]
sigtrap.pm: Avoid lexical $_
my $_ is about to be deprecated.
It has been using it since commit
972fc2eb7a to avoid modifying a
read-only argument. Using @{[...]} instead works, too.
David Mitchell [Tue, 4 Dec 2012 15:30:37 +0000 (15:30 +0000)]
silence some non-clang warnings
ccde85316a0db149f30359ebfdf031ef602b0344 added some
#pragma clang ...
lines to shut up clang.
This caused gcc to give voluminous 'unknown pragma "clang"' output.
Sigh.
Hopefully now fixed, although it all seems very cumbersome.
David Mitchell [Tue, 4 Dec 2012 13:22:41 +0000 (13:22 +0000)]
silence some clang warnings
principally, proto.h was sometimes being included twice - once before
a fn decl, and once after - giving rise to a 'decl after def' warning.
Also, S_croak_memory_wrap was declared static in every source file, but
not used in some. So selectively disable the unused-function warning.
Craig A. Berry [Tue, 4 Dec 2012 13:23:57 +0000 (07:23 -0600)]
Avoid some doubled escapes in tovmsspec.
Since it's impossible to guarantee a filename is never makes
multiple trips through the Unix-to-VMS converter, it's important
not to escape characters that have already been escaped.
David Mitchell [Tue, 4 Dec 2012 11:32:39 +0000 (11:32 +0000)]
add SvREFCNT_dec_NN()
Like SvREFCNT_dec(), but skips the not null check, making code potentially
smaller and faster.
Also as proof of concept, updates the SvREFCNT_dec's in scope.c where
it's obvious the value can't be NULL. There are still 500+ uses in the
perl core that need evaluating!
David Mitchell [Sun, 2 Dec 2012 12:59:37 +0000 (12:59 +0000)]
make SvREFCNT_dec() more efficient
Historically, SvREFCNT_dec was just
#define SvREFCNT_dec(sv) sv_free((SV*)(sv))
then in 5.10.0, for GCC, the macro was partially inlined, avoiding a
function call for the refcnt > 1 case. Recently, the macro was turned into
an inline function, providing the function-call avoidance to other
platforms too. However, the macro/inline-function is quite big, and
appears over 500 times in the core source. Its action is logically
equivalent to:
if (sv) {
if (SvREFCNT(sv) > 1)
SvREFCNT(sv)--;
else if (SvREFCNT == 1) {
// normal case
SvREFCNT(sv)--;
sv_free2(sv);
}
else {
// exceptional case
sv_free(sv);
}
}
Where sv_free2() handles the "normal" quick cases, while sv_free()
handles the odd cases (e,g. a ref count already at 0 during global
destruction).
This means we have to plant code that potentially calls two different
subs, over 500 times.
This commit changes SvREFCNT_dec and sv_free2() to look like:
PERL_STATIC_INLINE void
S_SvREFCNT_dec(pTHX_ SV *sv)
{
if (sv) {
U32 rc = SvREFCNT(sv);
if (rc > 1)
SvREFCNT(sv) = rc - 1;
else
Perl_sv_free2(aTHX_ sv, rc);
}
}
Perl_sv_free2(pTHX_ SV *const sv, const U32 rc)
{
if (rc == 1) {
SvREFCNT(sv) = 0;
... do sv_clear, del_SV etc ...
return
}
/* handle exceptional rc == 0 */
...
}
So for the normal cases (rc > 1, rc == 1) there is the same amount of
testing and function calls, but the second test has been moved inside
the sv_free2() function.
This makes the perl executable about 10-15K smaller, and apparently a bit
faster (modulo the fact that most benchmarks are just measuring noise).
The refcount is passed as a second arg to sv_free2(), as on platforms
that pass the first few args in registers, it saves reading sv->sv_refcnt
again.
David Mitchell [Thu, 29 Nov 2012 11:37:08 +0000 (11:37 +0000)]
Optimise magic handling in save* and leave_scope
There are several places that have code similar to
if (SvMAGICAL(sv)) {
PL_localizing = 2;
SvSETMAGIC(sv)
PL_localizing = 0;
}
The condition is sub-optimal (it should only test for set magic), and the
SvSETMAGIC repeats a similar test.
Other places didn't have the outer condition, so they set PL_localizing
twice even when not needed.
David Mitchell [Sun, 25 Nov 2012 23:08:11 +0000 (23:08 +0000)]
refactor Perl_leave_scope
This is a large and hot function. The main problem with it is that
there is code to pop a few args repeated in just about every branch.
Also, there are a whole bunch of local vars (sv, av, hv, gv etc)
that are never all used simultaneously, but are really just there for
casting convenience. Together, they defeat the compiler's register
allocation algorithms (well, they did for gcc anyway).
We fix this by just declaring three general vars, arg0,1,2 of type ANY, and
move the popping code to above the switch(). We sort the SAVEt_*
indices in order of number of args, so it's quick to determine how many
args we need to pop for a particular type.
Together with the previous commits which added the SS_ADD_* macros, this
reduces the size of scope.o (-O2, gcc x86_64) by about 9% (threaded)
or 17% (unthreaded), and seems to speed up simple loops / function calls
by around 5%.
David Mitchell [Sun, 25 Nov 2012 16:36:43 +0000 (16:36 +0000)]
save_int/i32 inline the long version
Both these functions were structured as
if (int will fit in type)
SS_ADD(...);
else
save_pushi32ptr(...)
Inline the call of the "long" version of the save. With refactoring, the
machine code (x86_64, gcc -O2) is no larger than before, and saves time
on the long version.
David Mitchell [Sun, 25 Nov 2012 15:22:19 +0000 (15:22 +0000)]
Add SS_ADD_* macros and replace most SSPUSH* uses
The current idiom for adding an entry to the savestack is
SSCHECK(3);
SSPUSHINT(...);
SSPUSHPTR(...);
SSPUSHUV(SAVEt_...);
Replace this with a new idiom:
{
dSS_ADD;
SS_ADD_INT(...);
SS_ADD_PTR(...);
SS_ADD_UV(SAVEt_...);
SS_ADD_END(3);
}
This is designed to be more efficient.
First, it defines some local vars, and defers updating PL_savestack_ix
to the end.
Second, it performs the 'is there space on the stack' check *after*
pushing. Doing the check last means that values in registers will have
been pushed and no longer needed, so don't need saving around the call to
grow. Also, tail-call elimination of the grow() can be done. These changes
reduce the code of something like save_pushptrptr() to half its former
size.
Of course, doing the size check *after* pushing means we must always
ensure there are SS_MAXPUSH free slots on the savestack */
Father Chrysostomos [Tue, 4 Dec 2012 01:27:22 +0000 (17:27 -0800)]
Lower version.pm version
Commit
4a7557453 increased the version when modifying a test, but
without updating other tests that check the version number.
Since modifying a test does not affect what gets installed, it was
not actually necessary to change the version number.
Yves Orton [Mon, 3 Dec 2012 23:00:28 +0000 (00:00 +0100)]
Fix per-hash hash order dependency bug in version.pm
If we make each hash have its own keyorder then this test will fail
pretty regularly. Fixing it to get sorted keys from Dumper for the
relevent test prevents this failure.
Joel Berger [Sat, 1 Dec 2012 16:15:36 +0000 (10:15 -0600)]
Cwd::fast_abs_path's untaint should allow for multiline directories
This bug was noticed via https://github.com/dagolden/file-chdir/issues/3 and testing has led to this being the cause.
The problem is worse on some platforms (notably cygwin in this case) when abs_path is implemented by fast_abs_path.
Since File::chdir tests for proper behavior when a directory contains a newline, this bug then breaks File::chdir (one of my favorites and very useful xplatform tool).
Yes this should have tests, but since it will involve creating a directory with a newline, I thought I would do better to leave that to someone with better knowledge than I.
Father Chrysostomos [Mon, 3 Dec 2012 02:53:23 +0000 (18:53 -0800)]
[perl #115962] cwd.t: Add test for fast_abs_path in LF dir
Father Chrysostomos [Mon, 3 Dec 2012 01:46:24 +0000 (17:46 -0800)]
Stop /[\i]/ from leaking under fatal warnings
This commit arranges for the regexp and one temporary sv in S_regclass
to be freed in case the ‘Unrecognized escape \x in character class’
warning proves fatal.
Father Chrysostomos [Mon, 3 Dec 2012 01:40:36 +0000 (17:40 -0800)]
Stop /(?{})+/ from leaking under fatal warnings
This commit arranges for the regexp to be freed in case the ‘blah blah
blah matches null string many times in regex’ warning proves fatal.
Father Chrysostomos [Mon, 3 Dec 2012 01:34:44 +0000 (17:34 -0800)]
Make PL_sawampersand checks conditional on PERL_SAWAMPERSAND
This does not actually make any difference, since PL_sawampersand is
a constant when PERL_SAWAMPERSAND is undefined. It just makes the
code clearer.
Father Chrysostomos [Mon, 3 Dec 2012 01:27:41 +0000 (17:27 -0800)]
Stop /(?{})?/ from leaking under fatal warnings
Fatal errors in regexp compilation do SAVEFREESV before croaking, to
make sure the regexp is freed.
Warnings that happen after the sizing pass need to be protected the
same way, in case they are fatal.
This commit arranges for the regexp to be freed in case the ‘Quanti-
fier unexpected on zero-length expression’ warning proves fatal.
/(?{})?/ also triggers some others leaks. Before re_op_compile calls
S_study_chunk, it allocates three scalars for study_chunk’s use. Some
of those are freed after the call to study_chunk, while others become
part of the regexp.
I surrounded the allocation and freeing with an ENTER/LEAVE pair,
using SAVEFREESV to free them when there is a croak. So those cases
SvREFCNT_dec was used, it is simply omitted. Those cases where it was
omitted now have SvREFCNT_inc.
One more complication was that sometimes there is a goto between the
ENTER and the LEAVE which restarts the surrounding code. It already=
took those scalars into account, freeing them. But to balance ENTER/
LEAVE pairs properly I had to do a LEAVE just before the goto, and
remove the freeing of the SVs after the goto.
The new name of the macro that uses goto was inspired by
Acme::ButFirst.
Father Chrysostomos [Sat, 1 Dec 2012 04:20:19 +0000 (20:20 -0800)]
Remove use of SAVEDESTRUCTOR_X(clear_re...) from regcomp.c
The purpose of this is to free the regexp when croaking.
SAVEDESTRUCTOR_X calls clear_re on scope exit. clear_re does
ReREFCNT_dec.
It used to be necessary to do it this way before regular expres-
sions were SVs.
Since v5.10.0-145-g84679df, regexps have been SVs, and ReREFCNT_dec is
effectively an alias for SvREFCNT_dec.
There will be one less function call on scope exit when regexp compi-
lation croaks if we use SAVEFREESV instead of SAVEDESTRUCTOR_X.
Yves Orton [Mon, 3 Dec 2012 10:49:00 +0000 (11:49 +0100)]
Make it possible to simulate old style one-at-a-time hashing
With a 0 seed and ONE_AT_A_TIME_OLD hashing enabled one can simulate
older perls (with the exception there is no rehashing at play).
This includes a modest tweak to reduce ops per character by comparing
the string pointer to the end of the string, instead of maintaining
a position counter.
Craig A. Berry [Sun, 2 Dec 2012 21:17:55 +0000 (15:17 -0600)]
Better escaping of dots in tovmsspec.
When converting a filename with multiple dots to native VMS syntax,
it's necessary to escape all but the last dot with a caret ('^').
We've been doing this for some time, but have been doing it blindly
such that multiple trips through the converter resulted in a
stuttering caret problem (e.g., foo^^^.bar.pl when foo^.bar.pl was
intended).
So create a convenience macro that does the escaping and make it
only escape unescaped instances and also make it check that the
escape doesn't push us off the end of the buffer we are working
on.
Use the new macro in the three most obvious places that it's
applicable. There may be other places that also should use it.
Craig A. Berry [Sat, 1 Dec 2012 03:47:03 +0000 (21:47 -0600)]
Remove a spurious strlen in VMS's readdir().
After setting the null byte, we turned around and pretended we
didn't know where it was and went hunting for it. Hmm.
Craig A. Berry [Sat, 1 Dec 2012 03:20:47 +0000 (21:20 -0600)]
Fix memory leak in VMS's readdir().
When we got to the end of a directory we were not freeing the
buffer we'd been using. So refactor that section of code to have
only one return. Bug introduced in
657054d4f860463a01c5.
Father Chrysostomos [Sat, 1 Dec 2012 02:01:40 +0000 (18:01 -0800)]
Increase $sort::VERSION to 2.02
Martin Becker [Fri, 30 Nov 2012 17:07:43 +0000 (18:07 +0100)]
fixed typos in sample code in sort.pm documentation
Father Chrysostomos [Fri, 30 Nov 2012 17:50:35 +0000 (09:50 -0800)]
Stop format closure fatal warnings from leaking
Father Chrysostomos [Fri, 30 Nov 2012 17:27:27 +0000 (09:27 -0800)]
svleak.t: Correct test name
I got slightly confused when I added that. I had tested both page
overflow and closure warnings (only the latter leaked), and I got
them mixed up when I wrote the test name.
Father Chrysostomos [Fri, 30 Nov 2012 06:49:09 +0000 (22:49 -0800)]
Stop duplicate lex vars from leaking under fatal warnings
Father Chrysostomos [Thu, 29 Nov 2012 21:07:02 +0000 (13:07 -0800)]
Stop newCONSTSUB from leaking the constant under fatal warnings
James E Keenan [Fri, 30 Nov 2012 02:30:47 +0000 (21:30 -0500)]
Merge branch 'blead' of jkeenan@perl5.git.perl.org:/perl into blead
James E Keenan [Fri, 23 Nov 2012 19:20:56 +0000 (14:20 -0500)]
Add descriptions to tests in t/op/arith.t.
For: RT #115806
James E Keenan [Fri, 30 Nov 2012 02:25:07 +0000 (21:25 -0500)]
t/win32/runenv.t: Correct syntax error reported by bulk88++.
Part of: RT #115788