summaryrefslogtreecommitdiff
path: root/pad.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-10-16 18:04:28 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-10-16 21:51:46 -0700
commit8771da69db30134352181c38401c7e50753a7ee8 (patch)
tree10c5d26ce8e3d86763deb53b5d0a1e68d860ea90 /pad.c
parent61c8799482f9e533904bfe832138c24064709f7d (diff)
downloadperl-8771da69db30134352181c38401c7e50753a7ee8.tar.gz
Used pad name lists for pad ids
I added pad IDs so that a pad could record which pad it closes over, to avoid problems with closures closing over the wrong pad, resulting in crashes or bizarre copies. These pad IDs were shared between clones of the same pad. In commit 9ef8d56, for efficiency I made clones of the same closure share the same pad name list. It has just occurred to be that each padlist containing the same pad name list also has the same pad ID, so we can just use the pad name list itself as the ID. This makes padlists 32 bits smaller and eliminates PL_pad_generation from the interpreter struct.
Diffstat (limited to 'pad.c')
-rw-r--r--pad.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pad.c b/pad.c
index 88235663dc..673f8c7329 100644
--- a/pad.c
+++ b/pad.c
@@ -280,7 +280,6 @@ Perl_pad_new(pTHX_ int flags)
padname = (PAD *)SvREFCNT_inc_simple_NN(PL_comppad_name);
}
else {
- padlist->xpadl_id = PL_padlist_generation++;
av_store(pad, 0, NULL);
padname = newAV();
}
@@ -1994,7 +1993,8 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside)
outside = CvOUTSIDE(proto);
if ((CvCLONE(outside) && ! CvCLONED(outside))
|| !CvPADLIST(outside)
- || CvPADLIST(outside)->xpadl_id != protopadlist->xpadl_outid) {
+ || PadlistNAMES(CvPADLIST(outside))
+ != protopadlist->xpadl_outid) {
outside = find_runcv_where(
FIND_RUNCV_padid_eq, (IV)protopadlist->xpadl_outid, NULL
);
@@ -2016,7 +2016,6 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside)
SAVESPTR(PL_comppad_name);
PL_comppad_name = protopad_name;
CvPADLIST(cv) = pad_new(padnew_CLONE|padnew_SAVE);
- CvPADLIST(cv)->xpadl_id = protopadlist->xpadl_id;
av_fill(PL_comppad, fpad);
@@ -2025,7 +2024,8 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside)
outpad = outside && CvPADLIST(outside)
? AvARRAY(PadlistARRAY(CvPADLIST(outside))[depth])
: NULL;
- if (outpad) CvPADLIST(cv)->xpadl_outid = CvPADLIST(outside)->xpadl_id;
+ if (outpad)
+ CvPADLIST(cv)->xpadl_outid = PadlistNAMES(CvPADLIST(outside));
for (ix = fpad; ix > 0; ix--) {
SV* const namesv = (ix <= fname) ? pname[ix] : NULL;