summaryrefslogtreecommitdiff
path: root/gv.h
Commit message (Collapse)AuthorAgeFilesLines
* Reset method caches when GPs are sharedFather Chrysostomos2012-11-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new MRO stuff in 5.10 made PL_sub_generation++ mostly unnecessary, and almost all uses of it were replaced with mro_method_changed_in. There is only one problem: That doesn’t actually work properly. After glob-to-glob assignment (*foo = *bar), both globs share the same GP (glob pointer, or list of glob slots). But there is no list of GVs associated with any GP. So there is no way, given a GV whose GP is shared, to find out what other classes might need their method caches reset. sub B::b { "b" } *A::b = *B::b; @C::ISA = "A"; print C->b, "\n"; # should print "b" eval 'sub B::b { "c" }'; print C->b, "\n"; # should print "c" __END__ $ perl5.8.9 foo b c $ perl5.10.0 foo b b And it continues up to 5.16.x. If a GP is shared, then those places where mro_method_changed_in is called after the GP has been modified must do PL_sub_generation++ instead if the GP is shared, which can be detected through its refer- ence count.
* [perl #114924] Make method calls work with ::SUPER packagesFather Chrysostomos2012-09-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Perl caches SUPER methods inside packages named Foo::SUPER. But this interferes with actual method calls on those packages (SUPER->foo, foo::SUPER->foo). The first time a package is looked up, it is vivified under the name with which it is looked up. So *SUPER:: will cause that package to be called SUPER, and *main::SUPER:: will cause it to be named main::SUPER. main->SUPER::isa used to be very sensitive to the name of the main::FOO package (where the cache is kept). If it happened to be called SUPER, that call would fail. Fixing that bug (commit 3c104e59d83f) caused the CPAN module named SUPER to fail, because SUPER->foo was now being treated as a SUPER::method call. gv_fetchmeth_pvn was using the ::SUPER suffix to determine where to look for the method. The package passed to it (the ::SUPER package) was being used to look for cached methods, but the package with ::SUPER stripped off was being used for the rest of lookup. 3c104e59d83f made main->SUPER::foo work by treating SUPER as main::SUPER in that case. Mentioning *main::SUPER:: or doing a main->SUPER::foo call before loading SUPER.pm also caused it to fail, even before 3c104e59d83f. Instead of using publicly-visible packages for internal caches, we should be keeping them internal, to avoid such side effects. This commit adds a new member to the HvAUX struct, where a hash of GVs is stored, to cache super methods. I cannot simpy use a hash of CVs, because I need GvCVGEN. Using a hash of GVs allows the existing method cache code to be used. This new hash of GVs is not actually a stash, as it has no HvAUX struct (i.e., no name, no mro_meta). It doesn’t even need an @ISA entry as before (which was only used to make isa caches reset), as it shares its owner stash’s mro_meta generation numbers. In fact, the GVs inside it have their GvSTASH pointers pointing to the owner stash. In terms of memory use, it is probably the same as before. Every stash and every iterated or weakly-referenced hash is now one pointer larger than before, but every SUPER cache is smaller (no HvAUX, no *ISA + @ISA + $ISA[0] + magic). The code is a lot simpler now and uses fewer stash lookups, so it should be faster. This will break any XS code that expects the gv_fetchmeth_pvn to treat the ::SUPER suffix as magical. This behaviour was only barely docu- mented (the suffix was mentioned, but what it did was not), and is unused on CPAN.
* document some more Gv* macrosJesse Luehrs2012-06-211-0/+12
|
* 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.
* Merge multi and flags params to gv_init_*Father Chrysostomos2011-10-061-3/+5
| | | | | Since multi is a boolean (even though it’s typed as an int), there is no need to have a separate parameter. We can just use a flag bit.
* gv.c: newGVgen_flags and a flags parameter for gv_get_super_pkg.Brian Fraser2011-10-061-0/+1
|
* Remove method param from gv_autoload_*Father Chrysostomos2011-10-061-2/+7
| | | | | | | | method is a boolean flag (typed I32, but used as a boolean) added by commit 54310121b442. These new gv_autoload_* functions have a flags parameter, so there’s no reason for this extra effective bool. We can just use a flag bit.
* Remove 4 from new gv_autoload4_(sv|pvn?) functionsFather Chrysostomos2011-10-061-1/+1
| | | | | | | | | | | | The 4 was added in commit 54310121b442 (inseparable changes during 5.003/4 developement), presumably the ‘Don't look up &AUTOLOAD in @ISA when calling plain function’ part. Before that, gv_autoload had three arguments, so the 4 indicated the new version (with the method argument). Since these new functions don’t all have four arguments, and since they have a new naming convention, there is not reason for the 4.
* gv.c: Added gv_autoload4_(sv|pv|pvn)Brian Fraser2011-10-061-0/+1
|
* gv.c: Added gv_fetchmethod_(sv|pv|pvn)_flags.Brian Fraser2011-10-061-0/+1
| | | | | | In addition from taking a flags parameter, it also takes the length of the method; This will eventually make method lookup nul-clean.
* gv.c: Added gv_fetchmeth_(sv|pv|pvn)_autoload.Brian Fraser2011-10-061-1/+2
|
* Remove some _get variants of *NAMEUTF8 macros in [gh]v.hFather Chrysostomos2011-10-061-3/+2
| | | | | For macros that returns flags, the _get convention implies that there could be a _set variant some day. But we don’t do that for flags.
* gv.c: Added gv_fetchmeth_(sv|pv|pvn).Brian Fraser2011-10-061-0/+1
| | | | | I'm probably pushing this too early. Can't do the Perl-level tests because of that. TODO.
* gv.c: Added gv_init_(sv|pv|pvn), renamed gv_init_sv as gv_init_svtype.Brian Fraser2011-10-061-0/+1
| | | | | | | | | gv_init_pvn() is the same as the old gv_init(), but takes a flags parameter, which will be used for the UTF-8 cleanup. The old gv_init() is now implemeneted as a macro in gv.h. Also included is some minimal testing in XS::APItest.
* UTF-8 related macros in hv.h and gv.hBrian Fraser2011-10-061-0/+6
| | | | Groundwork for the following commits.
* Enter gv_fetchsv_nomgFather Chrysostomos2011-09-081-1/+4
| | | | | | | | | | | There are so many cases that use this incantation to get around gv_fetchsv’s calling of get-magic-- STRLEN len; const char *name = SvPV_nomg_const(sv,len); gv = gv_fetchpvn_flags(name, len, flags | SvUTF8(sv), type); --that it’s about time we had a shorthand.
* Eliminate is_gv_magical_svFather Chrysostomos2011-08-301-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This resolves perl bug #97978. Many built-in variables, like $], are actually created on the fly when first accessed. Perl likes to pretend that these variables have always existed, so it autovivifies the *] glob even in rvalue context (e.g., defined *{"]"}, close "]"). The list of variables that were autovivified was maintained separ- ately (in is_gv_magical_sv) from the code that actually creates them (gv_fetchpvn_flags). ‘Maintained’ is not actually precise: it *wasn’t* being maintained, and there were new variables that never got added to is_gv_magical_sv and one deleted variable that was never removed. There are only two pieces of code that call is_gv_magical_sv, both in pp.c: S_rv2gv (called by *{} and also the implicit *{} that functions like close() provide) and Perl_softrefxv (called by ${}, @{}, %{}). In both cases, the glob is immediately autovivified if is_gv_magical_sv returns true. So this commit eliminates the extra maintenance burden by extirpat- ing is_gv_magical_sv altogether, and replacing it with a new flag to gv_fetchpvn_flags, GvADDMG, which will autovivify a glob *if* it’s a magical one. It does make defined(*{"frobbly"}) slightly slower, in that it creates a temporary glob and then frees it when it sees nothing magical has been done with it. But this case is rare enough it should not matter. At least I got rid of the bugginess.
* Revert ‘Deprecate tie $handle without *’Father Chrysostomos2011-06-111-3/+0
| | | | | This reverts commit 7c7df8124bbdd7a0091f8ed82589548c8182f624, except for the perldiag entry, which we still need for splain’s sake.
* add GvCV_set() and GvGP_set() macros.David Mitchell2011-01-211-4/+11
| | | | | | | | and make GvCV() and GvGP() rvalue-only. This it to allow a future commit to eliminate some backref magic between GV and CVs, which will require complete control over assignment to the gp_cv slot.
* Deprecate tie $handle without *Father Chrysostomos2010-12-021-0/+3
|
* [perl #77362] Assigning glob to lvalue causes stringificationFather Chrysostomos2010-09-261-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test from t/op/gv.t was added by change 22315/4ce457a6: { # test the assignment of a GLOB to an LVALUE my $e = ''; local $SIG{__DIE__} = sub { $e = $_[0] }; my $v; sub f { $_[0] = 0; $_[0] = "a"; $_[0] = *DATA } f($v); is ($v, '*main::DATA'); my $x = <$v>; is ($x, "perl\n"); } That change was the one that made glob-to-lvalue assignment work to begin with. But this test passes in perl version *prior* to that change. This patch fixes the test and adds tests to make sure what is assigned is actually a glob, and not just a string. It also happens to fix the stringification bug. In doing so, it essen- tially ‘enables’ globs-as-PVLVs. It turns out that many different parts of the perl source don’t fully take this into account, so this patch also fixes the following to work with them (I tried to make these into separate patches, but they are so intertwined it just got too complicated): • GvIO(gv) to make readline and other I/O ops work. • Autovivification of glob slots. • tie *$pvlv • *$pvlv = undef, *$pvlv = $number, *$pvlv = $ref • Duplicating a filehandle accessed through a PVLV glob when the stringified form of the glob cannot be used to access the file handle (!) • Using a PVLV glob as a subroutine reference • Coderef assignment when the glob is no longer in the symbol table • open with a PVLV glob for the filehandle • -t and -T • Unopened file handle warnings
* fix indendation of DM_* flag definitionsDavid Mitchell2010-06-041-5/+5
|
* express DM_[GU]ID flags in terms of componentsDavid Mitchell2010-06-041-2/+2
|
* rename DM_ARRAY flag to DM_ARRAY_ISADavid Mitchell2010-06-041-1/+1
| | | | | This better represents its current role as specifically delaying magic on @ISA as opposed to a general array magic delay mechanism.
* Fix clang "incompatible operand types" error in ternary expressions.George Greer2010-05-271-1/+1
|
* PL_defoutgv isn't always a GV.David Mitchell2010-03-301-0/+1
| | | | | | | | | | | | | | | | | | | | Nasty code like the following results in PL_defoutgv not pointing to a valid GV: my $x = *STDERR; select($x); $x = 1; This causes all sorts of SEGVs when PL_defoutgv is subsequently accessed, because most code assumes that it has a valid gv_gp pointer. It also turns out that PL_defoutgv is under-tested; for example, temporarily hacking pp_close to make an arg-less close() croak didn't cause any minitest failures. Add a new test file that does some basic testing of a bad PL_defoutgv, and fix all the obvious badness in accessing it. This also fixes #20727, which although ostensibly a tie bug, was due to PL_defoutgv pointing to a tiedelem scalar, and fun like that described above happening.
* Merge gv_IOadd() into gv_add_by_type().Nicholas Clark2009-08-081-0/+1
|
* Merge gv_AVadd(), gv_HVadd() and gv_SVadd() into gv_add_by_type().Nicholas Clark2009-08-081-0/+4
| | | | The "short" names become macro wrappers, and the Perl_* versions become mathoms.
* Remove GvREFCNT_inc(), which is deprecated and unused.Nicholas Clark2009-08-071-3/+0
|
* GvUNIQUE* have been defined as 0 since 2005/06/30 - high time to remove them.Nicholas Clark2009-04-131-10/+0
|
* Add a macro MUTABLE_PTR(p), which on (non-pedantic) gcc will not castNicholas Clark2008-10-271-1/+1
| | | | | | | | | | 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
* Update copyright years.Nicholas Clark2008-10-251-2/+2
| | | p4raw-id: //depot/perl@34585
* readable assertion namesReini Urban2008-06-081-17/+17
| | | | | | From: "Reini Urban" <rurban@x-ray.at> Message-ID: <6910a60806080541n4f7e1939q254797411545ebea@mail.gmail.com> p4raw-id: //depot/perl@34029
* /* This code tries to figure out just what went wrong withNicholas Clark2008-04-171-0/+2
| | | | | | | | | | | gv_fetchmethod. It therefore needs to duplicate a lot of the internals of that function. "Duplicate". <snigger>. You said a naughty word. Now sanitised. [All tests pass, but I'm not 100% confident that this code is equivalent in all reachable corner cases, and it may be possible to simplify the error reporting logic now in gv_fetchmethod_flags] p4raw-id: //depot/perl@33702
* Deprecate (and remove core use of ) Nullav, Nullcv, Nullgv, Nullhe,Nicholas Clark2008-01-231-1/+3
| | | | | Nullhek and Nullhv. Nullop is going to be a bit less simple. p4raw-id: //depot/perl@33051
* Fix up copyright years for files modified in 2007.Nicholas Clark2007-11-071-1/+1
| | | p4raw-id: //depot/perl@32237
* Re: optimize push @ISA, (was Re: parent.pm at http://corion.net/perl-dev)Brandon Black2007-08-311-0/+1
| | | | | | From: "Brandon Black" <blblack@gmail.com> Message-ID: <84621a60708121336m13dcf9e5uac624fb246f2a79c@mail.gmail.com> p4raw-id: //depot/perl@31770
* More portability nits by JarkkoRafael Garcia-Suarez2007-06-161-1/+1
| | | p4raw-id: //depot/perl@31396
* Rearrange members of structures to reduce memory size on someNicholas Clark2007-03-311-5/+5
| | | | | | platforms. On LP64 structs stackinfo, refcounted_he, and magic shrink by 8 bytes, struct yy_parser by 16. p4raw-id: //depot/perl@30817
* Don't SEGV when dumping an undefined typeglob. The HEK used to storeNicholas Clark2007-03-011-1/+1
| | | | | the GV's name can be NULL. p4raw-id: //depot/perl@30439
* Add get_cvn_flags(), which is like get_cv() but takes a length. ThisNicholas Clark2007-01-151-0/+4
| | | | | allows symbolic code references with embeded NULs to work. p4raw-id: //depot/perl@29830
* Assert that PVGVs are never SvVALID() in the PVBM sense.Nicholas Clark2006-12-121-0/+1
| | | p4raw-id: //depot/perl@29536
* Another place where Intel C++ pretending to be gcc is a reallySteve Peters2006-05-021-1/+1
| | | | | bad thing. p4raw-id: //depot/perl@28067
* GvFILE() cannot be a pointer to the memory owned by the COP, becauseNicholas Clark2006-05-021-2/+13
| | | | | | | COPs created by use can be freed along this memory, but the GP remains. Given that several GVs may refer to the same file, use a shared string rather than an individual allocation per GP. p4raw-id: //depot/perl@28060
* use NOOP macroAndy Lester2006-04-251-2/+2
| | | | | Message-ID: <20060424184451.GA1479@petdance.com> p4raw-id: //depot/perl@27958
* Ensure GvNAME doesn't return NULLMarcus Holland-Moritz2006-04-241-3/+4
| | | | | | | First patch from : Subject: Re: [PATCH] cleanup 212 warnings emitted by gcc-4.2 Message-ID: <20060423044704.6a383ee8@r2d2> p4raw-id: //depot/perl@27944
* Random accumulated patchesAndy Lester2006-03-311-3/+2
| | | | | Message-ID: <20060331054228.GA18940@petdance.com> p4raw-id: //depot/perl@27641
* Change 27380 (HEK into the IV union failed to convert the code in theNicholas Clark2006-03-051-1/+1
| | | | | non-gcc-debugging ifdef. Whoops. Very lax of me) p4raw-id: //depot/perl@27383
* Perl_gv_name_set should not leak the old HEK. Allow the flag GV_ADDNicholas Clark2006-03-051-1/+3
| | | | | to simplify GV initialisation. p4raw-id: //depot/perl@27382
* Move the GvNAME HEK into the IV union - every GV is now 1 pointerNicholas Clark2006-03-051-1/+1
| | | | | smaller. p4raw-id: //depot/perl@27380