summaryrefslogtreecommitdiff
path: root/universal.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* universal.c:XS_utf8_decode: rmv redundant codeFather Chrysostomos2012-01-231-1/+0
| | | | SvPV_force_nolen already calls sv_force_normal for us.
* perlop: remove triple-dotFather Chrysostomos2012-01-051-0/+1
| | | | | This has been superseded by c2f1e229, which adds it to perlsyn.
* [perl #91850] utf8::decode: croak for ro scalarsFather Chrysostomos2012-01-051-1/+1
|
* PerlIO::get_layers: Treat numbers as stringsFather Chrysostomos2011-12-251-1/+1
| | | | | | | | | | | | | | PerlIO::get_layers should not be ignoring an argument like 12, but treating "12" (the string) as a filehandle, as those are both the same value. It’s an instance of the string/num bug, which is a bit like the Unicode Bug. This commit takes the conservative approach of expanding it to flat scalars in general, but not references (in case we decide to do something interesting later on, even though I think that would be a bad idea).
* [perl #97956] PerlIO::get_layers: call get-magicFather Chrysostomos2011-12-251-7/+3
|
* Set all version object math ops to noopJohn Peacock2011-12-121-0/+9
| | | | | | | Explicitly handle all math operations with version objects as noop instead of letting Perl handle it magically with nomethod. Signed-off-by: David Golden <dagolden@cpan.org>
* Use syntax from perlguts for testing objectsJohn Peacock2011-12-091-11/+11
| | | | | | | | | | | | | The following paragraph is in perlguts.pod: To check if you've got an object derived from a specific class you have to write: if (sv_isobject(sv) && sv_derived_from(sv, class)) { ... } which does the right thing with magical things like tied scalars. Signed-off-by: David Golden <dagolden@cpan.org>
* Revert 9bf41c1d to UNIVERSAL::VERSIONJohn Peacock2011-12-091-8/+12
| | | | | | | Return the previous behavior where CLASS->VERSION will return a stringified version object of the contents of $CLASS::VERSION. Signed-off-by: David Golden <dagolden@cpan.org>
* Produce right error msg for $ver < "version"Father Chrysostomos2011-11-241-1/+1
| | | | | | | | | | | | | | "version" was being treated as a version object and then failing the validation check. It should be treated as a string, just like "versions": $ perl5.15.4 -Ilib -e '$^V < "version"' Invalid version object at -e line 1. $ perl5.15.4 -Ilib -e '$^V < "versions"' Invalid version format (dotted-decimal versions require at least three parts) at -e line 1. See also perl #102586.
* UNIVERSAL::VERSION should treat "version" as a stringFather Chrysostomos2011-11-231-2/+2
| | | | | | | | | | | | | It was treating it as a version object and then failing the validation test, instead of treating it as an invalid version format, as it does with "versions": $ ./perl -Ilib -e'$VERSION = "versions"; main->VERSION(1)' Invalid version format (dotted-decimal versions require at least three parts) at -e line 1. $ ./perl -Ilib -e'$VERSION = "version"; main->VERSION(1)' Invalid version object at -e line 1. See also perl #102586.
* Remove comment added by mistake in c7abbf64Father Chrysostomos2011-11-191-1/+1
|
* Internals::SvREFCNT() now treats reference counts as unsignedTony Cook2011-11-141-3/+3
| | | | | | Previously setting a large (negative in 32-bit signed) reference count would be returned as a positive number on 64-bit builds and negative on 32-bit builds.
* [rt #103222] make Internals::SvREFCNT set/get consistentTony Cook2011-11-141-2/+2
|
* Use HEKfFather Chrysostomos2011-10-071-12/+13
| | | | This avoids creating a lot of temporary SVs.
* universal.c: VERSION UTF8 cleanupBrian Fraser2011-10-061-27/+46
|
* universal.c: Make croak_xs_usage account for UTF8Brian Fraser2011-10-061-6/+8
|
* Document sv_does_pvnFather Chrysostomos2011-10-061-2/+9
|
* Correct name of sv_does_sv apidoc entryFather Chrysostomos2011-10-061-3/+3
| | | | plus other tweaks
* universal.c: sv_does() UTF8 cleanup.Brian Fraser2011-10-061-12/+51
| | | | | This adds _sv, _pv, and _pvn forms to sv_does, and changes it to use sv_ref() instead of sv_reftype().
* universal.c: ->can UTF8 cleanup.Brian Fraser2011-10-061-3/+1
|
* universal.c: ->isa, sv_derived_from UTF8 cleanup.Brian Fraser2011-10-061-13/+62
| | | | | | | This makes them both nul-and-UTF8 clean, although the latter is somewhat superficial, as mro isn't clean yet. (Tests coming once ->can and ->DOES are clean)
* [perl #96126] Allocate CvFILE more simplyFather Chrysostomos2011-08-171-2/+7
| | | | | | | | | | | | | | | | | | | See the thread starting at: http://www.nntp.perl.org/group/perl.perl5.porters/2011/07/msg175161.html Instead of assuming that only Perl subs have mallocked CvFILEs and only under threads, resulting in various hackery to borrow parts of the SvPVX buffer where that assumption proves wrong, we can simply add another flag (DYNFILE) to indicate whether CvFILE is mallocked, instead of trying to use the ISXSUB flag for two purposes. This simplifies the code greatly, eliminating bug #96126 in the pro- cess (which had to do with sv_dup not knowing about the hackery that this commit removes). I removed that comment from cv_ckproto_len about CONSTSUBs doubling up the buffer field, as it is no longer relevant. But I still left the code as it is, since it’s better to do an explicit length check.
* [perl #95544] Make UNIVERSAL::VERSION return $VERSIONFather Chrysostomos2011-07-271-11/+8
| | | | | | | | | | | | | | With this patch: $ ./miniperl -le ' $VERSION = "3alpha"; print "main"->VERSION' 3alpha $ ./miniperl -le ' $VERSION = "3alpha"; print "main"->VERSION(4)' Invalid version format (non-numeric data) at -e line 1. See the discussion starting at: http://www.nntp.perl.org/group/perl.perl5.porters/2011/06/msg173710.html Basically, this patch allows custom version parsers to call ->VERSION to retrieve the version, even if the default parser would choke on it.
* Make Internals::SvREADONLY smarterFather Chrysostomos2011-07-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (aka: More fun with Hash::Util) $ perl -lMHash::Util=lock_value $h{a} = __PACKAGE__; lock_value %h, a; $h{a} = "3"; print $h{a}' ^D 3 OK, so it didn’t really lock it. Now for more fun: $ perl -lMHash::Util=unlock_value $h{a} = __PACKAGE__; unlock_value %h, a; $h{a} =~ y/ia/ao/; print __PACKAGE__ ^D moan There are three different ways to fix this: 1) Add an SvFAKE function to Internals:: (not *more* ‘internals’ for people [ahem, Const::Fast, ahem] to abuse!) 2) Use B::* functions in Hash::Util to check the flags (too slow) 3) Make Internals::SvREADONLY less ‘internal’, by having it deal with readonliness in general, rather than just the SVf_READONLY flag. The third approach seems the most logical, so that’s what this commit does. There is one test in t/op/tr.t that uses Internals::SvREADONLY to detect bovinity, so I’ve changed it to use B instead, as that will have no effect on post-install efficiency. (This approach also fixes Const::Fast’s bugginess, but that is purely accidental.)
* Remove two pointless uses of sv_2mortalFather Chrysostomos2011-06-051-2/+0
| | | | | boolSV returns an immortal. When sv_2mortal is called on an immortal, it simply returns. So eliminate the call.
* 2nd try: [perl #91834] utf8::decode does not respect copy-on-writeFather Chrysostomos2011-05-291-1/+3
| | | | | | I reverted the first version of this patch because I put the if() statement before a declaration. I did a revert, rather than a correc- tion, to make back-porting easier.
* Revert "[perl #91834] utf8::decode does not respect copy-on-write"Father Chrysostomos2011-05-291-1/+0
| | | | This reverts commit 40f11004fb3b5fa1cd207a20090df837d721b736.
* [perl #91834] utf8::decode does not respect copy-on-writeFather Chrysostomos2011-05-291-0/+1
| | | | | | | | | | | | | | | | | | | | | utf8::decode was not respecting copy-on-write, but simply modify- ing the PV (the scalar’s string buffer) in place, causing problems with hashes: my $name = "\x{c3}\x{b3}"; my ($k1) = keys %{ { $name=>undef } }; my $k2 = $name; utf8::decode($k1); utf8::decode($k2); print "k1 eq k2 = '", $k1 eq $k2, "'\n"; my $h = { $k1 => 1, $k2 => 2 }; print "{k1} '", $h->{$k1}, "'\n"; print "{k2} '", $h->{$k2}, "'\n"; This example (from the RT ticket) shows that there were two hash ele- ments with the same key. As of this commit, the hash only has one element.
* [perl #90054] Fix typo in universal.cJohan Vromans2011-05-181-1/+1
| | | | At XS(XS_UNIVERSAL_DOES), invocant is spelled wrong.
* CH] Change usage of regex/op common to common namesKarl Williamson2011-01-161-1/+1
| | | | | | | | | This patch changes the core functions to use the common names for the fields that are shared between op.c and regcomp.c, just for consistency of using one name throughout the core for the same thing. A grep of cpan shows that both names are used in various modules; so both names must be retained.
* Use multi-bit field for regex character setKarl Williamson2011-01-161-8/+8
| | | | | | | | | | | | | The /d, /l, and /u regex modifiers are mutually exclusive. This patch changes the field that stores the character set to use more than one bit with an enum determining which one. This data structure more closely follows the semantics of their being mutually exclusive, and conserves bits as well, and is better expandable. A small API is added to set and query the bit field. This patch is not .xs source backwards compatible. A handful of cpan programs are affected.
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-3/+3
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>