summaryrefslogtreecommitdiff
path: root/universal.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Consistently use NOT_REACHED; /* NOTREACHED */Jarkko Hietaniemi2015-03-041-1/+1
| | | | | | Both needed: the macro is for compilers, the comment for static checkers. (This doesn't address whether each spot is correct and necessary.)
* Add documentation for /n (non-capture) regexp flag.Matthew Horsfall2014-12-301-1/+1
|
* [perl #123458] list cx re::regexp_pattern($nonre)Father Chrysostomos2014-12-191-1/+1
| | | | | It was returning (undef) in list context, though it was documented to return the empty list.
* universal.c:re_regexp_pattern: Mention GIMME_V onceFather Chrysostomos2014-12-191-2/+3
| | | | | | | | | | | While it was only being called once, it occurred in two code paths. Pulling it out of the main if-block reduces the size of universal.o. Before and after: $ ls -l universal.o -rw-r--r-- 1 sprout staff 33700 Dec 19 16:05 universal.o $ ls -l universal.o -rw-r--r-- 1 sprout staff 33692 Dec 19 16:13 universal.o
* make more use of NOT_REACHEDLukas Mai2014-11-291-1/+1
| | | | In particular, remove all instances of 'assert(0);'.
* optimize Perl_boot_core_UNIVERSAL and Perl_nextargvDaniel Dragan2014-11-071-2/+4
| | | | | | | | | | | Perl_nextargv fuse 2 tests into 1 Perl_boot_core_UNIVERSAL reorder instructions to avoid using a non-vol registers (save cv across the Safefree), not reread CV body * after Safefree. Compute address of CvFILE once. for Perl_boot_core_UNIVERSAL on VC 2003 before 0x66 bytes of 32 bit x86 machine code, after 0x61.
* Implement the bipolar read-only systemFather Chrysostomos2014-09-201-2/+2
| | | | | | | | | | | | | | | | | | | | | This fixes bugs related to Hash::Util::unlock accidentally unlocking internal scalars (e.g., that returned by undef()) and allowing them to be modified. Internal read-only values are now marked by two flags, the regular read-only flag, and the new ‘protected’ flag. Before this SvREADONLY served two purposes: 1) The code would use it to protect things that must not be modi- fied, ever (except when the core sees fit to do so). 2) Hash::Util and everybody else would use it to make this unmodifia- ble temporarily when requested by the user. Internals::SvREADONLY serves the latter purpose and only flips the read-only flag, so things that need to stay read-only will remain so, because of the ‘other’ read-only flag, that CPAN doesn’t know about. (If you are a CPAN author, do not read this.)
* universal.c:croak_xs_usage: Don’t fetch context twiceFather Chrysostomos2014-09-151-1/+1
|
* Avoid creating GVs when subs are declaredFather Chrysostomos2014-09-151-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes ‘sub foo {...}’ declarations to store subroutine references in the stash, to save memory. Typeglobs still notionally exist. Accessing CvGV(cv) will reify them. Hence, currently the savings are lost when a sub call is compiled. $ ./miniperl -e 'sub foo{} BEGIN { warn $::{foo} } foo(); BEGIN { warn $::{foo} }' CODE(0x7f8ef082ad98) at -e line 1. *main::foo at -e line 1. This optimisation is skipped if the subroutine declaration contains a package separator. Concerning the changes in caller.t, this code: sub foo { print +(caller(0))[3],"\n" } my $fooref = delete $::{foo}; $fooref -> (); used to crash in 5.7.3 or thereabouts. It was fixed by 16658 (aka 07b8c804e8) to produce ‘(unknown)’ instead. Then in 5.13.3 it was changed (by 803f274) to produce ‘main::__ANON__’ instead. So the tests are really checking that we don’t get a crash. I think it is acceptable that it has now changed to ‘main::foo’.
* For lexical subs, reify CvGV from CvSTASH and CvNAME_HEKFather Chrysostomos2014-09-151-1/+2
| | | | | From now on, the presence of a name hek implies a GV. Any access to CvGV will cause that implicit GV to be reified.
* universal.c gv_stashpv -> gv_stashpvsDaniel Dragan2014-07-031-1/+1
| | | | avoids a strlen()
* Remove or downgrade unnecessary dVAR.Jarkko Hietaniemi2014-06-251-24/+0
| | | | | | | | You need to configure with g++ *and* -Accflags=-DPERL_GLOBAL_STRUCT or -Accflags=-DPERL_GLOBAL_STRUCT_PRIVATE to see any difference. (g++ does not do the "post-annotation" form of "unused".) The version code has some of these issues, reported upstream.
* universal.c - utf8::downgrade($x,FAIL_OK) is not supposed to treat FAIL_OK ↵Yves Orton2014-06-021-1/+1
| | | | as an integer
* Insert asserts to paths suspected by Coverity.Jarkko Hietaniemi2014-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Coverity suspects paths like this: (1) p = foo(); if (!p) p = bar(); baz(p->q); since it cannot prove that p is always non-NULL at the dereference. (2) Or simply something like: mg = mg_find(...); foo(mg->blah); Since mg_find() can fail returning NULL. Adding assert() calls before the dereferences. Testing with -DDEBUGGING. Hopefully there are regular smokes doing the same. [perl #121894] Fix for Coverity perl5 CIDs 28950,28952..28955,28964,28967,28970..28795,49921: CID ...: Dereference after null check (FORWARD_NULL) var_deref_op: Dereferencing null pointer p->q (TODO: Coverity perl5 CIDs 28962,28968,28969: the same issue, but would conflict with already in-flight changes, prepare catch-up patch later.) --- dist/Data-Dumper/Dumper.xs | 1 + dump.c | 1 + ext/Devel-Peek/Peek.xs | 1 + ext/XS-APItest/APItest.xs | 1 + mg.c | 2 ++ mro.c | 4 +++- op.c | 4 ++++ perlio.c | 1 + pp_hot.c | 5 +++-- regcomp.c | 3 +++ regexec.c | 5 ++++- universal.c | 2 +- util.c | 4 +++- 13 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dist/Data-Dumper/Dumper.xs b/dist/Data-Dumper/Dumper.xs index 12c4ebd..23e0cf4 100644 --- a/dist/Data-Dumper/Dumper.xs +++ b/dist/Data-Dumper/Dumper.xs @@ -641,6 +641,7 @@ DD_dump(pTHX_ SV *val, const char *name, STRLEN namelen, SV *retval, HV *seenhv, else { sv_pattern = val; } + assert(sv_pattern); rval = SvPV(sv_pattern, rlen); rend = rval+rlen; slash = rval; diff --git a/dump.c b/dump.c index 59be3e0..c2d72fd 100644 --- a/dump.c +++ b/dump.c @@ -471,6 +471,7 @@ Perl_sv_peek(pTHX_ SV *sv) finish: while (unref--) sv_catpv(t, ")"); + /* XXX when is sv ever NULL? */ if (TAINTING_get && SvTAINTED(sv)) sv_catpv(t, " [tainted]"); return SvPV_nolen(t); diff --git a/ext/Devel-Peek/Peek.xs b/ext/Devel-Peek/Peek.xs index 679efa5..b20fa94 100644 --- a/ext/Devel-Peek/Peek.xs +++ b/ext/Devel-Peek/Peek.xs @@ -450,6 +450,7 @@ PPCODE: BOOT: { CV * const cv = get_cvn_flags("Devel::Peek::Dump", 17, 0); + assert(cv); cv_set_call_checker(cv, S_ck_dump, (SV *)cv); XopENTRY_set(&my_xop, xop_name, "Dump"); diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index a51924d..18ba381 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -2096,6 +2096,7 @@ newCONSTSUB(stash, name, flags, sv) break; } EXTEND(SP, 2); + assert(mycv); PUSHs( CvCONST(mycv) ? &PL_sv_yes : &PL_sv_no ); PUSHs((SV*)CvGV(mycv)); diff --git a/mg.c b/mg.c index 76912bd..7f3339a 100644 --- a/mg.c +++ b/mg.c @@ -1675,6 +1675,7 @@ Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg) same function. */ mg = mg_find(mg->mg_obj, PERL_MAGIC_isa); + assert(mg); if (SvTYPE(mg->mg_obj) == SVt_PVAV) { /* multiple stashes */ SV **svp = AvARRAY((AV *)mg->mg_obj); I32 items = AvFILLp((AV *)mg->mg_obj) + 1; @@ -3437,6 +3438,7 @@ Perl_magic_copycallchecker(pTHX_ SV *sv, MAGIC *mg, SV *nsv, sv_magic(nsv, &PL_sv_undef, mg->mg_type, NULL, 0); nmg = mg_find(nsv, mg->mg_type); + assert(nmg); if (nmg->mg_flags & MGf_REFCOUNTED) SvREFCNT_dec(nmg->mg_obj); nmg->mg_ptr = mg->mg_ptr; nmg->mg_obj = SvREFCNT_inc_simple(mg->mg_obj); diff --git a/mro.c b/mro.c index 1b37ca7..ccf4bf4 100644 --- a/mro.c +++ b/mro.c @@ -638,12 +638,14 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash) hv_storehek(mroisarev, namehek, &PL_sv_yes); } - if((SV *)isa != &PL_sv_undef) + if ((SV *)isa != &PL_sv_undef) { + assert(namehek); mro_clean_isarev( isa, HEK_KEY(namehek), HEK_LEN(namehek), HvMROMETA(revstash)->isa, HEK_HASH(namehek), HEK_UTF8(namehek) ); + } } } } diff --git a/op.c b/op.c index 796cb03..79621ce 100644 --- a/op.c +++ b/op.c @@ -2907,6 +2907,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) S_cant_declare(aTHX_ o); } else if (attrs) { GV * const gv = cGVOPx_gv(cUNOPo->op_first); + assert(PL_parser); PL_parser->in_my = FALSE; PL_parser->in_my_stash = NULL; apply_attrs(GvSTASH(gv), @@ -2929,6 +2930,7 @@ S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp) else if (attrs && type != OP_PUSHMARK) { HV *stash; + assert(PL_parser); PL_parser->in_my = FALSE; PL_parser->in_my_stash = NULL; @@ -10229,6 +10231,7 @@ Perl_ck_split(pTHX_ OP *o) op_append_elem(OP_SPLIT, o, newDEFSVOP()); kid = kid->op_sibling; + assert(kid); scalar(kid); if (!kid->op_sibling) @@ -10902,6 +10905,7 @@ Perl_cv_set_call_checker(pTHX_ CV *cv, Perl_call_checker ckfun, SV *ckobj) MAGIC *callmg; sv_magic((SV*)cv, &PL_sv_undef, PERL_MAGIC_checkcall, NULL, 0); callmg = mg_find((SV*)cv, PERL_MAGIC_checkcall); + assert(callmg); if (callmg->mg_flags & MGf_REFCOUNTED) { SvREFCNT_dec(callmg->mg_obj); callmg->mg_flags &= ~MGf_REFCOUNTED; diff --git a/perlio.c b/perlio.c index d4c43d0..e6ff9e4 100644 --- a/perlio.c +++ b/perlio.c @@ -2225,6 +2225,7 @@ PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags) PerlIO_funcs * const self = PerlIOBase(o)->tab; SV *arg = NULL; char buf[8]; + assert(self); PerlIO_debug("PerlIOBase_dup %s f=%p o=%p param=%p\n", self ? self->name : "(Null)", (void*)f, (void*)o, (void*)param); diff --git a/pp_hot.c b/pp_hot.c index 2cccc48..9c9d1e9 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -3078,6 +3078,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) const HE* const he = hv_fetch_ent(stash, meth, 0, *hashp); if (he) { gv = MUTABLE_GV(HeVAL(he)); + assert(stash); if (isGV(gv) && GvCV(gv) && (!GvCVGEN(gv) || GvCVGEN(gv) == (PL_sub_generation + HvMROMETA(stash)->cache_gen))) @@ -3085,9 +3086,9 @@ S_method_common(pTHX_ SV* meth, U32* hashp) } } + assert(stash || packsv); gv = gv_fetchmethod_sv_flags(stash ? stash : MUTABLE_HV(packsv), - meth, GV_AUTOLOAD | GV_CROAK); - + meth, GV_AUTOLOAD | GV_CROAK); assert(gv); return isGV(gv) ? MUTABLE_SV(GvCV(gv)) : MUTABLE_SV(gv); diff --git a/regcomp.c b/regcomp.c index eaee604..3d49827 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2007,6 +2007,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, }); re_trie_maxbuff = get_sv(RE_TRIE_MAXBUF_NAME, 1); + assert(re_trie_maxbuff); if (!SvIOK(re_trie_maxbuff)) { sv_setiv(re_trie_maxbuff, RE_TRIE_MAXBUF_INIT); } @@ -14920,6 +14921,7 @@ S_set_ANYOF_arg(pTHX_ RExC_state_t* const pRExC_state, av_store(av, 0, (runtime_defns) ? SvREFCNT_inc(runtime_defns) : &PL_sv_undef); if (swash) { + assert(cp_list); av_store(av, 1, swash); SvREFCNT_dec_NN(cp_list); } @@ -16609,6 +16611,7 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node, last= plast; while (PL_regkind[op] != END && (!last || node < last)) { + assert(node); /* While that wasn't END last time... */ NODE_ALIGN(node); op = OP(node); diff --git a/regexec.c b/regexec.c index 362390b..ffab4f2 100644 --- a/regexec.c +++ b/regexec.c @@ -7010,6 +7010,8 @@ no_silent: sv_commit = &PL_sv_yes; sv_yes_mark = &PL_sv_no; } + assert(sv_err); + assert(sv_mrk); sv_setsv(sv_err, sv_commit); sv_setsv(sv_mrk, sv_yes_mark); } @@ -7620,6 +7622,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog, *only_utf8_locale_ptr = ary[2]; } else { + assert(only_utf8_locale_ptr); *only_utf8_locale_ptr = NULL; } @@ -7641,7 +7644,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog, } else if (doinit && ((si && si != &PL_sv_undef) || (invlist && invlist != &PL_sv_undef))) { - + assert(si); sw = _core_swash_init("utf8", /* the utf8 package */ "", /* nameless */ si, diff --git a/universal.c b/universal.c index a29696d..65e02df 100644 --- a/universal.c +++ b/universal.c @@ -67,7 +67,7 @@ S_isa_lookup(pTHX_ HV *stash, const char * const name, STRLEN len, U32 flags) if (our_stash) { HEK *canon_name = HvENAME_HEK(our_stash); if (!canon_name) canon_name = HvNAME_HEK(our_stash); - + assert(canon_name); if (hv_common(isa, NULL, HEK_KEY(canon_name), HEK_LEN(canon_name), HEK_FLAGS(canon_name), HV_FETCH_ISEXISTS, NULL, HEK_HASH(canon_name))) { diff --git a/util.c b/util.c index b90abe5..cd0afb6 100644 --- a/util.c +++ b/util.c @@ -850,15 +850,17 @@ Perl_fbm_instr(pTHX_ unsigned char *big, unsigned char *bigend, SV *littlestr, U { const MAGIC *const mg = mg_find(littlestr, PERL_MAGIC_bm); - const unsigned char * const table = (const unsigned char *) mg->mg_ptr; const unsigned char *oldlittle; + assert(mg); + --littlelen; /* Last char found by table lookup */ s = big + littlelen; little += littlelen; /* last char */ oldlittle = little; if (s < bigend) { + const unsigned char * const table = (const unsigned char *) mg->mg_ptr; I32 tmp; top2: -- 1.8.5.2 (Apple Git-48)
* Use the C_ARRAY_LENGTH.Jarkko Hietaniemi2014-05-281-2/+1
| | | | | | | | | | | | Use the C_ARRAY_LENGTH instead of sizeof(c_array)/sizeof(c_array[0]) or sizeof(c_array)/sizeof(type_of_element_in_c_array), and C_ARRAY_END for c_array + C_ARRAY_LENGTH(c_array). While doing this found potential off-by-one error in sv.c:Perl_sv_magic: how > C_ARRAY_LENGTH(PL_magic_data) should probably have been how >= C_ARRAY_LENGTH(PL_magic_data) No tests fail, but this seems to be more of an internal sanity check.
* Change av_len calls to av_tindex for clarityKarl Williamson2014-02-201-2/+2
| | | | | | av_tindex is a more clearly named synonym for av_len, available starting in v5.18. This changes the core uses to it, including modules in /ext, which are not dual-lifed.
* Added missing prototypes.Brian Fraser2014-02-051-0/+21
| | | | | This was mostly for XS functions defined in the core, but also for a handful of functions in the :stdio layer.
* universal.c: include vutil.hFather Chrysostomos2014-01-041-0/+1
| | | | Subsequent changes to vxs.inc will require it.
* Extract version routines into two new filesFather Chrysostomos2014-01-041-405/+5
| | | | | | | | | | | | | This is to make synchronisation between the CPAN distribution and the perl core easier. The files have different extensions to match what the CPAN distribu- tion will have. vutil.c is a separate compilation unit that the CPAN dist already has. vxs.inc will be included by vxs.xs (vxs.c is obvi- ously alreday taken, being generated from vxs.xs). In the perl core util.c includes vutil.c and universal.c includes vxs.inc.
* perlapi: Consistent spaces after dotsFather Chrysostomos2013-12-291-1/+1
| | | | plus some typo fixes. I probably changed some things in perlintern, too.
* Purge sfio support, which has been broken for a decade.Nicholas Clark2013-12-271-2/+2
| | | | | | | | | | | The last Perl release that built with -Dusesfio was v5.8.0, and even that failed many regression tests. Every subsequent release fails to build, and in the decade that has passed we have had no bug reports about this. So it's safe to delete all the code. The Configure related code will be purged in a subsequent commit. 2 references to sfio intentionally remain in fakesdio.h and nostdio.h, as these appear to be for using its stdio API-compatibility layer.
* Also build PerlIO_get_layers with -DusesfioNicholas Clark2013-12-271-2/+2
| | | | | | | | | | | | | This extends patch 5fef3b4a7f0c97d3 from April 2003 from fixing the stdio-only build to also fix the sfio build, which was broken when PerlIO_get_layers was added (2 commits previously, 39f7a87036eb8d13). Without this fix, perl would refuse to build with -Dusesfio. Given that 39f7a87036eb8d13 was merged to maint-5.8, this means that the -Dusesfio build was broken for v5.8.1 and later on that branch, as well as for v5.10.0 and all subsequent releases. Given that in the past 10 years, no-one has reported this, it's safe to assume that no-one considers sfio support to be important.
* Remove constant.pm-specific behaviour from Internals::SvREADONLYFather Chrysostomos2013-12-261-9/+32
| | | | | | | Some stuff on CPAN is using this undocumented function, so give constant.pm its own. It is already a core module, depending on functionality provided by the core solely for its sake; so this does not really change its relationship to the core.
* Sprinkle diag_listed_asFather Chrysostomos2013-11-171-0/+3
|
* Make the details array in universal.c staticFather Chrysostomos2013-10-241-1/+1
| | | | | Otherwise we can have linking problems when a global ‘details’ symbol is defined elsewhere. (That happened to me with an XS module.)
* isa should fall back to checking @UNIVERSAL::ISA in all casesJesse Luehrs2013-10-171-4/+8
|
* Sync core with CPAN version.pm releaseJohn Peacock2013-09-031-2/+12
| | | | | | | Remove pointless diag lines, which were more trouble than they were worth. Add code to ensure that SV's with magic are handled properly, and include a test for it as well. A couple of whitespace changes and one last set of I32 -> SSize_t upgrade for array indices.
* Use SSize_t for arraysFather Chrysostomos2013-08-251-5/+5
| | | | | | | | | | Make the array interface 64-bit safe by using SSize_t instead of I32 for array indices. This is based on a patch by Chip Salzenberg. This completes what the previous commit began when it changed av_extend.
* universal.c: Ignore SvIsCOW in XS_Internals_SvREADONLYFather Chrysostomos2013-08-111-2/+4
| | | | | | | | | | | | | | | SvIsCOW used to check SVf_READONLY|SVf_FAKE. e3918bb703ca changed that, but did not change the assumptions that code already made (that there could be not truly read-only COWs. Now SvREADONLY actually means read-only, so Internals::SvREADONLY should not be saying that read-ony COWs are not, nor does it need to flatten COWs when making them read-only. Hence, locking hash values no longer has a speed and memory hit if that hash contains COWs. Part of the code is left in place for PERL_OLD_COPY_ON_WRITE, to avoid making read-only COWs under that configuration. See the previous com- mit for why.
* Don’t let list const modification affect future retvalsFather Chrysostomos2013-08-041-0/+9
| | | | | | | | | | | In commit f99a5f08f203, I inadvertently made modifications to val- ues return by list ‘constants’ affect what values are returned sub- sequently. It’s for this type of situation that PADTMP exists (values are never referenced, but copied). So use it. This is similar to 5608dcc62, which fixed #3105.
* [perl #113932] Make UNIVERSAL::can("STDOUT"...) workFather Chrysostomos2013-07-121-0/+3
| | | | | | | For consistency with the way method lookup works, UNIVERSAL::can(...) should treat a bareword representing a filehandle as a lookup in the IO::File package (or whichever package implements that filehandle object).
* [perl #113932] UNIVERSAL::can with globs and globrefsFather Chrysostomos2013-07-081-2/+8
| | | | | | | | | | | | (Also perl #118105.) This allows *ARGV->can("print") to work as long as IO::Handle is loaded. This translates into UNIVERSAL::can(\*ARGV,"print"). This commit also changes UNIVERSAL::can to accept a plain *ARGV as well. UNIVERSAL::can("ARGV",...) is left as it is (ARGV is treated as a pack- age name), because changing that requires a bigger patch, and I don’t know when I will get to it.
* Bring core up to version-0.9902John Peacock2013-03-071-1/+1
| | | | | | | | | | | | | | The attached patch bring the core Perl version code (including a fairly significant leak when run in a tight loop) up to parity with CPAN 0.9902. This deals with all open issues except: https://rt.cpan.org/Ticket/Display.html?id=81294 which I am having a hard time modeling. John Signed-off-by: Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
* remove an EXTEND from XS_re_regexp_patternDaniel Dragan2012-11-231-4/+3
| | | | | | | | | 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.
* Hash Function Change - Murmur hash and true per process hash seedYves Orton2012-11-171-41/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* pv->pvn for literals in pp_require and Perl_sv_derived_from_pvnDaniel Dragan2012-11-121-1/+1
| | | | | | | | | I found these 2 strlens while stepping through the interp while running a script and both came from a pp_require. UNIVERSAL::can was not modified since it is more rarely called than pp_require. A better more through investigation of version obj comparison and upgrading will need to be done in the future (new funcs needed for the derived/upg_version idiom, remove the upg_version since it was changed to always be a ver obj, etc).
* add items checking to Internals::SvREFCNTDaniel Dragan2012-11-121-9/+9
| | | | | | Add item count checking to Internals::SvREFCNT in case prototype is bypassed. Getting rid of the undef saves some instructions. Reading SvREFCNT(sv) only once save an instruction.
* rmv context from Perl_croak_no_modify and Perl_croak_xs_usageDaniel Dragan2012-11-121-4/+4
| | | | | | | | | | | Remove the context/pTHX from Perl_croak_no_modify and Perl_croak_xs_usage. For croak_no_modify, it now has no parameters (and always has been no return), and on some compilers will now be optimized to a conditional jump. For Perl_croak_xs_usage one push asm opcode is removed at the caller. For both funcs, their footprint in their callers (which probably are hot code) is smaller, which means a tiny bit more room in the cache. My text section went from 0xC1A2F to 0xC198F after apply this. Also see http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195233.html .
* Move more X's off the PUSH into EXTEND'sSteffen Mueller2012-10-221-10/+13
| | | | | | | | Generally speaking, if there's branching and each branch may contain a varying number of PUSH operations, EXTENDing to the longest number of items should generally be more efficient since the stack will eventually grow to a relatively steady state, but the extra branching incurred by the X's will cost every time.
* Fix VC compilation of universal.c as C++ following commit 613875e219Steve Hay2012-10-101-1/+1
|
* add const to Perl_boot_core_UNIVERSAL's xsub registration structDaniel Dragan2012-10-091-1/+1
| | | | | | | | Move struct xsub_details details to RO memory from RW memory. This increases the amount of bytes of the image that can be shared between Perl processes by the OS. The inverse is each perl process takes less process specific memory. I saw no change in .text, .rdata went from 0x21121 to 0x21391 (+0x270), .data went from 0x3b18 to 0x38b8 (-0x260). 32 bit Visual C.
* Make utf8::decode respect set-magicFather Chrysostomos2012-10-011-0/+1
|
* Make utf8::encode respect magicFather Chrysostomos2012-10-011-0/+1
| | | | | | | | | | | | | It has always ignored set-magic, as far as I can tell. Since the magic flags patch (4bac9ae47b), it has been ignor- ing get- magic on magical scalars that were already PVs. sv_utf8_upgrade_flags_grow begins with an if(!SvPOK(sv)) check, which used to mean ‘if this scalar is magic or not a string’, but now means simply ‘if this scalar is not a string’. SvPOK_nog is the new SvPOK. Due to the way the flags now work, I had to modify sv_pvutf8n_force as well, to keep existing tests passing.
* Remove some redundant magical flag checksFather Chrysostomos2012-07-291-5/+3
| | | | | Now that gmagical svs use the OK flags the same way as muggles, things like SvPOK || (SvGMAGICAL && SvPOKp) are no longer necessary.
* also make sure ->isa works on undeclared packagesJesse Luehrs2012-06-231-0/+2
|
* all packages can do methods in UNIVERSAL [perl #47113]Jesse Luehrs2012-06-231-0/+2
| | | | | | Foo->can("can") should be true even if "package Foo" hasn't been seen yet (obviously, since that method call doesn't die with a method not found error).
* Make UNIVERSAL::can treats str and num the same wayFather Chrysostomos2012-06-071-2/+2
|
* update the editor hints for spaces, not tabsRicardo Signes2012-05-291-2/+2
| | | | | This updates the editor hints in our files for Emacs and vim to request that tabs be inserted as spaces.
* Don’t incr PL_amagic_generation in universal.cFather Chrysostomos2012-05-211-3/+0
| | | | | | | In boot_core_UNIVERSAL, there is no need to increment PL_amagic_generation to indicate that there are classes using over- loading. The previous commit removed the only use of it that required it to be non-zero for overloading to work.
* [perl #109762] Stop !$^V from leakingFather Chrysostomos2012-02-031-1/+7
| | | | by mortalising the temporary SVs.