3 * Copyright (C) 2002,2003 by Larry Wall and others
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
8 * "Anyway: there was this Mr Frodo left an orphan and stranded, as you
9 * might say, among those queer Bucklanders, being brought up anyhow in
10 * Brandy Hall. A regular warren, by all accounts. Old Master Gorbadoc
11 * never had fewer than a couple of hundred relations in the place. Mr
12 * Bilbo never did a kinder deed than when he brought the lad back to
13 * live among decent folk." --the Gaffer
17 * As of Sept 2002, this file is new and may be in a state of flux for
18 * a while. I've marked things I intent to come back and look at further
19 * with an 'XXX DAPM' comment.
23 =head1 Pad Data Structures
25 =for apidoc m|AV *|CvPADLIST|CV *cv
26 CV's can have CvPADLIST(cv) set to point to an AV.
28 For these purposes "forms" are a kind-of CV, eval""s are too (except they're
29 not callable at will and are always thrown away after the eval"" is done
30 executing). Require'd files are simply evals without any outer lexical
33 XSUBs don't have CvPADLIST set - dXSTARG fetches values from PL_curpad,
34 but that is really the callers pad (a slot of which is allocated by
37 The CvPADLIST AV has does not have AvREAL set, so REFCNT of component items
38 is managed "manual" (mostly in pad.c) rather than normal av.c rules.
39 The items in the AV are not SVs as for a normal AV, but other AVs:
41 0'th Entry of the CvPADLIST is an AV which represents the "names" or rather
42 the "static type information" for lexicals.
44 The CvDEPTH'th entry of CvPADLIST AV is an AV which is the stack frame at that
45 depth of recursion into the CV.
46 The 0'th slot of a frame AV is an AV which is @_.
47 other entries are storage for variables and op targets.
50 C<PL_comppad_name> is set to the names AV.
51 C<PL_comppad> is set to the frame AV for the frame CvDEPTH == 1.
52 C<PL_curpad> is set to the body of the frame AV (i.e. AvARRAY(PL_comppad)).
54 During execution, C<PL_comppad> and C<PL_curpad> refer to the live
55 frame of the currently executing sub.
57 Iterating over the names AV iterates over all possible pad
58 items. Pad slots that are SVs_PADTMP (targets/GVs/constants) end up having
59 &PL_sv_undef "names" (see pad_alloc()).
61 Only my/our variable (SVs_PADMY/SVs_PADOUR) slots get valid names.
62 The rest are op targets/GVs/constants which are statically allocated
63 or resolved at compile time. These don't have names by which they
64 can be looked up from Perl code at run time through eval"" like
65 my/our variables can be. Since they can't be looked up by "name"
66 but only by their index allocated at compile time (which is usually
67 in PL_op->op_targ), wasting a name SV for them doesn't make sense.
69 The SVs in the names AV have their PV being the name of the variable.
70 NV+1..IV inclusive is a range of cop_seq numbers for which the name is
71 valid. For typed lexicals name SV is SVt_PVMG and SvSTASH points at the
72 type. For C<our> lexicals, the type is SVt_PVGV, and GvSTASH points at the
73 stash of the associated global (so that duplicate C<our> delarations in the
74 same package can be detected). SvCUR is sometimes hijacked to
75 store the generation number during compilation.
77 If SvFAKE is set on the name SV, then that slot in the frame AV is
78 a REFCNT'ed reference to a lexical from "outside". In this case,
79 the name SV does not use NVX and IVX to store a cop_seq range, since it is
80 in scope throughout. Instead IVX stores some flags containing info about
81 the real lexical (is it declared in an anon, and is it capable of being
82 instantiated multiple times?), and for fake ANONs, NVX contains the index
83 within the parent's pad where the lexical's value is stored, to make
86 If the 'name' is '&' the corresponding entry in frame AV
87 is a CV representing a possible closure.
88 (SvFAKE and name of '&' is not a meaningful combination currently but could
89 become so if C<my sub foo {}> is implemented.)
91 Note that formats are treated as anon subs, and are cloned each time
92 write is called (if necessary).
94 The flag SVf_PADSTALE is cleared on lexicals each time the my() is executed,
95 and set on scope exit. This allows the 'Variable $x is not available' warning
96 to be generated in evals, such as
98 { my $x = 1; sub f { eval '$x'} } f();
105 #define PERL_IN_PAD_C
109 #define PAD_MAX 999999999
116 Create a new compiling padlist, saving and updating the various global
117 vars at the same time as creating the pad itself. The following flags
118 can be OR'ed together:
120 padnew_CLONE this pad is for a cloned CV
121 padnew_SAVE save old globals
122 padnew_SAVESUB also save extra stuff for start of sub
128 Perl_pad_new(pTHX_ int flags)
130 AV *padlist, *padname, *pad, *a0;
132 ASSERT_CURPAD_LEGAL("pad_new");
134 /* XXX DAPM really need a new SAVEt_PAD which restores all or most
135 * vars (based on flags) rather than storing vals + addresses for
136 * each individually. Also see pad_block_start.
137 * XXX DAPM Try to see whether all these conditionals are required
140 /* save existing state, ... */
142 if (flags & padnew_SAVE) {
144 SAVESPTR(PL_comppad_name);
145 if (! (flags & padnew_CLONE)) {
147 SAVEI32(PL_comppad_name_fill);
148 SAVEI32(PL_min_intro_pending);
149 SAVEI32(PL_max_intro_pending);
150 SAVEI32(PL_cv_has_eval);
151 if (flags & padnew_SAVESUB) {
152 SAVEI32(PL_pad_reset_pending);
156 /* XXX DAPM interestingly, PL_comppad_name_floor never seems to be
157 * saved - check at some pt that this is okay */
159 /* ... create new pad ... */
165 if (flags & padnew_CLONE) {
166 /* XXX DAPM I dont know why cv_clone needs it
167 * doing differently yet - perhaps this separate branch can be
168 * dispensed with eventually ???
171 a0 = newAV(); /* will be @_ */
173 av_store(pad, 0, (SV*)a0);
174 AvFLAGS(a0) = AVf_REIFY;
177 av_store(pad, 0, Nullsv);
181 av_store(padlist, 0, (SV*)padname);
182 av_store(padlist, 1, (SV*)pad);
184 /* ... then update state variables */
186 PL_comppad_name = (AV*)(*av_fetch(padlist, 0, FALSE));
187 PL_comppad = (AV*)(*av_fetch(padlist, 1, FALSE));
188 PL_curpad = AvARRAY(PL_comppad);
190 if (! (flags & padnew_CLONE)) {
191 PL_comppad_name_fill = 0;
192 PL_min_intro_pending = 0;
197 DEBUG_X(PerlIO_printf(Perl_debug_log,
198 "Pad 0x%"UVxf"[0x%"UVxf"] new: compcv=0x%"UVxf
199 " name=0x%"UVxf" flags=0x%"UVxf"\n",
200 PTR2UV(PL_comppad), PTR2UV(PL_curpad), PTR2UV(PL_compcv),
201 PTR2UV(padname), (UV)flags
205 return (PADLIST*)padlist;
209 =for apidoc pad_undef
211 Free the padlist associated with a CV.
212 If parts of it happen to be current, we null the relevant
213 PL_*pad* global vars so that we don't have any dangling references left.
214 We also repoint the CvOUTSIDE of any about-to-be-orphaned
215 inner subs to the outer of this cv.
217 (This function should really be called pad_free, but the name was already
224 Perl_pad_undef(pTHX_ CV* cv)
227 PADLIST *padlist = CvPADLIST(cv);
231 if (!SvREFCNT(CvPADLIST(cv))) /* may be during global destruction */
234 DEBUG_X(PerlIO_printf(Perl_debug_log,
235 "Pad undef: cv=0x%"UVxf" padlist=0x%"UVxf"\n",
236 PTR2UV(cv), PTR2UV(padlist))
239 /* detach any '&' anon children in the pad; if afterwards they
240 * are still live, fix up their CvOUTSIDEs to point to our outside,
242 /* XXX DAPM for efficiency, we should only do this if we know we have
243 * children, or integrate this loop with general cleanup */
245 if (!PL_dirty) { /* don't bother during global destruction */
246 CV *outercv = CvOUTSIDE(cv);
247 U32 seq = CvOUTSIDE_SEQ(cv);
248 AV *comppad_name = (AV*)AvARRAY(padlist)[0];
249 SV **namepad = AvARRAY(comppad_name);
250 AV *comppad = (AV*)AvARRAY(padlist)[1];
251 SV **curpad = AvARRAY(comppad);
252 for (ix = AvFILLp(comppad_name); ix > 0; ix--) {
253 SV *namesv = namepad[ix];
254 if (namesv && namesv != &PL_sv_undef
255 && *SvPVX(namesv) == '&')
257 CV *innercv = (CV*)curpad[ix];
258 namepad[ix] = Nullsv;
259 SvREFCNT_dec(namesv);
261 SvREFCNT_dec(innercv);
262 if (SvREFCNT(innercv) /* in use, not just a prototype */
263 && CvOUTSIDE(innercv) == cv)
265 assert(CvWEAKOUTSIDE(innercv));
266 /* don't relink to grandfather if he's being freed */
267 if (outercv && SvREFCNT(outercv)) {
268 CvWEAKOUTSIDE_off(innercv);
269 CvOUTSIDE(innercv) = outercv;
270 CvOUTSIDE_SEQ(innercv) = seq;
271 SvREFCNT_inc(outercv);
274 CvOUTSIDE(innercv) = Nullcv;
283 ix = AvFILLp(padlist);
285 SV* sv = AvARRAY(padlist)[ix--];
288 if (sv == (SV*)PL_comppad_name)
289 PL_comppad_name = Nullav;
290 else if (sv == (SV*)PL_comppad) {
291 PL_comppad = Null(PAD*);
292 PL_curpad = Null(SV**);
296 SvREFCNT_dec((SV*)CvPADLIST(cv));
297 CvPADLIST(cv) = Null(PADLIST*);
304 =for apidoc pad_add_name
306 Create a new name and associated PADMY SV in the current pad; return the
308 If C<typestash> is valid, the name is for a typed lexical; set the
309 name's stash to that value.
310 If C<ourstash> is valid, it's an our lexical, set the name's
311 GvSTASH to that value
313 If fake, it means we're cloning an existing entry
319 Perl_pad_add_name(pTHX_ char *name, HV* typestash, HV* ourstash, bool fake)
321 PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY);
322 SV* namesv = NEWSV(1102, 0);
324 ASSERT_CURPAD_ACTIVE("pad_add_name");
327 sv_upgrade(namesv, ourstash ? SVt_PVGV : typestash ? SVt_PVMG : SVt_PVNV);
328 sv_setpv(namesv, name);
331 SvFLAGS(namesv) |= SVpad_TYPED;
332 SvSTASH(namesv) = (HV*)SvREFCNT_inc((SV*) typestash);
335 SvFLAGS(namesv) |= SVpad_OUR;
336 GvSTASH(namesv) = (HV*)SvREFCNT_inc((SV*) ourstash);
339 av_store(PL_comppad_name, offset, namesv);
342 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
343 "Pad addname: %ld \"%s\" FAKE\n", (long)offset, name));
346 /* not yet introduced */
347 SvNVX(namesv) = (NV)PAD_MAX; /* min */
348 SvIVX(namesv) = 0; /* max */
350 if (!PL_min_intro_pending)
351 PL_min_intro_pending = offset;
352 PL_max_intro_pending = offset;
353 /* if it's not a simple scalar, replace with an AV or HV */
354 /* XXX DAPM since slot has been allocated, replace
355 * av_store with PL_curpad[offset] ? */
357 av_store(PL_comppad, offset, (SV*)newAV());
358 else if (*name == '%')
359 av_store(PL_comppad, offset, (SV*)newHV());
360 SvPADMY_on(PL_curpad[offset]);
361 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
362 "Pad addname: %ld \"%s\" new lex=0x%"UVxf"\n",
363 (long)offset, name, PTR2UV(PL_curpad[offset])));
373 =for apidoc pad_alloc
375 Allocate a new my or tmp pad entry. For a my, simply push a null SV onto
376 the end of PL_comppad, but for a tmp, scan the pad from PL_padix upwards
377 for a slot which has no name and and no active value.
382 /* XXX DAPM integrate alloc(), add_name() and add_anon(),
383 * or at least rationalise ??? */
387 Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype)
392 ASSERT_CURPAD_ACTIVE("pad_alloc");
394 if (AvARRAY(PL_comppad) != PL_curpad)
395 Perl_croak(aTHX_ "panic: pad_alloc");
396 if (PL_pad_reset_pending)
398 if (tmptype & SVs_PADMY) {
399 sv = *av_fetch(PL_comppad, AvFILLp(PL_comppad) + 1, TRUE);
400 retval = AvFILLp(PL_comppad);
403 SV **names = AvARRAY(PL_comppad_name);
404 SSize_t names_fill = AvFILLp(PL_comppad_name);
407 * "foreach" index vars temporarily become aliases to non-"my"
408 * values. Thus we must skip, not just pad values that are
409 * marked as current pad values, but also those with names.
411 /* HVDS why copy to sv here? we don't seem to use it */
412 if (++PL_padix <= names_fill &&
413 (sv = names[PL_padix]) && sv != &PL_sv_undef)
415 sv = *av_fetch(PL_comppad, PL_padix, TRUE);
416 if (!(SvFLAGS(sv) & (SVs_PADTMP | SVs_PADMY)) &&
417 !IS_PADGV(sv) && !IS_PADCONST(sv))
422 SvFLAGS(sv) |= tmptype;
423 PL_curpad = AvARRAY(PL_comppad);
425 DEBUG_X(PerlIO_printf(Perl_debug_log,
426 "Pad 0x%"UVxf"[0x%"UVxf"] alloc: %ld for %s\n",
427 PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long) retval,
428 PL_op_name[optype]));
429 return (PADOFFSET)retval;
433 =for apidoc pad_add_anon
435 Add an anon code entry to the current compiling pad
441 Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type)
446 name = NEWSV(1106, 0);
447 sv_upgrade(name, SVt_PVNV);
448 sv_setpvn(name, "&", 1);
451 ix = pad_alloc(op_type, SVs_PADMY);
452 av_store(PL_comppad_name, ix, name);
453 /* XXX DAPM use PL_curpad[] ? */
454 av_store(PL_comppad, ix, sv);
457 /* to avoid ref loops, we never have parent + child referencing each
458 * other simultaneously */
459 if (CvOUTSIDE((CV*)sv)) {
460 assert(!CvWEAKOUTSIDE((CV*)sv));
461 CvWEAKOUTSIDE_on((CV*)sv);
462 SvREFCNT_dec(CvOUTSIDE((CV*)sv));
470 =for apidoc pad_check_dup
472 Check for duplicate declarations: report any of:
473 * a my in the current scope with the same name;
474 * an our (anywhere in the pad) with the same name and the same stash
476 C<is_our> indicates that the name to check is an 'our' declaration
481 /* XXX DAPM integrate this into pad_add_name ??? */
484 Perl_pad_check_dup(pTHX_ char *name, bool is_our, HV *ourstash)
489 ASSERT_CURPAD_ACTIVE("pad_check_dup");
490 if (!ckWARN(WARN_MISC) || AvFILLp(PL_comppad_name) < 0)
491 return; /* nothing to check */
493 svp = AvARRAY(PL_comppad_name);
494 top = AvFILLp(PL_comppad_name);
495 /* check the current scope */
496 /* XXX DAPM - why the (I32) cast - shouldn't we ensure they're the same
498 for (off = top; (I32)off > PL_comppad_name_floor; off--) {
500 && sv != &PL_sv_undef
502 && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
504 || ((SvFLAGS(sv) & SVpad_OUR) && GvSTASH(sv) == ourstash))
505 && strEQ(name, SvPVX(sv)))
507 Perl_warner(aTHX_ packWARN(WARN_MISC),
508 "\"%s\" variable %s masks earlier declaration in same %s",
509 (is_our ? "our" : "my"),
511 (SvIVX(sv) == PAD_MAX ? "scope" : "statement"));
516 /* check the rest of the pad */
520 && sv != &PL_sv_undef
522 && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
523 && ((SvFLAGS(sv) & SVpad_OUR) && GvSTASH(sv) == ourstash)
524 && strEQ(name, SvPVX(sv)))
526 Perl_warner(aTHX_ packWARN(WARN_MISC),
527 "\"our\" variable %s redeclared", name);
528 Perl_warner(aTHX_ packWARN(WARN_MISC),
529 "\t(Did you mean \"local\" instead of \"our\"?)\n");
532 } while ( off-- > 0 );
538 =for apidoc pad_findmy
540 Given a lexical name, try to find its offset, first in the current pad,
541 or failing that, in the pads of any lexically enclosing subs (including
542 the complications introduced by eval). If the name is found in an outer pad,
543 then a fake entry is added to the current pad.
544 Returns the offset in the current pad, or NOT_IN_PAD on failure.
550 Perl_pad_findmy(pTHX_ char *name)
558 offset = pad_findlex(name, PL_compcv, PL_cop_seqmax, 1,
559 Null(SV**), &out_sv, &out_flags);
560 if (offset != NOT_IN_PAD)
563 /* look for an our that's being introduced; this allows
564 * our $foo = 0 unless defined $foo;
565 * to not give a warning. (Yes, this is a hack) */
567 nameav = (AV*)AvARRAY(CvPADLIST(PL_compcv))[0];
568 name_svp = AvARRAY(nameav);
569 for (offset = AvFILLp(nameav); offset > 0; offset--) {
570 SV *namesv = name_svp[offset];
571 if (namesv && namesv != &PL_sv_undef
573 && (SvFLAGS(namesv) & SVpad_OUR)
574 && strEQ(SvPVX(namesv), name)
575 && U_32(SvNVX(namesv)) == PAD_MAX /* min */
584 =for apidoc pad_findlex
586 Find a named lexical anywhere in a chain of nested pads. Add fake entries
587 in the inner pads if it's found in an outer one.
589 Returns the offset in the bottom pad of the lex or the fake lex.
590 cv is the CV in which to start the search, and seq is the current cop_seq
591 to match against. If warn is true, print appropriate warnings. The out_*
592 vars return values, and so are pointers to where the returned values
593 should be stored. out_capture, if non-null, requests that the innermost
594 instance of the lexical is captured; out_name_sv is set to the innermost
595 matched namesv or fake namesv; out_flags returns the flags normally
596 associated with the IVX field of a fake namesv.
598 Note that pad_findlex() is recursive; it recurses up the chain of CVs,
599 then comes back down, adding fake entries as it goes. It has to be this way
600 because fake namesvs in anon protoypes have to store in NVX the index into
606 /* Flags set in the SvIVX field of FAKE namesvs */
608 #define PAD_FAKELEX_ANON 1 /* the lex is declared in an ANON, or ... */
609 #define PAD_FAKELEX_MULTI 2 /* the lex can be instantiated multiple times */
611 /* the CV has finished being compiled. This is not a sufficient test for
612 * all CVs (eg XSUBs), but suffices for the CVs found in a lexical chain */
613 #define CvCOMPILED(cv) CvROOT(cv)
615 /* the CV does late binding of its lexicals */
616 #define CvLATE(cv) (CvANON(cv) || SvTYPE(cv) == SVt_PVFM)
620 S_pad_findlex(pTHX_ char *name, CV* cv, U32 seq, int warn,
621 SV** out_capture, SV** out_name_sv, int *out_flags)
623 I32 offset, new_offset;
626 AV *padlist = CvPADLIST(cv);
630 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
631 "Pad findlex cv=0x%"UVxf" searching \"%s\" seq=%d%s\n",
632 PTR2UV(cv), name, (int)seq, out_capture ? " capturing" : "" ));
634 /* first, search this pad */
636 if (padlist) { /* not an undef CV */
638 AV *nameav = (AV*)AvARRAY(padlist)[0];
639 SV **name_svp = AvARRAY(nameav);
641 for (offset = AvFILLp(nameav); offset > 0; offset--) {
642 SV *namesv = name_svp[offset];
643 if (namesv && namesv != &PL_sv_undef
644 && strEQ(SvPVX(namesv), name))
647 fake_offset = offset; /* in case we don't find a real one */
648 else if ( seq > U_32(SvNVX(namesv)) /* min */
649 && seq <= (U32)SvIVX(namesv)) /* max */
654 if (offset > 0 || fake_offset > 0 ) { /* a match! */
655 if (offset > 0) { /* not fake */
657 *out_name_sv = name_svp[offset]; /* return the namesv */
659 /* set PAD_FAKELEX_MULTI if this lex can have multiple
660 * instances. For now, we just test !CvUNIQUE(cv), but
661 * ideally, we should detect my's declared within loops
662 * etc - this would allow a wider range of 'not stayed
663 * shared' warnings. We also treated alreadly-compiled
664 * lexes as not multi as viewed from evals. */
666 *out_flags = CvANON(cv) ?
668 (!CvUNIQUE(cv) && ! CvCOMPILED(cv))
669 ? PAD_FAKELEX_MULTI : 0;
671 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
672 "Pad findlex cv=0x%"UVxf" matched: offset=%ld (%ld,%ld)\n",
673 PTR2UV(cv), (long)offset, (long)U_32(SvNVX(*out_name_sv)),
674 (long)SvIVX(*out_name_sv)));
676 else { /* fake match */
677 offset = fake_offset;
678 *out_name_sv = name_svp[offset]; /* return the namesv */
679 *out_flags = SvIVX(*out_name_sv);
680 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
681 "Pad findlex cv=0x%"UVxf" matched: offset=%ld flags=0x%lx index=%lu\n",
682 PTR2UV(cv), (long)offset, (unsigned long)*out_flags,
683 (unsigned long)SvNVX(*out_name_sv)
687 /* return the lex? */
692 if ((SvFLAGS(*out_name_sv) & SVpad_OUR)) {
693 *out_capture = Nullsv;
697 /* trying to capture from an anon prototype? */
699 ? CvANON(cv) && CvCLONE(cv) && !CvCLONED(cv)
700 : *out_flags & PAD_FAKELEX_ANON)
702 if (warn && ckWARN(WARN_CLOSURE))
703 Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
704 "Variable \"%s\" is not available", name);
705 *out_capture = Nullsv;
711 if (!CvCOMPILED(cv) && (*out_flags & PAD_FAKELEX_MULTI)
712 && warn && ckWARN(WARN_CLOSURE)) {
714 Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
715 "Variable \"%s\" will not stay shared", name);
718 if (fake_offset && CvANON(cv)
719 && CvCLONE(cv) &&!CvCLONED(cv))
722 /* not yet caught - look further up */
723 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
724 "Pad findlex cv=0x%"UVxf" chasing lex in outer pad\n",
727 pad_findlex(name, CvOUTSIDE(cv), CvOUTSIDE_SEQ(cv),
728 newwarn, out_capture, out_name_sv, out_flags);
733 *out_capture = AvARRAY((AV*)AvARRAY(padlist)[
734 CvDEPTH(cv) ? CvDEPTH(cv) : 1])[offset];
735 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
736 "Pad findlex cv=0x%"UVxf" found lex=0x%"UVxf"\n",
737 PTR2UV(cv), PTR2UV(*out_capture)));
739 if (SvPADSTALE(*out_capture)) {
740 if (ckWARN(WARN_CLOSURE))
741 Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
742 "Variable \"%s\" is not available", name);
743 *out_capture = Nullsv;
748 *out_capture = sv_2mortal((SV*)newAV());
749 else if (*name == '%')
750 *out_capture = sv_2mortal((SV*)newHV());
752 *out_capture = sv_newmortal();
760 /* it's not in this pad - try above */
765 /* out_capture non-null means caller wants us to capture lex; in
766 * addition we capture ourselves unless it's an ANON/format */
767 new_capturep = out_capture ? out_capture :
768 CvLATE(cv) ? Null(SV**) : &new_capture;
770 offset = pad_findlex(name, CvOUTSIDE(cv), CvOUTSIDE_SEQ(cv), 1,
771 new_capturep, out_name_sv, out_flags);
772 if (offset == NOT_IN_PAD)
775 /* found in an outer CV. Add appropriate fake entry to this pad */
777 /* don't add new fake entries (via eval) to CVs that we have already
778 * finished compiling, or to undef CVs */
779 if (CvCOMPILED(cv) || !padlist)
780 return 0; /* this dummy (and invalid) value isnt used by the caller */
784 AV *ocomppad_name = PL_comppad_name;
785 PAD *ocomppad = PL_comppad;
786 PL_comppad_name = (AV*)AvARRAY(padlist)[0];
787 PL_comppad = (AV*)AvARRAY(padlist)[1];
788 PL_curpad = AvARRAY(PL_comppad);
790 new_offset = pad_add_name(
792 (SvFLAGS(*out_name_sv) & SVpad_TYPED)
793 ? SvSTASH(*out_name_sv) : Nullhv,
794 (SvFLAGS(*out_name_sv) & SVpad_OUR)
795 ? GvSTASH(*out_name_sv) : Nullhv,
799 new_namesv = AvARRAY(PL_comppad_name)[new_offset];
800 SvIVX(new_namesv) = *out_flags;
802 SvNVX(new_namesv) = (NV)0;
803 if (SvFLAGS(new_namesv) & SVpad_OUR) {
806 else if (CvLATE(cv)) {
807 /* delayed creation - just note the offset within parent pad */
808 SvNVX(new_namesv) = (NV)offset;
812 /* immediate creation - capture outer value right now */
813 av_store(PL_comppad, new_offset, SvREFCNT_inc(*new_capturep));
814 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
815 "Pad findlex cv=0x%"UVxf" saved captured sv 0x%"UVxf" at offset %ld\n",
816 PTR2UV(cv), PTR2UV(*new_capturep), (long)new_offset));
818 *out_name_sv = new_namesv;
819 *out_flags = SvIVX(new_namesv);
821 PL_comppad_name = ocomppad_name;
822 PL_comppad = ocomppad;
823 PL_curpad = ocomppad ? AvARRAY(ocomppad) : Null(SV **);
832 Get the value at offset po in the current pad.
833 Use macro PAD_SV instead of calling this function directly.
840 Perl_pad_sv(pTHX_ PADOFFSET po)
842 ASSERT_CURPAD_ACTIVE("pad_sv");
845 Perl_croak(aTHX_ "panic: pad_sv po");
846 DEBUG_X(PerlIO_printf(Perl_debug_log,
847 "Pad 0x%"UVxf"[0x%"UVxf"] sv: %ld sv=0x%"UVxf"\n",
848 PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po, PTR2UV(PL_curpad[po]))
850 return PL_curpad[po];
855 =for apidoc pad_setsv
857 Set the entry at offset po in the current pad to sv.
858 Use the macro PAD_SETSV() rather than calling this function directly.
865 Perl_pad_setsv(pTHX_ PADOFFSET po, SV* sv)
867 ASSERT_CURPAD_ACTIVE("pad_setsv");
869 DEBUG_X(PerlIO_printf(Perl_debug_log,
870 "Pad 0x%"UVxf"[0x%"UVxf"] setsv: %ld sv=0x%"UVxf"\n",
871 PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po, PTR2UV(sv))
880 =for apidoc pad_block_start
882 Update the pad compilation state variables on entry to a new block
888 * - integrate this in general state-saving routine ???
889 * - combine with the state-saving going on in pad_new ???
890 * - introduce a new SAVE type that does all this in one go ?
894 Perl_pad_block_start(pTHX_ int full)
896 ASSERT_CURPAD_ACTIVE("pad_block_start");
897 SAVEI32(PL_comppad_name_floor);
898 PL_comppad_name_floor = AvFILLp(PL_comppad_name);
900 PL_comppad_name_fill = PL_comppad_name_floor;
901 if (PL_comppad_name_floor < 0)
902 PL_comppad_name_floor = 0;
903 SAVEI32(PL_min_intro_pending);
904 SAVEI32(PL_max_intro_pending);
905 PL_min_intro_pending = 0;
906 SAVEI32(PL_comppad_name_fill);
907 SAVEI32(PL_padix_floor);
908 PL_padix_floor = PL_padix;
909 PL_pad_reset_pending = FALSE;
916 "Introduce" my variables to visible status.
928 ASSERT_CURPAD_ACTIVE("intro_my");
929 if (! PL_min_intro_pending)
930 return PL_cop_seqmax;
932 svp = AvARRAY(PL_comppad_name);
933 for (i = PL_min_intro_pending; i <= PL_max_intro_pending; i++) {
934 if ((sv = svp[i]) && sv != &PL_sv_undef
935 && !SvFAKE(sv) && !SvIVX(sv))
937 SvIVX(sv) = PAD_MAX; /* Don't know scope end yet. */
938 SvNVX(sv) = (NV)PL_cop_seqmax;
939 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
940 "Pad intromy: %ld \"%s\", (%ld,%ld)\n",
942 (long)U_32(SvNVX(sv)), (long)SvIVX(sv))
946 PL_min_intro_pending = 0;
947 PL_comppad_name_fill = PL_max_intro_pending; /* Needn't search higher */
948 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
949 "Pad intromy: seq -> %ld\n", (long)(PL_cop_seqmax+1)));
951 return PL_cop_seqmax++;
955 =for apidoc pad_leavemy
957 Cleanup at end of scope during compilation: set the max seq number for
958 lexicals in this scope and warn of any lexicals that never got introduced.
964 Perl_pad_leavemy(pTHX)
967 SV **svp = AvARRAY(PL_comppad_name);
970 PL_pad_reset_pending = FALSE;
972 ASSERT_CURPAD_ACTIVE("pad_leavemy");
973 if (PL_min_intro_pending && PL_comppad_name_fill < PL_min_intro_pending) {
974 for (off = PL_max_intro_pending; off >= PL_min_intro_pending; off--) {
975 if ((sv = svp[off]) && sv != &PL_sv_undef
976 && !SvFAKE(sv) && ckWARN_d(WARN_INTERNAL))
977 Perl_warner(aTHX_ packWARN(WARN_INTERNAL),
978 "%"SVf" never introduced", sv);
981 /* "Deintroduce" my variables that are leaving with this scope. */
982 for (off = AvFILLp(PL_comppad_name); off > PL_comppad_name_fill; off--) {
983 if ((sv = svp[off]) && sv != &PL_sv_undef
984 && !SvFAKE(sv) && SvIVX(sv) == PAD_MAX)
986 SvIVX(sv) = PL_cop_seqmax;
987 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
988 "Pad leavemy: %ld \"%s\", (%ld,%ld)\n",
989 (long)off, SvPVX(sv),
990 (long)U_32(SvNVX(sv)), (long)SvIVX(sv))
995 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
996 "Pad leavemy: seq = %ld\n", (long)PL_cop_seqmax));
1001 =for apidoc pad_swipe
1003 Abandon the tmp in the current pad at offset po and replace with a
1010 Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust)
1012 ASSERT_CURPAD_LEGAL("pad_swipe");
1015 if (AvARRAY(PL_comppad) != PL_curpad)
1016 Perl_croak(aTHX_ "panic: pad_swipe curpad");
1018 Perl_croak(aTHX_ "panic: pad_swipe po");
1020 DEBUG_X(PerlIO_printf(Perl_debug_log,
1021 "Pad 0x%"UVxf"[0x%"UVxf"] swipe: %ld\n",
1022 PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po));
1025 SvPADTMP_off(PL_curpad[po]);
1027 SvREFCNT_dec(PL_curpad[po]);
1029 PL_curpad[po] = NEWSV(1107,0);
1030 SvPADTMP_on(PL_curpad[po]);
1031 if ((I32)po < PL_padix)
1037 =for apidoc pad_reset
1039 Mark all the current temporaries for reuse
1044 /* XXX pad_reset() is currently disabled because it results in serious bugs.
1045 * It causes pad temp TARGs to be shared between OPs. Since TARGs are pushed
1046 * on the stack by OPs that use them, there are several ways to get an alias
1047 * to a shared TARG. Such an alias will change randomly and unpredictably.
1048 * We avoid doing this until we can think of a Better Way.
1051 Perl_pad_reset(pTHX)
1053 #ifdef USE_BROKEN_PAD_RESET
1056 if (AvARRAY(PL_comppad) != PL_curpad)
1057 Perl_croak(aTHX_ "panic: pad_reset curpad");
1059 DEBUG_X(PerlIO_printf(Perl_debug_log,
1060 "Pad 0x%"UVxf"[0x%"UVxf"] reset: padix %ld -> %ld",
1061 PTR2UV(PL_comppad), PTR2UV(PL_curpad),
1062 (long)PL_padix, (long)PL_padix_floor
1066 if (!PL_tainting) { /* Can't mix tainted and non-tainted temporaries. */
1067 for (po = AvMAX(PL_comppad); po > PL_padix_floor; po--) {
1068 if (PL_curpad[po] && !SvIMMORTAL(PL_curpad[po]))
1069 SvPADTMP_off(PL_curpad[po]);
1071 PL_padix = PL_padix_floor;
1074 PL_pad_reset_pending = FALSE;
1079 =for apidoc pad_tidy
1081 Tidy up a pad after we've finished compiling it:
1082 * remove most stuff from the pads of anonsub prototypes;
1084 * mark tmps as such.
1089 /* XXX DAPM surely most of this stuff should be done properly
1090 * at the right time beforehand, rather than going around afterwards
1091 * cleaning up our mistakes ???
1095 Perl_pad_tidy(pTHX_ padtidy_type type)
1100 ASSERT_CURPAD_ACTIVE("pad_tidy");
1102 /* If this CV has had any 'eval-capable' ops planted in it
1103 * (ie it contains eval '...', //ee, /$var/ or /(?{..})/), Then any
1104 * anon prototypes in the chain of CVs should be marked as cloneable,
1105 * so that for example the eval's CV in C<< sub { eval '$x' } >> gets
1106 * the right CvOUTSIDE.
1107 * If running with -d, *any* sub may potentially have an eval
1108 * excuted within it.
1111 if (PL_cv_has_eval || PL_perldb) {
1112 for (cv = PL_compcv ;cv; cv = CvOUTSIDE(cv)) {
1113 if (cv != PL_compcv && CvCOMPILED(cv))
1114 break; /* no need to mark already-compiled code */
1116 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
1117 "Pad clone on cv=0x%"UVxf"\n", PTR2UV(cv)));
1123 /* extend curpad to match namepad */
1124 if (AvFILLp(PL_comppad_name) < AvFILLp(PL_comppad))
1125 av_store(PL_comppad_name, AvFILLp(PL_comppad), Nullsv);
1127 if (type == padtidy_SUBCLONE) {
1128 SV **namep = AvARRAY(PL_comppad_name);
1130 for (ix = AvFILLp(PL_comppad); ix > 0; ix--) {
1133 if (SvIMMORTAL(PL_curpad[ix]) || IS_PADGV(PL_curpad[ix]) || IS_PADCONST(PL_curpad[ix]))
1136 * The only things that a clonable function needs in its
1137 * pad are anonymous subs.
1138 * The rest are created anew during cloning.
1140 if (!((namesv = namep[ix]) != Nullsv &&
1141 namesv != &PL_sv_undef &&
1142 *SvPVX(namesv) == '&'))
1144 SvREFCNT_dec(PL_curpad[ix]);
1145 PL_curpad[ix] = Nullsv;
1149 else if (type == padtidy_SUB) {
1150 /* XXX DAPM this same bit of code keeps appearing !!! Rationalise? */
1151 AV *av = newAV(); /* Will be @_ */
1153 av_store(PL_comppad, 0, (SV*)av);
1154 AvFLAGS(av) = AVf_REIFY;
1157 /* XXX DAPM rationalise these two similar branches */
1159 if (type == padtidy_SUB) {
1160 for (ix = AvFILLp(PL_comppad); ix > 0; ix--) {
1161 if (SvIMMORTAL(PL_curpad[ix]) || IS_PADGV(PL_curpad[ix]) || IS_PADCONST(PL_curpad[ix]))
1163 if (!SvPADMY(PL_curpad[ix]))
1164 SvPADTMP_on(PL_curpad[ix]);
1167 else if (type == padtidy_FORMAT) {
1168 for (ix = AvFILLp(PL_comppad); ix > 0; ix--) {
1169 if (!SvPADMY(PL_curpad[ix]) && !SvIMMORTAL(PL_curpad[ix]))
1170 SvPADTMP_on(PL_curpad[ix]);
1173 PL_curpad = AvARRAY(PL_comppad);
1178 =for apidoc pad_free
1180 Free the SV at offet po in the current pad.
1185 /* XXX DAPM integrate with pad_swipe ???? */
1187 Perl_pad_free(pTHX_ PADOFFSET po)
1189 ASSERT_CURPAD_LEGAL("pad_free");
1192 if (AvARRAY(PL_comppad) != PL_curpad)
1193 Perl_croak(aTHX_ "panic: pad_free curpad");
1195 Perl_croak(aTHX_ "panic: pad_free po");
1197 DEBUG_X(PerlIO_printf(Perl_debug_log,
1198 "Pad 0x%"UVxf"[0x%"UVxf"] free: %ld\n",
1199 PTR2UV(PL_comppad), PTR2UV(PL_curpad), (long)po)
1202 if (PL_curpad[po] && PL_curpad[po] != &PL_sv_undef) {
1203 SvPADTMP_off(PL_curpad[po]);
1205 /* SV could be a shared hash key (eg bugid #19022) */
1207 #ifdef PERL_COPY_ON_WRITE
1208 !SvIsCOW(PL_curpad[po])
1210 !SvFAKE(PL_curpad[po])
1213 SvREADONLY_off(PL_curpad[po]); /* could be a freed constant */
1216 if ((I32)po < PL_padix)
1223 =for apidoc do_dump_pad
1225 Dump the contents of a padlist
1231 Perl_do_dump_pad(pTHX_ I32 level, PerlIO *file, PADLIST *padlist, int full)
1243 pad_name = (AV*)*av_fetch((AV*)padlist, 0, FALSE);
1244 pad = (AV*)*av_fetch((AV*)padlist, 1, FALSE);
1245 pname = AvARRAY(pad_name);
1246 ppad = AvARRAY(pad);
1247 Perl_dump_indent(aTHX_ level, file,
1248 "PADNAME = 0x%"UVxf"(0x%"UVxf") PAD = 0x%"UVxf"(0x%"UVxf")\n",
1249 PTR2UV(pad_name), PTR2UV(pname), PTR2UV(pad), PTR2UV(ppad)
1252 for (ix = 1; ix <= AvFILLp(pad_name); ix++) {
1254 if (namesv && namesv == &PL_sv_undef) {
1259 Perl_dump_indent(aTHX_ level+1, file,
1260 "%2d. 0x%"UVxf"<%lu> FAKE \"%s\" flags=0x%x index=%lu\n",
1263 (unsigned long) (ppad[ix] ? SvREFCNT(ppad[ix]) : 0),
1265 (unsigned long)SvIVX(namesv),
1266 (unsigned long)SvNVX(namesv)
1270 Perl_dump_indent(aTHX_ level+1, file,
1271 "%2d. 0x%"UVxf"<%lu> (%ld,%ld) \"%s\"\n",
1274 (unsigned long) (ppad[ix] ? SvREFCNT(ppad[ix]) : 0),
1275 (long)U_32(SvNVX(namesv)),
1276 (long)SvIVX(namesv),
1281 Perl_dump_indent(aTHX_ level+1, file,
1282 "%2d. 0x%"UVxf"<%lu>\n",
1285 (unsigned long) (ppad[ix] ? SvREFCNT(ppad[ix]) : 0)
1296 dump the contents of a CV
1303 S_cv_dump(pTHX_ CV *cv, char *title)
1305 CV *outside = CvOUTSIDE(cv);
1306 AV* padlist = CvPADLIST(cv);
1308 PerlIO_printf(Perl_debug_log,
1309 " %s: CV=0x%"UVxf" (%s), OUTSIDE=0x%"UVxf" (%s)\n",
1312 (CvANON(cv) ? "ANON"
1313 : (SvTYPE(cv) == SVt_PVFM) ? "FORMAT"
1314 : (cv == PL_main_cv) ? "MAIN"
1315 : CvUNIQUE(cv) ? "UNIQUE"
1316 : CvGV(cv) ? GvNAME(CvGV(cv)) : "UNDEFINED"),
1319 : CvANON(outside) ? "ANON"
1320 : (outside == PL_main_cv) ? "MAIN"
1321 : CvUNIQUE(outside) ? "UNIQUE"
1322 : CvGV(outside) ? GvNAME(CvGV(outside)) : "UNDEFINED"));
1324 PerlIO_printf(Perl_debug_log,
1325 " PADLIST = 0x%"UVxf"\n", PTR2UV(padlist));
1326 do_dump_pad(1, Perl_debug_log, padlist, 1);
1328 #endif /* DEBUGGING */
1335 =for apidoc cv_clone
1337 Clone a CV: make a new CV which points to the same code etc, but which
1338 has a newly-created pad built by copying the prototype pad and capturing
1345 Perl_cv_clone(pTHX_ CV *proto)
1348 AV* protopadlist = CvPADLIST(proto);
1349 AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE);
1350 AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE);
1351 SV** pname = AvARRAY(protopad_name);
1352 SV** ppad = AvARRAY(protopad);
1353 I32 fname = AvFILLp(protopad_name);
1354 I32 fpad = AvFILLp(protopad);
1361 assert(!CvUNIQUE(proto));
1363 /* Since cloneable anon subs can be nested, CvOUTSIDE may point
1364 * to a prototype; we instead want the cloned parent who called us.
1365 * Note that in general for formats, CvOUTSIDE != find_runcv */
1367 outside = CvOUTSIDE(proto);
1368 if (outside && CvCLONE(outside) && ! CvCLONED(outside))
1369 outside = find_runcv(NULL);
1370 depth = CvDEPTH(outside);
1371 assert(depth || SvTYPE(proto) == SVt_PVFM);
1374 assert(CvPADLIST(outside));
1377 SAVESPTR(PL_compcv);
1379 cv = PL_compcv = (CV*)NEWSV(1104, 0);
1380 sv_upgrade((SV *)cv, SvTYPE(proto));
1381 CvFLAGS(cv) = CvFLAGS(proto) & ~(CVf_CLONE|CVf_WEAKOUTSIDE);
1385 CvFILE(cv) = CvXSUB(proto) ? CvFILE(proto)
1386 : savepv(CvFILE(proto));
1388 CvFILE(cv) = CvFILE(proto);
1390 CvGV(cv) = CvGV(proto);
1391 CvSTASH(cv) = CvSTASH(proto);
1392 CvROOT(cv) = OpREFCNT_inc(CvROOT(proto));
1393 CvSTART(cv) = CvSTART(proto);
1394 CvOUTSIDE(cv) = (CV*)SvREFCNT_inc(outside);
1395 CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(proto);
1398 sv_setpvn((SV*)cv, SvPVX(proto), SvCUR(proto));
1400 CvPADLIST(cv) = comppadlist = pad_new(padnew_CLONE|padnew_SAVE);
1402 av_fill(PL_comppad, fpad);
1403 for (ix = fname; ix >= 0; ix--)
1404 av_store(PL_comppad_name, ix, SvREFCNT_inc(pname[ix]));
1406 PL_curpad = AvARRAY(PL_comppad);
1408 outpad = AvARRAY(AvARRAY(CvPADLIST(outside))[depth]);
1410 for (ix = fpad; ix > 0; ix--) {
1411 SV* namesv = (ix <= fname) ? pname[ix] : Nullsv;
1413 if (namesv && namesv != &PL_sv_undef) { /* lexical */
1414 if (SvFAKE(namesv)) { /* lexical from outside? */
1415 sv = outpad[(I32)SvNVX(namesv)];
1417 /* formats may have an inactive parent */
1418 if (SvTYPE(proto) == SVt_PVFM && SvPADSTALE(sv)) {
1419 if (ckWARN(WARN_CLOSURE))
1420 Perl_warner(aTHX_ packWARN(WARN_CLOSURE),
1421 "Variable \"%s\" is not available", SvPVX(namesv));
1425 assert(!SvPADSTALE(sv));
1426 sv = SvREFCNT_inc(sv);
1430 char *name = SvPVX(namesv);
1432 sv = SvREFCNT_inc(ppad[ix]);
1433 else if (*name == '@')
1435 else if (*name == '%')
1442 else if (IS_PADGV(ppad[ix]) || IS_PADCONST(ppad[ix])) {
1443 sv = SvREFCNT_inc(ppad[ix]);
1453 PerlIO_printf(Perl_debug_log, "\nPad CV clone\n");
1454 cv_dump(outside, "Outside");
1455 cv_dump(proto, "Proto");
1462 /* Constant sub () { $x } closing over $x - see lib/constant.pm:
1463 * The prototype was marked as a candiate for const-ization,
1464 * so try to grab the current const value, and if successful,
1465 * turn into a const sub:
1467 SV* const_sv = op_const_sv(CvSTART(cv), cv);
1470 cv = newCONSTSUB(CvSTASH(proto), 0, const_sv);
1482 =for apidoc pad_fixup_inner_anons
1484 For any anon CVs in the pad, change CvOUTSIDE of that CV from
1485 old_cv to new_cv if necessary. Needed when a newly-compiled CV has to be
1486 moved to a pre-existing CV struct.
1492 Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv)
1495 AV *comppad_name = (AV*)AvARRAY(padlist)[0];
1496 AV *comppad = (AV*)AvARRAY(padlist)[1];
1497 SV **namepad = AvARRAY(comppad_name);
1498 SV **curpad = AvARRAY(comppad);
1499 for (ix = AvFILLp(comppad_name); ix > 0; ix--) {
1500 SV *namesv = namepad[ix];
1501 if (namesv && namesv != &PL_sv_undef
1502 && *SvPVX(namesv) == '&')
1504 CV *innercv = (CV*)curpad[ix];
1505 assert(CvWEAKOUTSIDE(innercv));
1506 assert(CvOUTSIDE(innercv) == old_cv);
1507 CvOUTSIDE(innercv) = new_cv;
1514 =for apidoc pad_push
1516 Push a new pad frame onto the padlist, unless there's already a pad at
1517 this depth, in which case don't bother creating a new one.
1518 If has_args is true, give the new pad an @_ in slot zero.
1524 Perl_pad_push(pTHX_ PADLIST *padlist, int depth, int has_args)
1526 if (depth <= AvFILLp(padlist))
1530 SV** svp = AvARRAY(padlist);
1531 AV *newpad = newAV();
1532 SV **oldpad = AvARRAY(svp[depth-1]);
1533 I32 ix = AvFILLp((AV*)svp[1]);
1534 I32 names_fill = AvFILLp((AV*)svp[0]);
1535 SV** names = AvARRAY(svp[0]);
1537 for ( ;ix > 0; ix--) {
1538 if (names_fill >= ix && names[ix] != &PL_sv_undef) {
1539 char *name = SvPVX(names[ix]);
1540 if ((SvFLAGS(names[ix]) & SVf_FAKE) || *name == '&') {
1541 /* outer lexical or anon code */
1542 av_store(newpad, ix, SvREFCNT_inc(oldpad[ix]));
1544 else { /* our own lexical */
1546 av_store(newpad, ix, sv = (SV*)newAV());
1547 else if (*name == '%')
1548 av_store(newpad, ix, sv = (SV*)newHV());
1550 av_store(newpad, ix, sv = NEWSV(0, 0));
1554 else if (IS_PADGV(oldpad[ix]) || IS_PADCONST(oldpad[ix])) {
1555 av_store(newpad, ix, sv = SvREFCNT_inc(oldpad[ix]));
1558 /* save temporaries on recursion? */
1559 av_store(newpad, ix, sv = NEWSV(0, 0));
1566 av_store(newpad, 0, (SV*)av);
1567 AvFLAGS(av) = AVf_REIFY;
1569 av_store(padlist, depth, (SV*)newpad);
1570 AvFILLp(padlist) = depth;