summaryrefslogtreecommitdiff
path: root/hv.h
Commit message (Collapse)AuthorAgeFilesLines
* unify PERL_HASH and PERL_HASH_INTERNALDavid Mitchell2011-05-191-18/+10
| | | | | | | | | | | | | | | | | | Those two macros expand into two large, almost identical chunks of code. The only difference between the two is the source of the hash seed. So parameterize this into a new PERL_HASH_INTERNAL_() macro. Also, there are a couple of places in hv.c that do the rough equivalent of if (HvREHASH(hv)) key = PERL_HASH_INTERNAL(...) else key = PERL_HASH(...) which incorporates two complete macro expansions into the code. Reorganise them to be key = PERL_HASH_INTERNAL_(..., HvREHASH(hv))
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-2/+2
| | | | | | | | | # 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>
* Convert xhv_name in struct xpvhv_aux to be a union of HEK* and HEK**Nicholas Clark2010-11-241-17/+22
| | | | | This avoids a lot of casting. Nothing outside the perl core code is accessing that member directly.
* Make hv_undef leave HvENAME aloneFather Chrysostomos2010-11-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | unless called from sv_clear. This is necessary as and undeffed stash, though it nominally becomes just a plain hash and is not a stash any more, is still to be found in the symbol table. It may even be in multiple places. HvENAME’s raison d’être is to keep track of this. If the effective name is deleted, then things can get out of sync as the test in the commit demonstrates. This can cause problems if the hash is turned back into a stash. This does not change the deletion of the HvNAME, which is the only difference between hv_clear and hv_undef on stashes that is visible from Perl. caller still returns (unknown) or __ANON__::.... I tried to make this into several small commits, but each part of it breaks things without the other parts, so this is one big commit. These are the various parts: • hv_undef no longer calls mro_package_named directly, as it deletes the effective name of the stash. It must only be called on sub- stashes, so hfreeentries has been modified to do that. • hv_name_set, which has erased the HvENAME when passed a null arg for the value ever since effective names were added (a special case put it just for hv_undef), now leaves the HvENAME alone, unless the new HV_NAME_SETALL flag (set to 2 to allow for UTF8 in future) is passed. • hv_undef does not delete the name before the call to hfreeentries during global destruction. That extra name deletion was added when hfreeentries stopped hiding the name, as CVs won’t be anonymised properly if they see it. It does not matter where the CVs point if they are to be freed shortly. This is just a speed optimisation, as it allows the name and effective name to be deleted in one fell swoop. Deleting just the name (not the effective name) can require a memory allocation. • hv_undef calls mro_isa_changed_in as it used to (before it started using mro_package_moved), but now it happens after the entries are freed. Calling it first, as 5.13.6 and earlier versions did, was simply wrong. • Both names are deleted from PL_stashcache. I inadvertently switched it back and forth between the two names in previous commits. Since it needed to be accounted for, it made no omit it, as that would just complicate things. (I think PL_stashcache is buggy, though I have yet to come up with a test case.) • sv_clear now calls Perl_hv_undef_flags with the HV_NAME_SETALL flag, which is passed through to the second hv_name_set call, after hfreeentries. That determines whether the effective names are deleted. • The changes at the end of hv_undef consist of pussyfooting to avoid unnecessary work. They make sure that everything is freed that needs to be and nothing is freed that must not be.
* hv_undef .= _flagsFather Chrysostomos2010-11-201-0/+1
| | | | | | | Add flags param to hv_undef. There is no mathom, as the changes that this will support are by no means suitable for maint.
* mro_isa_changed_in3 is no longer necessaryFather Chrysostomos2010-11-111-1/+0
| | | | | | | | as of 80ebaca. It was nice while it lasted. This reverts 6f86b615fa.
* Fix memory leaks in mro_package_movedFather Chrysostomos2010-11-101-0/+1
| | | | | | | | | | | | This commit adds a new HV_FETCH_EMPTY_HE flag for hv_common. It is to be used in conjunction with HV_FETCH_LVALUE. It just stops the newly- created HE from having a new undef scalar assigned to it. This allows code to call hv_common just once instead of an hv_exists/ hv_store pair. It was such a double hv_common call that I was trying to avoid with HV_FETCH_LVALUE, without realising that it was leaking.
* Reorder struct xpvhv_aux to make two I32s adjacent.Nicholas Clark2010-11-021-1/+1
| | | | | | This avoids structure padding on architectures with 64 bit alignment for pointers. For example, on x86_64 it reduces the structure size from 48 to 40 bytes.
* Remove the #ifdef PERL_CORE surrounding the HvENAME* macrosFather Chrysostomos2010-10-291-6/+4
|
* Add HvENAME_HEKFather Chrysostomos2010-10-291-0/+2
|
* Add HvENAMEFather Chrysostomos2010-10-291-0/+9
| | | | | | Add HvENAME as an alias for HvENAME_get and make it public. This is now the preferred name for use in isa caches.
* Renaming of stashes should not be visible from PerlFather Chrysostomos2010-10-271-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | Change 35759254 made stashes get renamed when moved around. This had an unintended consequence: Typeglobs, ref() return values, stringifi- cation of blessed references and __PACKAGE__ are all affected by this. This commit makes a new distinction between stashes’ names and effect- ive names. Stash names are now unaffected when the stashes move around. Only the effective names are affected. (The apparent presence of any puns in the previous sentence is purely incidental and most likely the result of the reader’s inferential propensity.) To this end a new HvENAME_get macro is introduced, returning the first effective name (what HvNAME_get was returning). (Only one effective name needs to be in effect at a time.) hv_add_name and hv_delete_name have been renamed hv_add_ename and hv_delete_ename. hv_name_set is modified to leave the effective names in place unless the name is being set to NULL. These names are now stored in HvAUX as follows: When xhv_name_count is 0, xhv_name is a HEK pointer, containing the name which is also the effective name. When xhv_name_count is not zero, then xhv_name is a pointer to an array of HEK pointers. If xhv_name_count is positive, the first HEK is the name *and* one of the effective names. When xhv_name_count is negative, the first HEK is the name and subsequent HEKs are the effective names.
* Allow stashes to have multiple namesFather Chrysostomos2010-10-211-4/+13
| | | | | | | | | | | | | | | | | | This commits modifies the HvAUX structure as follows: A new field is added, named xhv_name_count, indicating the number of names. If it is zero (the default and most common case), then xhv_name is a HEK * as usual. If it is non-zero, then xhv_name actually holds a pointer to an array of HEK*s, the first being the default or ‘canonical’ name. This code is a little repetitious, but more refactorings are to come, so it is too soon to turn these repetitions into macros. This is yet another commit in preparation for fixing [perl #75176]. Basically, whenever a stash is deleted from its containing stash, if it has an alias elsewhere, it needs to assume the new name (of that alias; so it needs to know its other names already) and update isarev entries. Forthcoming commits will do that.
* full API for cop hint hashesZefram2010-10-211-10/+27
| | | | | | | | | | | | | Expose cop hint hashes as a type COPHH, with a cophh_* API which is a macro layer over the refcounted_he_* API. The documentation for cophh_* describes purely API-visible behaviour, whereas the refcounted_he_* documentation describes the functions mainly in terms of the implementation. Revise the cop_hints_* API, using the flags parameter consistently and reimplementing in terms of cophh_*. Use the cophh_* and cop_hints_* functions consistently where appropriate. [Modified by the committer to update two calls to Perl_refcounted_he_fetch recently added to newPMOP.]
* Allow mro_isa_changed_in to be called on nonexistent packagesFather Chrysostomos2010-10-111-0/+1
| | | | | | | | | | | | | | | | | This is necessary for an upcoming bug fix. (For this bug: @left::ISA = 'outer::inner'; @right::ISA = 'clone::inner'; *clone:: = \%outer::; print left->isa('clone::inner'),"\n"; print right->isa('outer::inner'),"\n"; ) This commit actually replaces mro_isa_changed_in with mro_isa_changed_in3. See the docs for it in the diff for mro.c.
* systematically provide pv/pvn/pvs/sv quartetsZefram2010-09-281-0/+3
| | | | | Anywhere an API function takes a string in pvn form, ensure that there are corresponding pv, pvs, and sv APIs.
* API functions for accessing the runtime hinthash.Ben Morrow2010-09-071-0/+7
| | | | | | | Add hinthash_fetch(sv|pv[ns]) as a replacement for refcounted_he_fetch, which is not API (and should not be). Also add caller_cx, as the correct XS equivalent to caller(). Lots of modules seem to have copies of this, so a proper API function will be more maintainable in future.
* Eliminate xhv_fill from struct xpvhv.Nicholas Clark2010-05-211-2/+1
|
* Make HvFILL() count the allocated buckets, instead of reading a stored value.Nicholas Clark2010-05-211-1/+1
| | | | | Add a function Perl_hv_fill to perform the count. This will save 1 IV per hash, and on some systems cause struct xpvhv to become cache aligned.
* Remove union _xivu from struct xpvhv - replace it with a non-union xav_keys.Nicholas Clark2010-05-211-3/+1
|
* In the SV body, exchange the positions of the NV and stash/magic.Nicholas Clark2010-05-211-2/+3
|
* Fix apidoc for HeUTF8()Marcus Holland-Moritz2010-02-201-1/+1
| | | | HeUTF8() onlu takes one argument.
* Eliminate *_ALLOCATED_HEAD and *_HEAD macros which are now used only once.Nicholas Clark2009-08-221-12/+3
|
* Eliminate the remaining definitions for *_allocated structs.Nicholas Clark2009-08-221-5/+0
|
* Add a key flag HVhek_KEYCANONICAL for Perl_hv_common(), which signals that theNicholas Clark2008-12-281-0/+3
| | | | | | key is in canonical form - any key passed encoded in UTF-8 cannot be represented as bytes, hence the downgrade check can be skipped. Use this internally for shared hash key scalars, as they are always canonical.
* In struct mro_meta, rename mro_linear_dfs to mro_linear_all, and change it fromNicholas Clark2008-12-271-2/+2
| | | | AV * to HV *.
* In struct mro_meta, rename mro_linear_c3 to mro_linear_current, and change itNicholas Clark2008-12-271-3/+5
| | | | from AV * to SV *.
* Proper pluggable Method Resolution Orders. 'c3' is now implemented outside theNicholas Clark2008-12-271-3/+7
| | | | | | core, in ext/mro/mro.xs. Also move mro::_nextcan() to mro.xs. It needs direct access to S_mro_get_linear_isa_c3(), and nothing on CPAN calls it, except via methods defined in mro.pm. Hence all users already require mro;
* Explictly export Perl_mro_meta_init() so that HvMROMETA() can become part of theNicholas Clark2008-12-271-1/+1
| | | | | public API and be used outside the core. However, leave Perl_mro_meta_init() as a private implementation detail.
* Add MRO_GET_PRIVATE_DATA() to use the cached mro private data where possible.Nicholas Clark2008-12-271-0/+5
|
* Repurpose struct mro_meta to allow it to store cached linear ISA for arbitaryNicholas Clark2008-12-271-0/+2
| | | | | | | method resolution orders. mro_linear_dfs becomes a hash holding the different MROs' private data. mro_linear_c3 becomes a shortcut pointer to the current MRO's private data.
* Add MUTABLE_HV(), and remove (HV *) casts from headers.Nicholas Clark2008-10-281-8/+8
| | | p4raw-id: //depot/perl@34619
* Add a macro MUTABLE_PTR(p), which on (non-pedantic) gcc will not castNicholas Clark2008-10-271-5/+5
| | | | | | | | | | away const, returning a void *. Add MUTABLE_SV(sv) which uses this, and replace all (SV *) casts either with MUTABLE_SV(sv), or (const SV *). This probably still needs some work - assigning to SvPVX() and SvRV() is now likely to generate a casting error. The core doesn't do this. But as-is it's finding bugs that can be fixed. p4raw-id: //depot/perl@34605
* Create a direct lookup hash for ->isa() lookup, by retaining theNicholas Clark2008-09-121-0/+1
| | | | | | | | | | | de-duping hash used by S_mro_get_linear_isa_dfs(). Provide a new function Perl_get_isa_hash() to lazily retrieve this. (Which could actually be static if S_isa_lookup() and Perl_sv_derived_from() moved into mro.c.) Make S_isa_lookup() use this lookup hash in place of a linear walk of the linear isa. This should turn isa lookups from O(n) to O(1), which should make heavy users of ->isa() faster. (eg PPI, and hence Perl Critic). p4raw-id: //depot/perl@34354
* metabatman fails the "this patch is self-documenting" test. RestoreNicholas Clark2008-05-201-27/+27
| | | | | (roughly) the original parameter names. p4raw-id: //depot/perl@33891
* Deprecate (and remove core use of ) Nullav, Nullcv, Nullgv, Nullhe,Nicholas Clark2008-01-231-4/+11
| | | | | Nullhek and Nullhv. Nullop is going to be a bit less simple. p4raw-id: //depot/perl@33051
* Typo fixRafael Garcia-Suarez2008-01-051-2/+2
| | | p4raw-id: //depot/perl@32860
* Missed three sv_2mortal(newSVpvn(...))s in the headers.Nicholas Clark2008-01-031-2/+2
| | | p4raw-id: //depot/perl@32820
* Add HeUTF8() to complement HePV() and then immediately suggest thatNicholas Clark2008-01-031-1/+15
| | | | | newSVhek(HeKEY_hek(he) is probably what you wanted all along. p4raw-id: //depot/perl@32812
* Change 32783 was generating warnings from gcc about an extra semicolonNicholas Clark2007-12-301-1/+1
| | | | | | in structure or union. No doubt some non-sloppy compilers will consider this an error and barf. We don't like barfing. p4raw-id: //depot/perl@32785
* factor out duplicate code in struct xpv*Marcus Holland-Moritz2007-12-301-41/+15
| | | | | Message-ID: <20071229181742.1933db40@r2d2> p4raw-id: //depot/perl@32783
* Similiarly Perl_newHV() can become a mathom by making newHV() aNicholas Clark2007-12-201-0/+10
| | | | | wrapper around newSV_type() and tweaking Perl_sv_upgrade(). p4raw-id: //depot/perl@32676
* Change the way of determining the MRO algorithm used from an enumNicholas Clark2007-09-261-5/+4
| | | | | | | | defined in the header, to a pointer to a structure. This allows the flexibility to easily add more MROs in the future, and to provide an API to do so. Dispatch in mro.c is now via the structure pointed to, rather than switch statements on the value of the enum. p4raw-id: //depot/perl@31977
* Add a new function Perl_hv_common_key_len(), which contains theNicholas Clark2007-09-201-0/+23
| | | | | | | | manipulations to convert negative lengths to positive length + UTF-8 flag. hv_delete(), hv_exists(), hv_fetch(), hv_store() and hv_store_flags() all become mathoms. The macros hv_fetchs() and hv_stores() call hv_common() directly. p4raw-id: //depot/perl@31931
* Switch Perl_hv_common() to returning void * rather than HE *.Nicholas Clark2007-09-201-3/+4
| | | p4raw-id: //depot/perl@31926
* Convert hv_delete_ent(), hv_exists_ent(), hv_fetch_ent() andNicholas Clark2007-09-201-0/+13
| | | | | | hv_store_ent() to macros, and consign the function bodies to history. Er, mathoms.c p4raw-id: //depot/perl@31924
* Send all delete()/delete_ent() calls via S_hv_fetch_common().Nicholas Clark2007-09-191-1/+1
| | | | | This puts all the key normalisation code in one place. p4raw-id: //depot/perl@31916
* For an LVALUE fetch, "hv_fetch()" will recurse into "hv_store()" for aNicholas Clark2007-09-191-5/+8
| | | | | | | | | hash with magic. Field hashes have u magic, so this recursion triggers. However, key conversion replaces the original key with the converted key, so we need to ensure that conversion happens exactly once, else for a non-idempotent key conversion routine (eg ROT13) we will see double conversion in this case. p4raw-id: //depot/perl@31898
* miscellaneaJarkko Hietaniemi2007-06-151-3/+3
| | | | | Message-ID: <4671FA51.4070001@iki.fi> p4raw-id: //depot/perl@31388
* Re: HvMROMETABrandon Black2007-05-301-3/+7
| | | | | | From: "Brandon Black" <blblack@gmail.com> Message-ID: <84621a60705291708m3f106d74r473f3d91c780163d@mail.gmail.com> p4raw-id: //depot/perl@31312