summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-12-25 11:25:00 +1200
committerChip Salzenberg <chip@atlantic.net>1996-12-25 11:25:00 +1200
commit7a4c00b4303a05a04564a03a88f4fa5c7a06a6e9 (patch)
treeed0b5c9815e3415ad3fb0f0239c9dbcc595f6997 /gv.c
parentb0c42ed9ba0f4415d135379bc4867084c8c23f6a (diff)
downloadperl-7a4c00b4303a05a04564a03a88f4fa5c7a06a6e9.tar.gz
[inseparable changes from patch from perl5.003_15 to perl5.003_16]
CORE PORTABILITY Subject: _13: patches for unicos/unicosmk Date: Fri, 20 Dec 1996 14:38:50 -0600 From: Dean Roehrich <roehrich@cray.com> Files: Configure MANIFEST hints/unicos.sh hints/unicosmk.sh private-msgid: <199612202038.OAA22805@poplar.cray.com> LIBRARY AND EXTENSIONS Subject: Refresh IO to 1.14 From: Graham Barr <gbarr@ti.com> Files: MANIFEST ext/IO/IO.xs ext/IO/README ext/IO/lib/IO/File.pm ext/IO/lib/IO/Handle.pm ext/IO/lib/IO/Pipe.pm ext/IO/lib/IO/Seekable.pm ext/IO/lib/IO/Select.pm ext/IO/lib/IO/Socket.pm t/lib/io_dup.t t/lib/io_pipe.t t/lib/io_sel.t t/lib/io_sock.t t/lib/io_tell.t t/lib/io_udp.t t/lib/io_xs.t OTHER CORE CHANGES Subject: Fix 'foreach(@ARGV) { while (<>) { push @p,$_ } }' From: Chip Salzenberg <chip@atlantic.net> Files: cop.h pp_hot.c scope.c Subject: Eliminate warnings from C< undef $x; $x OP= "foo" > From: Chip Salzenberg <chip@atlantic.net> Files: doop.c pp.c pp.h pp_hot.c Subject: Try again to improve method caching Date: Mon, 23 Dec 1996 20:13:56 -0500 (EST) From: Ilya Zakharevich <ilya@math.ohio-state.edu> Files: gv.c sv.c Msg-ID: <199612240113.UAA09487@monk.mps.ohio-state.edu> (applied based on p5p patch as commit 81c78688fe5c3927ad37ba29de14c86e38120317) Subject: Be more careful about 'o' magic memory management From: Chip Salzenberg <chip@atlantic.net> Files: mg.c sv.c Subject: Fix bad pointer refs when localized object loses magic From: Chip Salzenberg <chip@atlantic.net> Files: scope.c
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/gv.c b/gv.c
index fed7eca3dc..6dd8ad0f3c 100644
--- a/gv.c
+++ b/gv.c
@@ -143,19 +143,20 @@ I32 level;
if (SvTYPE(topgv) != SVt_PVGV)
gv_init(topgv, stash, name, len, TRUE);
- if (cv=GvCV(topgv)) {
- if (GvCVGEN(topgv) >= sub_generation)
- return topgv; /* valid cached inheritance */
- if (!GvCVGEN(topgv)) { /* not an inheritance cache */
- return topgv;
- }
- else {
- /* stale cached entry, just junk it */
- GvCV(topgv) = cv = 0;
- GvCVGEN(topgv) = 0;
+ if (cv = GvCV(topgv)) {
+ if (CvXSUB(cv) || CvROOT(cv) || CvGV(cv)) { /* Not deleted, possibly autoloaded. */
+ if (GvCVGEN(topgv) >= sub_generation)
+ return topgv; /* valid cached inheritance */
+ if (!GvCVGEN(topgv)) { /* not an inheritance cache */
+ return topgv;
+ }
}
+ /* stale cached entry, just junk it */
+ SvREFCNT_dec(cv);
+ GvCV(topgv) = cv = 0;
+ GvCVGEN(topgv) = 0;
}
- /* if cv is still set, we have to free it if we find something to cache */
+ /* Now cv = 0, and there is no cv in topgv. */
gvp = (GV**)hv_fetch(stash,"ISA",3,FALSE);
if (gvp && (gv = *gvp) != (GV*)&sv_undef && (av = GvAV(gv))) {
@@ -172,13 +173,9 @@ I32 level;
}
gv = gv_fetchmeth(basestash, name, len, level + 1);
if (gv) {
- if (cv) { /* junk old undef */
- assert(SvREFCNT(topgv) > 1);
- SvREFCNT_dec(topgv);
- SvREFCNT_dec(cv);
- }
GvCV(topgv) = GvCV(gv); /* cache the CV */
GvCVGEN(topgv) = sub_generation; /* valid for now */
+ SvREFCNT_inc(GvCV(gv));
return gv;
}
}
@@ -187,13 +184,9 @@ I32 level;
if (!level) {
if (lastchance = gv_stashpvn("UNIVERSAL", 9, FALSE)) {
if (gv = gv_fetchmeth(lastchance, name, len, level + 1)) {
- if (cv) { /* junk old undef */
- assert(SvREFCNT(topgv) > 1);
- SvREFCNT_dec(topgv);
- SvREFCNT_dec(cv);
- }
GvCV(topgv) = GvCV(gv); /* cache the CV */
GvCVGEN(topgv) = sub_generation; /* valid for now */
+ SvREFCNT_inc(GvCV(gv));
return gv;
}
}