platform/upstream/perl.git
11 years agoperldiag: typo
Father Chrysostomos [Mon, 19 Nov 2012 20:32:02 +0000 (12:32 -0800)]
perldiag: typo

11 years agoembed.fnc: Fix flags problem for regposixcc
Karl Williamson [Tue, 20 Nov 2012 00:39:58 +0000 (17:39 -0700)]
embed.fnc: Fix flags problem for regposixcc

The static and inline flags are considered mutually exclusive.  This is
not a fatal embed error as something can't be inline unless it is also
static, but the warning is there because the entry looks suspicious.
Commit 2fd63cc5b615213574e0153ed2bf14d9df23c073 introduced the flags
that caused the warning

11 years agoregen/embed.pl: Fix uninit variable warning.
Karl Williamson [Tue, 20 Nov 2012 00:38:18 +0000 (17:38 -0700)]
regen/embed.pl: Fix uninit variable warning.

11 years agoMerge topic branch into blead
Karl Williamson [Tue, 20 Nov 2012 00:13:41 +0000 (17:13 -0700)]
Merge topic branch into blead

This branch continues to make more systematic the handy.h definitions of
isFOO() macros started in 53335a31ed2284e8aaf1b6bf1cdcc0c0357841d0,
fixing some bugs and some incidentals found along the way.

Four of these macros are changed to not use function calls for
characters outside the Latin1 range.  Three of these used interpreter
level variables.  All core uses of these three interpreter variables
are removed in this series of commits, so the variables could be removed
without affecting the core.

11 years agoRefactor is(SPACE|PSXSP)_(uni|utf8) macros and utf8.c
Karl Williamson [Mon, 19 Nov 2012 21:36:12 +0000 (14:36 -0700)]
Refactor is(SPACE|PSXSP)_(uni|utf8) macros and utf8.c

This refactors the isSPACE_uni, is_SPACE_utf8, isPSXSPC_uni,
and is_PSXSPC_utf8 macros in handy.h, so that no function call need be
done to handle above Latin1 input.  These macros are quite small, and
unlikely to grow over time, as Unicode has mostly finished adding white
space equivalents to the Standard.  The functions that implement these
in utf8.c are also changed to use the macros instead of generating a
swash.  This should speed things up slightly, with less memory used over
time as the swash fills.

11 years agoregexec.c: Use SPACE macros instead of swash
Karl Williamson [Mon, 19 Nov 2012 21:24:29 +0000 (14:24 -0700)]
regexec.c: Use SPACE macros instead of swash

This will avoid loading a swash when an above Latin1 code point is
tested to see if it matches \s.  The SPACE macro is quite small, and
unlikely to grow over time, as Unicode has mostly finished adding white
space equivalents to the Standard.

The CCC_TRY_U macro in regexec.c could not be used for this, and I just
expanded out what it would generate, modified to use the macro instead
of a swash.

11 years agoRefactor is_XDIGIT_uni(), is_XDIGIT_utf8() and macros
Karl Williamson [Mon, 19 Nov 2012 20:55:13 +0000 (13:55 -0700)]
Refactor is_XDIGIT_uni(), is_XDIGIT_utf8() and macros

This adds macros to regen/regcharclass.pl that are usable as part of the
is_XDIGIT_foo() macros in handy.h, so that no function call need be done
to handle above Latin1 input.  These macros are quite small, and
unlikely to grow over time.  The functions that implement these in
utf8.c are also changed to use the macros instead of generating a swash.
This should speed things up slightly, with less memory used over time as
the swash fills.

11 years agoRefactor is_BLANK_uni() and is_BLANK_utf8() macros
Karl Williamson [Mon, 19 Nov 2012 20:36:56 +0000 (13:36 -0700)]
Refactor is_BLANK_uni() and is_BLANK_utf8() macros

This adds macros to regen/regcharclass.pl that are usable as part of the
is_BLANK_foo() macros in handy.h, so that no function call need be done
to handle above Latin1 input.  These macros are quite small, and
unlikely to grow over time, as Unicode has mostly finished adding white
space equivalents to the Standard.  The functions that implement these
in utf8.c are also changed to use the macros instead of generating a
swash.  This should speed things up slightly, with less memory used over
time as the swash fills.

11 years agohandy.h: Add isVERTWS_uni(), isVERTWS_utf8()
Karl Williamson [Mon, 19 Nov 2012 20:14:24 +0000 (13:14 -0700)]
handy.h: Add isVERTWS_uni(), isVERTWS_utf8()

These two macros match the same things as \v does in patterns.  I'm
leaving them undocumented for now.

11 years agoRefactor is_CNTRL_utf8(), is_utf8_cntrl()
Karl Williamson [Mon, 19 Nov 2012 20:00:47 +0000 (13:00 -0700)]
Refactor is_CNTRL_utf8(), is_utf8_cntrl()

All controls will always be in the Latin1 range by Unicode's stability
policy.  This means that we don't have to call is_utf8_cntrl() when the
input to the is_CNTRL_utf8() macro is above Latin1; we can just fail.
And that means that Perl_is_utf8_cntrl() can just use the macro.

11 years agohandy.h: Refactor macros to avoid aTHX_ problems
Karl Williamson [Mon, 19 Nov 2012 19:08:26 +0000 (12:08 -0700)]
handy.h: Refactor macros to avoid aTHX_ problems

This refactors these macros so that other macros automatically add aTHX_
if necessary.

11 years agoembed.fnc: Make a function global
Karl Williamson [Mon, 19 Nov 2012 18:05:43 +0000 (11:05 -0700)]
embed.fnc: Make a function global

This function is supposed to only be called internally, but it is called
by a macro that has global scope, so it also has to be global.

11 years agoregexec.c: Add PERL_UNIUSED_VAR()
Karl Williamson [Mon, 19 Nov 2012 17:59:38 +0000 (10:59 -0700)]
regexec.c: Add PERL_UNIUSED_VAR()

This is an attempt to silence warnings on some compilers.

11 years agoXS-APItest/t/handy.t: Refactor
Karl Williamson [Mon, 19 Nov 2012 16:58:12 +0000 (09:58 -0700)]
XS-APItest/t/handy.t: Refactor

This takes advantage of the Unicode::UCD::prop_invlist() function,
introduced in 5.16, to replace the hard-coded tables of Unicode values
previously used  (and also relying on recent fixes to an undocumented
function from that module ).  It als changes to give better messages if
the evals fail.  Using prop_invlist() allows us to easily extend to all
tests testing of some non-Latin1 code points.

11 years agoUnicode::UCD.pm: Fix bugs in undocumented binary search function
Karl Williamson [Mon, 19 Nov 2012 17:06:41 +0000 (10:06 -0700)]
Unicode::UCD.pm: Fix bugs in undocumented binary search function

This function is undocumented mostly because I was afraid it would be
buggy, as many such implementations are.  See:
http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html
(I recommend reading that link; it is instructive, entertaining, and
humbling.)

And it turns out I was right that I was wrong (in my original code).  A
test was inexplicably reversed, and another missing.

11 years agoregen/regcharclass.pl: Add 'cp_high' macro type
Karl Williamson [Sat, 17 Nov 2012 03:13:33 +0000 (20:13 -0700)]
regen/regcharclass.pl: Add 'cp_high' macro type

This generates a macro whose code point parameter must be above Latin1.
It will be used in future commits to avoid redundant checks

11 years agoregcomp.c: Revise comment
Karl Williamson [Tue, 30 Oct 2012 03:31:17 +0000 (21:31 -0600)]
regcomp.c: Revise comment

11 years agoregexes: Add \v to table of latin1 char classes
Karl Williamson [Thu, 16 Aug 2012 03:45:05 +0000 (21:45 -0600)]
regexes: Add \v to table of latin1 char classes

This will be used in future commits to allow \v and \V to be treated
consistently with other character classes.  (Doing the same for \h isn't
necessary, as it matches identically to [:blank:] in the entire Unicode
range.)

11 years agoregcomp.h: Make some #defines sequential
Karl Williamson [Thu, 16 Aug 2012 03:32:30 +0000 (21:32 -0600)]
regcomp.h: Make some #defines sequential

ANYOF_MAX is used as the upper boundary in loops.  If we keep it larger
than necessary, the loop does extraneous iterations.

The #defines that come after ANYOF_MAX are moved down to start with it.
This is useful in a later commit that will create an entry in
l1_char_class_tab.h for vertical white space determination.

11 years agoregcomp.sym: Change regkind for NPOSIX regnodes
Karl Williamson [Sun, 12 Aug 2012 17:50:54 +0000 (11:50 -0600)]
regcomp.sym: Change regkind for NPOSIX regnodes

It turns out that it is more convenient for the complement of a node to
have a regkind that is also the complement of a node.  This creates
slight inconveniences that are included in this patch, but will help
further patches.

11 years agoregcomp: Change name of #define to better reflect its purpose
Karl Williamson [Thu, 16 Aug 2012 02:49:59 +0000 (20:49 -0600)]
regcomp: Change name of #define to better reflect its purpose

ANYOF_MAX is used for two different purposes; this separates them and
creates a separate #define for one of them.

11 years agoregcomp.c: Revise debugging function
Karl Williamson [Wed, 25 Jul 2012 02:28:48 +0000 (20:28 -0600)]
regcomp.c: Revise debugging function

I use this function for debugging, but it is normally commented out.
This commit adds an entry to embed.fnc for it that can quickly be
uncommented, and makes some revisions to the function itself.

11 years agohandy.h: white-space, comments only
Karl Williamson [Sat, 21 Jul 2012 19:15:01 +0000 (13:15 -0600)]
handy.h: white-space, comments only

11 years agohandy.h: Mark more clearly things for internal-only use
Karl Williamson [Sat, 21 Jul 2012 19:07:49 +0000 (13:07 -0600)]
handy.h: Mark more clearly things for internal-only use

This changes the names of some macros to begin with an underscore, and
changes comments to more clearly indicate things which aren't to be used
outside the Perl core.

11 years agohandy.h: Use class numbers instead of macros in macro generation
Karl Williamson [Sat, 21 Jul 2012 17:45:18 +0000 (11:45 -0600)]
handy.h: Use class numbers instead of macros in macro generation

This refactors the macro builder macros to accept a class number instead
of a macro name.  This is easier to understand than having to use
CAT2(), and it allows for a potential future commit to use these at
run-time, given a class number.

11 years agohandy.h: Convert 3 macros to standard form
Karl Williamson [Sat, 21 Jul 2012 14:50:29 +0000 (08:50 -0600)]
handy.h: Convert 3 macros to standard form

These three outliers don't have to be.  They can use the same
constructed form as the others surrounding them.  One requires a
temporary #define which will be removed in a future commit

11 years agohandy.h: Define some macros for consistency
Karl Williamson [Fri, 20 Jul 2012 18:57:27 +0000 (12:57 -0600)]
handy.h: Define some macros for consistency

isWORDCHAR_uni() and isWORDCHAR_utf8() are defined for consistency with
the other isWORDCHAR...() macros

The isALNUM_foo() versions are retained for backwards compatibility

11 years agoutf8.c: Request function to be inline
Karl Williamson [Fri, 7 Sep 2012 17:20:49 +0000 (11:20 -0600)]
utf8.c: Request function to be inline

This could remove a layer of function call overhead for this small
function, (if the compiler doesn't already choose to inline it).

11 years agoutf8.c: White-space, comments only
Karl Williamson [Fri, 7 Sep 2012 17:16:40 +0000 (11:16 -0600)]
utf8.c: White-space, comments only

11 years agoutf8.c: Fix potential bug
Karl Williamson [Fri, 7 Sep 2012 16:54:44 +0000 (10:54 -0600)]
utf8.c: Fix potential bug

Commit 87367d5f9dc9bbf7db1a6cf87820cea76571bf1a changed
core_invlist_init() to return not the swash, but the swash's inversion
list if small enough, allowing a faster binary search than a slower hash
look-up on small lists.  Calls to two functions that access swashes were
changed to make this transparent.  However, there are two more such
functions which were overlooked, and need to be upgraded to provide such
transparency, should they ever be called on swashes that have been
converted.  This commit fixes one of them, but leaves the other, with a
comment, as it's much harder to do, and will not ever likely be
called on such a swash (it is for internal core use only).

11 years agoembed.fnc: Restrict access to non-public functions
Karl Williamson [Fri, 16 Nov 2012 21:52:45 +0000 (14:52 -0700)]
embed.fnc: Restrict access to non-public functions

These two functions added earlier in 5.17 are not meant to be public.
This moves them so they are defined only for certain core files, and
marks them as experimental should they show up in any documentation.

11 years agoperldelta: mention OP_PADRANGE
David Mitchell [Mon, 19 Nov 2012 17:23:19 +0000 (17:23 +0000)]
perldelta: mention OP_PADRANGE

11 years agoRemove the EPOC port.
Nicholas Clark [Sat, 17 Nov 2012 14:09:45 +0000 (15:09 +0100)]
Remove the EPOC port.

EPOC was a family of operating systems developed by Psion for mobile
devices. It was the predecessor of Symbian.

The port was last updated in April 2002.

11 years agoUpdate CGI to CPAN version 3.63
Chris 'BinGOs' Williams [Mon, 19 Nov 2012 11:10:21 +0000 (11:10 +0000)]
Update CGI to CPAN version 3.63

  [DELTA]

  Version 3.63 Nov 12, 2012

    [SECURITY]
    - CR escaping for Set-Cookie and P3P headers was improved. There was potential
      for newline injection in these headers.
      (Thanks to anazawa, https://github.com/markstos/CGI.pm/pull/23)

11 years agoUpdate Unicode-Collate to CPAN version 0.93
Chris 'BinGOs' Williams [Mon, 19 Nov 2012 11:07:57 +0000 (11:07 +0000)]
Update Unicode-Collate to CPAN version 0.93

  [DELTA]

  0.93  Sun Nov 18 18:13:42 2012
    - DUCET is updated (for Unicode 6.2.0) as Collate/allkeys.txt.
    ! Please notice that allkeys.txt will be overwritten if you have had
      other allkeys.txt already.
    - The default UCA_Version is 26.
    - Locale/*.pl (except fr.pl) and CJK/Korean.pm are updated.
    - modified tests: loc_es.t, loc_estr.t, version.t in t.

11 years agoFix test-skipping logic for File::Glob under no-taint-perl
Steffen Mueller [Mon, 19 Nov 2012 06:48:03 +0000 (07:48 +0100)]
Fix test-skipping logic for File::Glob under no-taint-perl

11 years agoCPAN for EU::ParseXS is now at 3.18
Steffen Mueller [Mon, 19 Nov 2012 06:39:23 +0000 (07:39 +0100)]
CPAN for EU::ParseXS is now at 3.18

11 years agoComplete ExtUtils::ParseXS/EU::Typemaps version bump
Steffen Mueller [Mon, 19 Nov 2012 06:33:29 +0000 (07:33 +0100)]
Complete ExtUtils::ParseXS/EU::Typemaps version bump

This moves to 3.18 across the entire distribution for a new CPAN release
and completes the changelog.

11 years agorefactor pp_padsv
Daniel Dragan [Sun, 18 Nov 2012 23:37:18 +0000 (18:37 -0500)]
refactor pp_padsv

This commit rearranges the autos in a way to minimize the number of vars
saved across calls. By calculating TARG after EXTEND, TARG does not need
to be saved across a conditional stack grow call. In order to not read
the pad slot and PL_curpad twice (once for TARG, once for save_clearsv),
a * to the pad slot is saved in a volatile. var padentry is calced after
the EXTEND call, but before save_clearsv, and is not saved across
save_clearsv. TARG's scope was not extended to the vifify_ref call, since

1. SP (TOPs assignment) will be referenced anyway after vivify_ref and
this can not be removed.
2. All of pp_padsv has only 3 non-vol inter func vars, my_perl, SP and op.

Adding TARG to remain live past any call (save_clearsv) would add a 4th
non-vol var to this opcode and increase the total stack frame size by
1 pointer, either to save a non-vol reg, or to put TARG directly on the
stack (platform dependent).

The SPAGAIN and RETURN combo was strange, since we fetch global SP, and
then write it right back. But in the old code, the RETURN, if the if branch
is not taken would be required for the XPUSHs. SAVECLEARSV macro included
addr of op, would wouldn't work here, so the func was called directly.
Originally I kept the SAVECLEARSV, but the asm of Visual C showed
recalcing of the pad slot in SAVECLEARSV even though no calls are made in
my revision between EXTEND and SAVECLEARSV, so I forced the compiler to
cache the pad slot. By removing a 2nd PL_curpad dereference, in theory
the CPU can toss a chunk of the pad array from CPU cache away sooner.
TOPs does not inc/dec local SP, so a PUTBACK is not required after
vivify_ref. Brief comments added to explain the unusual code on first
glance. PL_op was cached to remove a couple "*(my_perl+4)"s that were
PL_op being reread after the 2 calls. PL_op caching was the last change I
did. Without PL_op caching, pp_padsv has max 2 cross func saved autos but
was 0x77 long. With PL_op caching, pp_padsv now has 3 saved autos, but is
only 0x72 since some "*(my_perl+4)"s were removed. Since Linux/Win32 32 bit
x86 has only 3 (without ebp) or 4 (with ebp) non-vol regs, this func post
PL_op caching still uses no C stack vars (but nonvol regs are saved and
restored of course). This patch is similar in concept to commit fdf4ddd .

The machine size of pp_padsv dropped from 0x85 to 0x72 for me after this
commit.

11 years agoreduce scope of a var in save_clearsv
Daniel Dragan [Mon, 19 Nov 2012 02:16:39 +0000 (21:16 -0500)]
reduce scope of a var in save_clearsv

svp is a pointer to a pad array slice. It is derefed to set a sv flag.
It's optimized scope previous extended past the savestack_grow call. By
moving the flag setting before any calls in save_clearsv, svp does not have
to be carried across any calls. On some platforms there will be a benefit
(args transfered in vol regs for example, AMD64 Win64), on others none
since it will be reread from the stack after any child call anyway. I
assume the SvPADSTALE_off flag will have no effect on the panic croak.
After this commit, the only auto var carried through a call is
offset_shifted (and unavoidably my_perl).

I saw a drop in the size of save_clearsv from 0x5A to 0x58. The saving
and use of 1 nonvol reg on x86 32 bit VC 2003 was reduced, total stack
frame reduced by 1 pointer, since VC 2003 read svp off the stack only
once at the start of save_clearsv and kept it in a nonvol reg for the rest
of this func's body.

11 years agoperlhack: Note why some t/op tests avoid test.pl
Father Chrysostomos [Mon, 19 Nov 2012 02:52:53 +0000 (18:52 -0800)]
perlhack: Note why some t/op tests avoid test.pl

11 years agoStop \P{Assigned} from leaking
Father Chrysostomos [Mon, 19 Nov 2012 02:36:12 +0000 (18:36 -0800)]
Stop \P{Assigned} from leaking

I suspect this leak also applies to any large character classes.

An HV created with newHV has a reference count of 1, so doing
newRV_inc on it will cause a leak.

11 years agoutf8.c: Fix a minor refcounting bug caused by 02c8547
Father Chrysostomos [Mon, 19 Nov 2012 02:44:16 +0000 (18:44 -0800)]
utf8.c: Fix a minor refcounting bug caused by 02c8547

Under some circumstances it could cause a hash to point to a freed
element.  But the hash itself was leaking, so it caused on problems,
as no attempt to free its element again was made.

The next commit will stop the hash from leaking.

11 years agoRequest that regcomp.c:S_regpposixcc be inlined
Father Chrysostomos [Mon, 19 Nov 2012 01:45:09 +0000 (17:45 -0800)]
Request that regcomp.c:S_regpposixcc be inlined

It is only called from one spot.

11 years agoStop /[.zog.]/ and /[[.zog.]]/ from leaking
Father Chrysostomos [Mon, 19 Nov 2012 01:44:20 +0000 (17:44 -0800)]
Stop /[.zog.]/ and /[[.zog.]]/ from leaking

Before croaking, we need to free any SVs we might have allocated tem-
porarily.  Also, Simple_vFAIL does not free the regular expression.
For that we need vFAIL.

11 years agogv.t: Suppress warning
Father Chrysostomos [Mon, 19 Nov 2012 01:29:33 +0000 (17:29 -0800)]
gv.t: Suppress warning

11 years agoInline regcomp.c:S_checkposixcc into its only caller
Father Chrysostomos [Mon, 19 Nov 2012 00:11:20 +0000 (16:11 -0800)]
Inline regcomp.c:S_checkposixcc into its only caller

In the next commit, it will need to access other variables around its
call site.

11 years agofix -DPERL_GLOBAL_STRUCT builds broken with the hash merge
Tony Cook [Sun, 18 Nov 2012 23:41:32 +0000 (10:41 +1100)]
fix -DPERL_GLOBAL_STRUCT builds broken with the hash merge

note: this failed to build in smoke-me eg.
http://perl.develop-help.com/raw/?id=131750

11 years agoperldelta: hash function still needs mention
Father Chrysostomos [Sun, 18 Nov 2012 22:11:07 +0000 (14:11 -0800)]
perldelta: hash function still needs mention

11 years agogv.t: More *foo{NAME,PACKAGE} tests
Father Chrysostomos [Sun, 18 Nov 2012 22:09:21 +0000 (14:09 -0800)]
gv.t: More *foo{NAME,PACKAGE} tests

11 years agoStop $unicode =~ /[[:posix:]]/ from leaking
Father Chrysostomos [Sun, 18 Nov 2012 21:29:56 +0000 (13:29 -0800)]
Stop $unicode =~ /[[:posix:]]/ from leaking

If we have just created an SV, it has a reference count of 1, so using
newRV_inc on it will create a leak.  So we need to use newRV_noinc and
do SvREFCNT_inc in those cases where the SV is not new.

This has leaked since v5.17.3-117-g87367d5.

11 years agoStop prototype("CORE::...") errors from leaking
Father Chrysostomos [Sun, 18 Nov 2012 06:56:07 +0000 (22:56 -0800)]
Stop prototype("CORE::...") errors from leaking

They have leakd since v5.17.0-54-g1b08e05.

11 years agoStop local $_[0] from leaking
Father Chrysostomos [Sun, 18 Nov 2012 06:49:57 +0000 (22:49 -0800)]
Stop local $_[0] from leaking

local $_[0] puts the current $_[0] on to the savestack and gives the
array a brand new SV.  If the array is not marked REAL, it holds no
reference counts on its elements.  @_ is surreal by default.

The localisation code was making @_ hold a reference count on its new
element.  The restore code was assuming it had a reference count, so
everything worked out if $_[0] was not modified after localisation.

But if the array is surreal, then modifications to it will assume that
it does *not* hold a reference count on $_[0].  So doing shift, or
@_=undef would cause the new element to leak.

Also, taking a reference to the array (\@_) will trigger, making
the reference count of all elements increeas, likwies leaking the
new element.

Since there is only one REAL flag, which indicates that all elements
of the array are reference-counted, we cannot have some elements ref-
erence-counted and some not (which local $_[0] does), and have every-
thing behave correctly.

So the only solution is to reify arrays before localising
their elements.

11 years agoMore perlδ stuff
Father Chrysostomos [Sun, 18 Nov 2012 02:37:32 +0000 (18:37 -0800)]
More perlδ stuff

11 years agoMake *_{ARRAY} reify
Father Chrysostomos [Sun, 18 Nov 2012 01:32:20 +0000 (17:32 -0800)]
Make *_{ARRAY} reify

Otherwise *_{ARRAY} returned from a sub will be kenotic, in the lit-
eral sense.  (If you don’t understand that, just look at the test.)

11 years agoDocument and test *glob{NAME} and *glob{PACKAGE}
Father Chrysostomos [Sun, 18 Nov 2012 01:22:01 +0000 (17:22 -0800)]
Document and test *glob{NAME} and *glob{PACKAGE}

These have been supported since *foo{THING} was added in perl 5.005.
If only I had known about these sooner....  I could have been writing
*$AUTOLOAD{NAME} all this time!

11 years agoAll tests should have descriptions.
James E Keenan [Mon, 22 Oct 2012 01:49:03 +0000 (21:49 -0400)]
All tests should have descriptions.

11 years agoIncrease $XS::APItest::VERSION to 0.45
Father Chrysostomos [Sat, 17 Nov 2012 20:44:31 +0000 (12:44 -0800)]
Increase $XS::APItest::VERSION to 0.45

11 years agorefactor pp_rand
Daniel Dragan [Sat, 17 Nov 2012 07:20:50 +0000 (02:20 -0500)]
refactor pp_rand

Reduce liveness of various variables. srand relies on nothing but a THX
so do that first and don't calculate a local SP yet. Put the EXTEND near SP
calculation. This might refresh SP. MAXARG access PL_op. The POPs balances
the stack. var sv is kept in a volatile, it is out of scope after the SvNV.
Through the SvNV, only 2 autos/regs are carried my_perl and SP.
dTARGET again uses PL_op but it and PUSHs and PUTBACK make no calls. SP is
out of scope after the PUTBACK. In macro Drand01 is the next call. XPUSHn
uses SvSETMAGIC. This is replaced with sv_setnv_mg since rand is not hot.
Now TARG is out of scope. Only my_perl remains in scope. NORMAL uses
PL_op for the 3rd and final time. All x86 32bit C stack usage was for
saving nonvol regs and 2 auto NVs (asm limitations prevent from keeping
it in a normal reg I guess)(VC2003). Caching PL_op->op_next at dTARGET to
avoid a 3rd PL_op dereference was tried with

SV * targ; (op_next = NORMAL), (GETTARGET), (PUSHs(TARG)), (PUTBACK);

to allow reordering, but it generated a stack auto on Visual C even
though 1 non vol reg (edi) was available. Another untried idea would be to
declare a OP * and set it to PL_op, then do the op_next and op_targ derefs,
but with the above mess, PL_op was derefed once by compiler optimization
but still the stack var was used. Also maintainability contributed to
scrapping  the idea. The 1.0 assigns are reordered by comp in a way
that all of them happen after the SvNV but before the next call, which
is rand(), so they are fine order of execution wise. The comment about
SP or TARG means either dTARGET is done before the SvNV and SP is out of
scope before SvNV but SV * targ has to be saved across the SvNV, or SP is
saved across the SvNV. A choice was made save SP since the C code would
be more complicated, probably with gotos and initialing sv to NULL if
dTARGET/PUTBACK had to happen after conditional MAXARG/TOPs
unconditionally, but SvNV is conditonally called. The improvements in
this commit are not specific to x86-32 but all platforms and cpus.

The function dropped from 0xFF to 0xEB for me.

11 years ago[perl #115756] Fix XS::APItest::SvIsCOW
Father Chrysostomos [Sat, 17 Nov 2012 19:01:42 +0000 (11:01 -0800)]
[perl #115756] Fix XS::APItest::SvIsCOW

SvIsCOW returns a flag which will turn into 0 if truncated to 8 bits.

11 years ago8c34e50dc slowed down detruction with no DESTROY
Father Chrysostomos [Sat, 17 Nov 2012 18:49:11 +0000 (10:49 -0800)]
8c34e50dc slowed down detruction with no DESTROY

I changed it to cache the DESTROY method in SvSTASH(stash), instead
of amagic tables, for the sake of speed.  But I made no distinction
between ‘no cache’ and ‘no DESTROY method’.  So classes with no
DESTROY method became as slow as perl 5.6.

To solve that, I’m using an adjusted pointer (following the example
of warnings.h) to mean ‘intentionally blank’.

I also fixed two instances of the DESTROY cache not being updated,
introduced by that commit.

11 years agoHash Function Change - Murmur hash and true per process hash seed
Yves Orton [Sat, 17 Nov 2012 13:12:04 +0000 (14:12 +0100)]
Hash Function Change - Murmur hash and true per process hash seed

This patch does the following:

*) Introduces multiple new hash functions to choose from at build
time. This includes Murmur-32, SDBM, DJB2, SipHash, SuperFast, and
One-at-a-time. Currently this is handled by muning hv.h. Configure
support hopefully to follow.

*) Changes the default hash to Murmur hash which is faster than the
old default One-at-a-time.

*) Rips out the old HvREHASH mechanism and replaces it with a
per-process random hash seed.

*) Changes the old PL_hash_seed from an interpreter value to a
global variable. This means it does not have to be copied during
interpreter setup or cloning.

*) Changes the format of the PERL_HASH_SEED variable to a hex
string so that hash seeds longer than fit in an integer are possible.

*) Changes the return of Hash::Util::hash_seed() from a number to a
string. This is to accomodate hash functions which have more bits than
can be fit in an integer.

*) Adds new functions to Hash::Util to improve introspection of hashes

  -) hash_value() - returns an integer hash value for a given string.
  -) bucket_info() - returns basic hash bucket utilization info
  -) bucket_stats() - returns more hash bucket utilization info
  -) bucket_array() - which keys are in which buckets in a hash

More details on the new hash functions can be found below:

    Murmur Hash: (v3) from google, see
        http://code.google.com/p/smhasher/wiki/MurmurHash3

    Superfast Hash: From Paul Hsieh.
        http://www.azillionmonkeys.com/qed/hash.html

    DJB2: a hash function from Daniel Bernstein
        http://www.cse.yorku.ca/~oz/hash.html

    SDBM: a hash function sdbm.
        http://www.cse.yorku.ca/~oz/hash.html

    SipHash: by Jean-Philippe Aumasson and Daniel J. Bernstein.
        https://www.131002.net/siphash/

They have all be converted into Perl's ugly macro format.
I have not done any rigorous testing to make sure this conversion
is correct. They seem to function as expected however.

All of them use the random hash seed.

You can force the use of a given function by defining one of

    PERL_HASH_FUNC_MURMUR
    PERL_HASH_FUNC_SUPERFAST
    PERL_HASH_FUNC_DJB2
    PERL_HASH_FUNC_SDBM
    PERL_HASH_FUNC_ONE_AT_A_TIME

Setting the environment variable PERL_HASH_SEED_DEBUG to 1 will make
perl output the current seed (changed to hex) and the hash function
it has been built with.

Setting the environment variable PERL_HASH_SEED to a hex value will
cause that value to be used at the seed. Any missing bits of the seed
will be set to 0. The bits are filled in from left to right, not
the traditional right to left so setting it to FE results in a seed
value of "FE000000" not "000000FE".

Note that we do the hash seed initialization in perl_construct().
Doing it via perl_alloc() (via init_tls) causes problems under
threaded builds as the buffers used for reentrant srand48 functions
are not allocated. See also the p5p mail "Hash improvements blocker:
portable random code that doesnt depend on a functional interpreter",
Message-ID:
<CANgJU+X+wNayjsNOpKRqYHnEy_+B9UH_2irRA5O3ZmcYGAAZFQ@mail.gmail.com>

11 years agoleakfinder: More exceptions
Father Chrysostomos [Sat, 17 Nov 2012 18:13:10 +0000 (10:13 -0800)]
leakfinder: More exceptions

11 years agoperlδ
Father Chrysostomos [Sat, 17 Nov 2012 18:09:16 +0000 (10:09 -0800)]
perlδ

11 years ago[perl #114864] Don’t use amt for DESTROY
Father Chrysostomos [Fri, 16 Nov 2012 18:00:50 +0000 (10:00 -0800)]
[perl #114864] Don’t use amt for DESTROY

DESTROY has been cached in overload tables since
perl-5.6.0-2080-g32251b2, making it 4 times faster than before (over-
load tables are faster than method lookup).

But it slows down symbol lookup on stashes with overload tables,
because overload tables use magic, and SvRMAGICAL results in calls to
mg_find on every hash lookup.

By reusing SvSTASH(stash) to cache the DESTROY method (if the stash
is unblessed, of course, as most stashes are), we can avoid making
all destroyable stashes magical and also speed up DESTROY lookup
slightly more.

The results:

• 10% increase in stash lookup speed after destructors.  That was just
  testing $Foo::{x}.  Other stash lookups will have other overheads
  that make the difference less impressive.

• 5% increase in DESTROY lookup speed.  I was using an empty DESTROY
  method to test this, so, again, real DESTROY methods will have more
  overhead and less speedup.

11 years agoPreserve case of command-line arguments on VMS.
Craig A. Berry [Sat, 17 Nov 2012 17:24:43 +0000 (11:24 -0600)]
Preserve case of command-line arguments on VMS.

OpenVMS releases of the last decade or so have had this capability
but it's still not the default.  But it's a reasonable default for
Perl, so enable it in our initialization code.

Unfortunately this feature does not work unless extended parse has
been enabled in the process before invoking Perl.  Enabling
extended parse in our initialization code doesn't do any good
because DCL has already parsed the arguments before we get there.

So we will be limited to documenting that things work better with
extended parse and that the test suite assumes it's enabled.

11 years agoadd .gdb_history to .gitignore
Yves Orton [Sat, 17 Nov 2012 13:10:59 +0000 (14:10 +0100)]
add .gdb_history to .gitignore

11 years agoAdd a utility macro for reading hex digits.
Yves Orton [Sat, 17 Nov 2012 13:04:38 +0000 (14:04 +0100)]
Add a utility macro for reading hex digits.

Karl checked and it seems it actually works on EBCDIC as well
as on ASCII.

11 years agomake regcharclass hash order determinisitic
Yves Orton [Sat, 17 Nov 2012 13:02:18 +0000 (14:02 +0100)]
make regcharclass hash order determinisitic

11 years agoEliminate test from generated cp macros
Yves Orton [Sat, 17 Nov 2012 11:58:12 +0000 (12:58 +0100)]
Eliminate test from generated cp macros

Sayeth Karl:
In the _cp macros, the final test can be simplified:

/*** GENERATED CODE ***/
#define is_VERTWS_cp(cp)     \
( ( 0x0A <= cp && cp <= 0x0D ) || ( 0x0D < cp &&     \
( 0x85 == cp || ( 0x85 < cp &&     \
( 0x2028 == cp || ( 0x2028 < cp &&     \
0x2029 == cp ) ) ) ) ) )

That 0x2028 < cp can be omitted and it will still mean the same thing.

And So Be It.

11 years agoclone() wasn't cloning the whole stack
David Mitchell [Fri, 16 Nov 2012 18:04:49 +0000 (18:04 +0000)]
clone() wasn't cloning the whole stack

When cloning stacks (e.g. for fake fork), the stack is cloned
by copying the stack AV pointed to by PL_curstackinfo; but the
AvFILL on that AV may not be up to date, resulting in the top N
items of the stack not being cloned. Fix by saving PL_stack_sp
back into AvFILL(PL_curstack) before cloning

11 years agoOops, fix memory leak just introduced by 3fcdbd32b2
Steve Hay [Fri, 16 Nov 2012 14:21:06 +0000 (14:21 +0000)]
Oops, fix memory leak just introduced by 3fcdbd32b2

11 years agoDon't try to ansify the path if it is empty
Steve Hay [Fri, 16 Nov 2012 09:11:36 +0000 (09:11 +0000)]
Don't try to ansify the path if it is empty

Fixes a possible crash (manifested when running with the page heap enabled)
when running after clearing PATH, which at least one test in op/taint.t
does.

11 years agounder -Dusedl there are no warnings about the other dl_ functions
Tony Cook [Fri, 16 Nov 2012 11:14:16 +0000 (22:14 +1100)]
under -Dusedl there are no warnings about the other dl_ functions

without usedl, the warnings are like:

Subroutine DynaLoader::dl_error redefined at (eval 1) line 2
... warnings about every other DynaLoader function
Subroutine DynaLoader::dl_error redefined at (eval 2) line 2

with usedl, only dl_error is defined, so the other warnings disappear,
since the regexp expected two new-lines between the dl_error warnings
the test failed.

The change makes one of the newlines optional.

11 years agoleakfinder.pl requires XS::APItest which isn't built with -Uusedl
Tony Cook [Fri, 16 Nov 2012 09:57:32 +0000 (20:57 +1100)]
leakfinder.pl requires XS::APItest which isn't built with -Uusedl

11 years agosave_freeop is not an expression, remove PL_Xpv
Daniel Dragan [Thu, 15 Nov 2012 20:11:10 +0000 (15:11 -0500)]
save_freeop is not an expression, remove PL_Xpv

save_freeop and SAVEFREEOP are never used in expressions only statements.
Using PL_Xpv is never ideal. For me .text section dropped from 0xC1DFF to
0xC1DBF after applying this.

11 years agoleakfinder.pl: More exceptions
Father Chrysostomos [Thu, 15 Nov 2012 23:55:50 +0000 (15:55 -0800)]
leakfinder.pl: More exceptions

11 years ago[perl #115742] Push a new pad for recursive DB::DB
Father Chrysostomos [Thu, 15 Nov 2012 23:53:13 +0000 (15:53 -0800)]
[perl #115742] Push a new pad for recursive DB::DB

When invoking the debugger recursively, pp_dbstate needs to push a new
pad (like pp_entersub) so that DB::DB doesn’t stomp on the lexical
variables belonging to the outer call.

11 years agoperlre: Fix syntax error in example
Father Chrysostomos [Thu, 15 Nov 2012 20:46:36 +0000 (12:46 -0800)]
perlre: Fix syntax error in example

11 years agoperlfunc: Correct note about eval in DB package
Father Chrysostomos [Thu, 15 Nov 2012 20:38:27 +0000 (12:38 -0800)]
perlfunc: Correct note about eval in DB package

It’s where the subroutine is defined, not the current package,
that matters.

#!perl -l
sub { my $x = 3; foo(); print $x }->();
sub foo { package DB; eval q"$x = 42" }
__END__
3

#!perl -l
sub { my $x = 3; DB::foo(); print $x }->();
package DB;
sub foo { package main; eval q"$x = 42"; }
__END__
42

11 years agoleakfinder.pl: Run evals four times
Father Chrysostomos [Thu, 15 Nov 2012 02:08:34 +0000 (18:08 -0800)]
leakfinder.pl: Run evals four times

With three times we still get false positives

11 years agoleakfinder.pl: More exceptions
Father Chrysostomos [Thu, 15 Nov 2012 02:05:04 +0000 (18:05 -0800)]
leakfinder.pl: More exceptions

11 years ago[MERGE] refactor pp_iter
David Mitchell [Thu, 15 Nov 2012 22:46:31 +0000 (22:46 +0000)]
[MERGE] refactor pp_iter

Refactor the code in this hot function. Chiefly, the if/else chain
was replaced with a single switch statment, and various bits of code were
tidied up, duplicate code eliminated, local vars added to avoid repeated
evaluation of expressions etc; along with big whitespace changes to fix up
indentation etc afterwards.

With these changes, these trivial benchamarks run about 7% faster:

    $x++ for @a; # @a has 30_000 elements
    $x++ for 1..30_000;

while this one stayed about the same, presumably due to the relatively
costly overhead of sv_inc():

    $x++ for 'aaa' .. 'zzz';

11 years agopp_iter: final whitespace/comment tidy up
David Mitchell [Thu, 15 Nov 2012 22:34:40 +0000 (22:34 +0000)]
pp_iter: final whitespace/comment tidy up

reindent the LAZYSV block to be consistent with the other two;
move the comments to be on the same line as the case statements,
and fix the indent on the RETPUSHYES.

Only whitespace/moving comment changes; nothing functional

11 years agopp_iter: refactor CXt_LOOP_LAZYSV branch
David Mitchell [Tue, 13 Nov 2012 13:12:31 +0000 (13:12 +0000)]
pp_iter: refactor CXt_LOOP_LAZYSV branch

11 years agopp_iter: refactor CXt_LOOP_LAZYIV branch
David Mitchell [Tue, 13 Nov 2012 12:51:05 +0000 (12:51 +0000)]
pp_iter: refactor CXt_LOOP_LAZYIV branch

11 years agopp_iter: a bit more refactoring of CXt_LOOP_FOR branch
David Mitchell [Tue, 13 Nov 2012 12:20:34 +0000 (12:20 +0000)]
pp_iter: a bit more refactoring of CXt_LOOP_FOR branch

11 years agopp_iter: factor out some common code in CXt_LOOP_FOR
David Mitchell [Tue, 13 Nov 2012 11:55:19 +0000 (11:55 +0000)]
pp_iter: factor out some common code in CXt_LOOP_FOR

11 years agopp_iter: move var declarations to narrower scope
David Mitchell [Tue, 13 Nov 2012 11:15:01 +0000 (11:15 +0000)]
pp_iter: move var declarations to narrower scope

11 years agopp_iter: reindent after removing if block
David Mitchell [Tue, 13 Nov 2012 11:02:36 +0000 (11:02 +0000)]
pp_iter: reindent after removing if block

only whitespace changes

11 years agopp_iter: move RETPUSHYES outside switch
David Mitchell [Tue, 13 Nov 2012 10:57:35 +0000 (10:57 +0000)]
pp_iter: move RETPUSHYES outside switch

11 years agopp_iter: reindent code after previous change
David Mitchell [Tue, 13 Nov 2012 10:52:49 +0000 (10:52 +0000)]
pp_iter: reindent code after previous change

Only whitespace changes

11 years agopp_iter: replace if/else with switch
David Mitchell [Tue, 13 Nov 2012 10:35:34 +0000 (10:35 +0000)]
pp_iter: replace if/else with switch

Makes the code neater and slightly faster

11 years agoFix unescaped left brace warning in uni/parser.t.
Craig A. Berry [Thu, 15 Nov 2012 17:12:25 +0000 (11:12 -0600)]
Fix unescaped left brace warning in uni/parser.t.

Which was causing the test to fail (on VMS at least) with
"unexpected output at test 0".

11 years agodump.c: Fix non-mad threaded build error
Father Chrysostomos [Wed, 14 Nov 2012 22:19:52 +0000 (14:19 -0800)]
dump.c: Fix non-mad threaded build error

This was introduced by 75a6ad4aa3.

C preprocessors treat the ‘aTHX_ foo’ in MACRO(aTHX_ foo) as a sin-
gle argument.

11 years agoSVf_IsCOW
Father Chrysostomos [Wed, 14 Nov 2012 21:02:48 +0000 (13:02 -0800)]
SVf_IsCOW

As discussed in ticket #114820, instead of using READONLY+FAKE to mark
a copy-on-write string, we should make it a separate flag.

There are many modules in CPAN (and 1 in core, Compress::Raw::Zlib)
that assume that SvREADONLY means read-only.  Only one CPAN module,
POSIX::pselect will definitely be broken by this.  Others may need to
be tweaked.  But I believe this is for the better.

It causes all tests except ext/Devel-Peek/t/Peek.t (which needs a tiny
tweak still) to pass under PERL_OLD_COPY_ON_WRITE, which is a prereq-
uisite for any new COW scheme that creates COWs under the same cir-
cumstances.

11 years agoleakfinder.pl: Duh!
Father Chrysostomos [Wed, 14 Nov 2012 19:22:56 +0000 (11:22 -0800)]
leakfinder.pl: Duh!

I hadn’t tested this before I committed it.  It had a syntax error.

11 years agoCombine duplicate dump code
Reini Urban [Wed, 14 Nov 2012 18:33:43 +0000 (12:33 -0600)]
Combine duplicate dump code

Combine op_flags and op_private dumper for MAD (xml) and -Dx dump.
Add some previously missing flags.

11 years agoremove most calls to strlen in S_force_ident
Daniel Dragan [Wed, 14 Nov 2012 11:18:54 +0000 (06:18 -0500)]
remove most calls to strlen in S_force_ident

I saw strlen("\"") being called here, where the string came from
Perl_yylex. This commit provides a shortcut to not call strlen for a
1 character + null character string.

11 years agoStop eval "END OF TERMS" from leaking
Father Chrysostomos [Wed, 14 Nov 2012 14:10:37 +0000 (06:10 -0800)]
Stop eval "END OF TERMS" from leaking

I found this memory leak by evaluating lines of the Copying file as
Perl code. :-)

The parser requires yylex to return exactly one token with each call.
Sometimes yylex needs to record a few tokens ahead of time, so its
puts them in its forced token stack.  The next call to yylex then pops
the pending token off that stack.

Ops belong to their subroutines.  If the subroutine is freed before
its root is attached, all the ops created when PL_compcv pointed
to that sub are freed as well.  To avoid crashes, the ops on the
savestack and the forced token stack are specially marked so they are
not freed when the sub is freed.

When it comes to evaluating "END OF TERMS AND CONDITIONS", the END
token causes a subroutine to be created and placed in PL_compcv.  The
OF token is treated by the lexer as a method call on the TERMS pack-
age.  The TERMS token is placed in the forced token stack as an sv in
an op for a WORD token, and a METHOD token for OF is returned.  As
soon as the parser sees the OF, it generates an error, which results
in LEAVE_SCOPE being called, which frees the subroutine for END while
TERMS is still on the forced token stack.  So the subroutine’s op
cleanup skips that op.  Then the parser calls back into the lexer,
which returns the TERMS token from the forced token stack.  Since
there has been an error, the parser discards that token, so the op
is never freed.  The forced token stack cleanup that happens in
parser_free does not catch this, as the token is no longer on
that stack.

Earlier, to solve the problem of yylex returning freed ops to the
parser, resulting in crashes, I set the op_savefree flag on ops on the
forced token stack.  But that resulted in a leak.

So now I am using a different approach: When the sub is freed and
frees all its ops, have it also look in the parser’s forced token
stack, freeing any ops that belong to it, and setting the point-
ers to null.