In perl.git, the branch smoke-me/padlist has been created
<http://perl5.git.perl.org/perl.git/commitdiff/108780ea3e4ef63e554a0cb979e2dd30f3a063ce?hp=0000000000000000000000000000000000000000>
at 108780ea3e4ef63e554a0cb979e2dd30f3a063ce (commit)
- Log -----------------------------------------------------------------
commit 108780ea3e4ef63e554a0cb979e2dd30f3a063ce
Author: Father Chrysostomos <[email protected]>
Date: Sat Aug 18 12:12:36 2012 -0700
pad.c: CvPADLIST docs: one more thing
M pad.c
commit 8294ccca0ffb35bf1e85f60ea9949293be5e7a1e
Author: Father Chrysostomos <[email protected]>
Date: Sat Aug 18 11:46:40 2012 -0700
pad.c: Use PAD_ARRAY rather than AvARRAY in curpad docs
M pad.c
commit 9a6bc3e8fbe3503734f821d02aa174def7549e25
Author: Father Chrysostomos <[email protected]>
Date: Sat Aug 18 11:38:50 2012 -0700
Use new types for comppad and comppad_name
I know that a few times Iâve looked at perl source files to find out
what type to use in â<type> foo = PL_whateverâ. So I am changing
intrpvar.h as well as the api docs.
M intrpvar.h
M pad.c
commit 90e6688b30e56bf4fb4b707d97c2ed2a60a336ae
Author: Father Chrysostomos <[email protected]>
Date: Sat Aug 18 11:36:32 2012 -0700
pad.c: CvPADLIST doc update
M pad.c
commit 662ac2917342b5e2287cc917d69ead4e3cc75299
Author: Father Chrysostomos <[email protected]>
Date: Fri Aug 17 14:21:37 2012 -0700
More PAD APIs
If we are making padlists their own type, and no longer AVs, it makes
sense to add APIs for pads, too, so that CPAN code that needs to
change now will only have to change once if we ever stop pads them-
selves from being AVs.
There is no reason pad names have to be SVs, so I am adding sep-
arate APIs for pad names, too. The AV containing pad names is
now officially a PADNAMELIST, which is accessed, not via
*PADLIST_ARRAY(padlist), but via PADLIST_NAMES(padlist).
Future optimisations may even merge the padlist with its name list so
I have also added macros to access the parts of the name list directly
from the padlist.
M ext/XS-APItest/APItest.xs
M pad.h
M perl.h
M sv.h
commit 8e178a7c9f9e909b1351007e4702d22c737bc70a
Author: Father Chrysostomos <[email protected]>
Date: Fri Aug 17 13:01:49 2012 -0700
Fix format closure bug with redefined outer sub
CVs close over their outer CVs. So, when you write:
my $x = 52;
sub foo {
sub bar {
sub baz {
$x
}
}
}
bazâs CvOUTSIDE pointer points to bar, barâs CvOUTSIDE points to foo,
and fooâs to the main cv.
When the inner reference to $x is looked up, the CvOUTSIDE chain is
followed, and each subâs pad is looked at to see if it has an $x.
(This happens at compile time.)
It can happen that bar is undefined and then redefined:
undef &bar;
eval 'sub bar { my $x = 34 }';
After this, baz will still refer to the main cvâs $x (52), but, if baz
had âeval '$x'â instead of just $x, it would see the new barâs $x.
(Itâs not really a new bar, as its refaddr is the same, but it has a
new body.)
This particular case is harmless, and is obscure enough that we could
define it any way we want, and it could still be considered correct.
The real problem happens when CVs are cloned.
When a CV is cloned, its name pad already contains the offsets into
the parent pad where the values are to be found. If the outer CV
has been undefined and redefined, those pad offsets can be com-
pletely bogus.
Normally, a CV cannot be cloned except when its outer CV is running.
And the outer CV cannot have been undefined without also throwing
away the op that would have cloned the prototype.
But formats can be cloned when the outer CV is not running. So it
is possible for cloned formats to close over bogus entries in a new
parent pad.
In this example, \$x gives us an array ref. It shows ARRAY(0xbaff1ed)
instead of SCALAR(0xdeafbee):
sub foo {
my $x;
format =
@
($x,warn \$x)[0]
.
}
undef &foo;
eval 'sub foo { my @x; write }';
foo
__END__
And if the offset that the formatâs pad closes over is beyond the end
of the parentâs new pad, we can even get a crash, as in this case:
eval
'sub foo {' .
'{my ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j,$k,$l,$m,$n,$o,$p,$q,$r,$s,$t,$u)}'x999
. q|
my $x;
format =
@
($x,warn \$x)[0]
.
}
|;
undef &foo;
eval 'sub foo { my @x; my $x = 34; write }';
foo();
__END__
So now, instead of using CvROOT to identify clones of
CvOUTSIDE(format), we use the padlist ID instead. Padlists donât
actually have an ID, so we give them one. Any time a sub is cloned,
the new padlist gets the same ID as the old. The format needs to
remember what its outer subâs padlist ID was, so we put that in the
padlist struct, too.
M embed.fnc
M embedvar.h
M intrpvar.h
M pad.c
M pad.h
M pp.c
M pp.h
M pp_ctl.c
M proto.h
M t/comp/form_scope.t
M toke.c
commit 0eef5b33684cf21277cfe258dab7b762ad17d708
Author: Father Chrysostomos <[email protected]>
Date: Thu Aug 16 16:47:38 2012 -0700
Increase $B::Xref::VERSION from 1.03 to 1.04
M ext/B/B/Xref.pm
commit b79265dd19afd0da41c9af80e065fa8a9d8d0abc
Author: Father Chrysostomos <[email protected]>
Date: Thu Aug 16 16:46:20 2012 -0700
Stop padlists from being AVs
In order to fix a bug, I need to add new fields to padlists. But I
cannot easily do that as long as they are AVs.
So I have created a new padlist struct.
This not only allows me to extend the padlist struct with new members
as necessary, but also saves memory, as we now have a three-pointer
struct where before we had a whole SV head (3-4 pointers) + XPVAV (5
pointers).
This will unfortunately break half of CPAN, but the pad API docs
clearly say this:
NOTE: this function is experimental and may change or be
removed without notice.
This would have broken B::Debug, but a patch sent upstream has already
been integrated into blead with commit 9d2d23d981.
M av.c
M dump.c
M embed.fnc
M embed.h
M ext/B/B.xs
M ext/B/B/Xref.pm
M ext/B/typemap
M ext/XS-APItest/APItest.xs
M pad.c
M pad.h
M perl.h
M proto.h
M sv.c
commit 5531463a263a3d28c788f85493ad590e95776ec8
Author: Father Chrysostomos <[email protected]>
Date: Wed Aug 15 22:27:54 2012 -0700
Use PADLIST in more places
Much code relies on the fact that PADLIST is typedeffed as AV.
PADLIST should be treated as a distinct type.
M cop.h
M dump.c
M embed.fnc
M op.c
M pad.c
M pp_ctl.c
M pp_hot.c
M pp_sort.c
M proto.h
M sv.h
commit 99daed539cbd769a9228d510c292b657dac58562
Author: Father Chrysostomos <[email protected]>
Date: Wed Aug 15 22:11:46 2012 -0700
Move PAD(LIST) typedefs to perl.h
otherwise they can only be used in some header files.
M pad.h
M perl.h
-----------------------------------------------------------------------
--
Perl5 Master Repository