xref: /openbsd-src/gnu/usr.bin/perl/pod/perlclassguts.pod (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1*f2a19305Safresh1=head1 NAME
2*f2a19305Safresh1
3*f2a19305Safresh1perlclassguts - Internals of how C<feature 'class'> and class syntax works
4*f2a19305Safresh1
5*f2a19305Safresh1=head1 DESCRIPTION
6*f2a19305Safresh1
7*f2a19305Safresh1This document provides in-depth information about the way in which the perl
8*f2a19305Safresh1interpreter implements the C<feature 'class'> syntax and overall behaviour.
9*f2a19305Safresh1It is not intended as an end-user guide on how to use the feature. For that,
10*f2a19305Safresh1see L<perlclass>.
11*f2a19305Safresh1
12*f2a19305Safresh1The reader is assumed to be generally familiar with the perl interpreter
13*f2a19305Safresh1internals overall. For a more general overview of these details, see also
14*f2a19305Safresh1L<perlguts>.
15*f2a19305Safresh1
16*f2a19305Safresh1=head1 DATA STORAGE
17*f2a19305Safresh1
18*f2a19305Safresh1=head2 Classes
19*f2a19305Safresh1
20*f2a19305Safresh1A class is fundamentally a package, and exists in the symbol table as an HV
21*f2a19305Safresh1with an aux structure in exactly the same way as a non-class package. It is
22*f2a19305Safresh1distinguished from a non-class package by the fact that the
23*f2a19305Safresh1C<HvSTASH_IS_CLASS()> macro will return true on it.
24*f2a19305Safresh1
25*f2a19305Safresh1Extra information relating to it being a class is stored in the
26*f2a19305Safresh1C<struct xpvhv_aux> structure attached to the stash, in the following fields:
27*f2a19305Safresh1
28*f2a19305Safresh1    HV          *xhv_class_superclass;
29*f2a19305Safresh1    CV          *xhv_class_initfields_cv;
30*f2a19305Safresh1    AV          *xhv_class_adjust_blocks;
31*f2a19305Safresh1    PADNAMELIST *xhv_class_fields;
32*f2a19305Safresh1    PADOFFSET    xhv_class_next_fieldix;
33*f2a19305Safresh1    HV          *xhv_class_param_map;
34*f2a19305Safresh1
35*f2a19305Safresh1=over 4
36*f2a19305Safresh1
37*f2a19305Safresh1=item *
38*f2a19305Safresh1
39*f2a19305Safresh1C<xhv_class_superclass> will be C<NULL> for a class with no superclass. It
40*f2a19305Safresh1will point directly to the stash of the parent class if one has been set with
41*f2a19305Safresh1the C<:isa()> class attribute.
42*f2a19305Safresh1
43*f2a19305Safresh1=item *
44*f2a19305Safresh1
45*f2a19305Safresh1C<xhv_class_initfields_cv> will contain a C<CV *> pointing to a function to be
46*f2a19305Safresh1invoked as part of the constructor of this class or any subclass thereof. This
47*f2a19305Safresh1CV is responsible for initializing all the fields defined by this class for a
48*f2a19305Safresh1new instance. This CV will be an anonymous real function - i.e. while it has no
49*f2a19305Safresh1name and no GV, it is I<not> a protosub and may be directly invoked.
50*f2a19305Safresh1
51*f2a19305Safresh1=item *
52*f2a19305Safresh1
53*f2a19305Safresh1C<xhv_class_adjust_blocks> may point to an AV containing CV pointers to each of
54*f2a19305Safresh1the C<ADJUST> blocks defined on the class. If the class has a superclass, this
55*f2a19305Safresh1array will additionally contain duplicate pointers of the CVs of its parent
56*f2a19305Safresh1class. The AV is created lazily the first time an element is pushed to it; it
57*f2a19305Safresh1is valid for there not to be one, and this pointer will be C<NULL> in that
58*f2a19305Safresh1case.
59*f2a19305Safresh1
60*f2a19305Safresh1The CVs are stored directly, not via RVs. Each CV will be an anonymous real
61*f2a19305Safresh1function.
62*f2a19305Safresh1
63*f2a19305Safresh1=item *
64*f2a19305Safresh1
65*f2a19305Safresh1C<xhv_class_fields> will point to a C<PADNAMELIST> containing C<PADNAME>s,
66*f2a19305Safresh1each being one defined field of the class. They are stored in order of
67*f2a19305Safresh1declaration. Note however, that the index into this array will not necessarily
68*f2a19305Safresh1be equal to the C<fieldix> of each field, because in the case of a subclass,
69*f2a19305Safresh1the array will begin at zero but the index of the first field in it will be
70*f2a19305Safresh1non-zero if its parent class contains any fields at all.
71*f2a19305Safresh1
72*f2a19305Safresh1For more information on how individual fields are represented, see L</Fields>.
73*f2a19305Safresh1
74*f2a19305Safresh1=item *
75*f2a19305Safresh1
76*f2a19305Safresh1C<xhv_class_next_fieldix> gives the field index that will be assigned to the
77*f2a19305Safresh1next field to be added to the class. It is only useful at compile-time.
78*f2a19305Safresh1
79*f2a19305Safresh1=item *
80*f2a19305Safresh1
81*f2a19305Safresh1C<xhv_class_param_map> may point to an HV which maps field C<:param> attribute
82*f2a19305Safresh1names to the field index of the field with that name. This mapping is copied
83*f2a19305Safresh1from parent classes; each class will contain the sum total of all its parents
84*f2a19305Safresh1in addition to its own.
85*f2a19305Safresh1
86*f2a19305Safresh1=back
87*f2a19305Safresh1
88*f2a19305Safresh1=head2 Fields
89*f2a19305Safresh1
90*f2a19305Safresh1A field is still fundamentally a lexical variable declared in a scope, and
91*f2a19305Safresh1exists in the C<PADNAMELIST> of its corresponding CV. Methods and other
92*f2a19305Safresh1method-like CVs can still capture them exactly as they can with regular
93*f2a19305Safresh1lexicals. A field is distinguished from other kinds of pad entry in that the
94*f2a19305Safresh1C<PadnameIsFIELD()> macro will return true on it.
95*f2a19305Safresh1
96*f2a19305Safresh1Extra information relating to it being a field is stored in an additional
97*f2a19305Safresh1structure accessible via the C<PadnameFIELDINFO()> macro on the padname. This
98*f2a19305Safresh1structure has the following fields:
99*f2a19305Safresh1
100*f2a19305Safresh1    PADOFFSET  fieldix;
101*f2a19305Safresh1    HV        *fieldstash;
102*f2a19305Safresh1    OP        *defop;
103*f2a19305Safresh1    SV        *paramname;
104*f2a19305Safresh1    bool       def_if_undef;
105*f2a19305Safresh1    bool       def_if_false;
106*f2a19305Safresh1
107*f2a19305Safresh1=over 4
108*f2a19305Safresh1
109*f2a19305Safresh1=item *
110*f2a19305Safresh1
111*f2a19305Safresh1C<fieldix> stores the "field index" of the field; that is, the index into the
112*f2a19305Safresh1instance field array where this field's value will be stored. Note that the
113*f2a19305Safresh1first index in the array is not specially reserved. The first field in a class
114*f2a19305Safresh1will start from field index 0.
115*f2a19305Safresh1
116*f2a19305Safresh1=item *
117*f2a19305Safresh1
118*f2a19305Safresh1C<fieldstash> stores a pointer to the stash of the class that defined this
119*f2a19305Safresh1field. This is necessary in case there are multiple classes defined within the
120*f2a19305Safresh1same scope; it is used to disambiguate the fields of each.
121*f2a19305Safresh1
122*f2a19305Safresh1    {
123*f2a19305Safresh1        class C1; field $x;
124*f2a19305Safresh1        class C2; field $x;
125*f2a19305Safresh1    }
126*f2a19305Safresh1
127*f2a19305Safresh1=item *
128*f2a19305Safresh1
129*f2a19305Safresh1C<defop> may store a pointer to a defaulting expression optree for this field.
130*f2a19305Safresh1Defaulting expressions are optional; this field may be C<NULL>.
131*f2a19305Safresh1
132*f2a19305Safresh1=item *
133*f2a19305Safresh1
134*f2a19305Safresh1C<paramname> may point to a regular string SV containing the C<:param> name
135*f2a19305Safresh1attribute given to the field. If none, it will be C<NULL>.
136*f2a19305Safresh1
137*f2a19305Safresh1=item *
138*f2a19305Safresh1
139*f2a19305Safresh1One of C<def_if_undef> and C<def_if_false> will be true if the defaulting
140*f2a19305Safresh1expression was set using the C<//=> or C<||=> operators respectively.
141*f2a19305Safresh1
142*f2a19305Safresh1=back
143*f2a19305Safresh1
144*f2a19305Safresh1=head2 Methods
145*f2a19305Safresh1
146*f2a19305Safresh1A method is still fundamentally a CV, and has the same basic representation as
147*f2a19305Safresh1one. It has an optree and a pad, and is stored via a GV in the stash of its
148*f2a19305Safresh1containing package. It is distinguished from a non-method CV by the fact that
149*f2a19305Safresh1the C<CvIsMETHOD()> macro will return true on it.
150*f2a19305Safresh1
151*f2a19305Safresh1(Note: This macro should not be confused with the one that was previously
152*f2a19305Safresh1called C<CvMETHOD()>. That one does not relate to the class system, and was
153*f2a19305Safresh1renamed to C<CvNOWARN_AMBIGUOUS()> to avoid this confusion.)
154*f2a19305Safresh1
155*f2a19305Safresh1There is currently no extra information that needs to be stored about a method
156*f2a19305Safresh1CV, so the structure does not add any new fields.
157*f2a19305Safresh1
158*f2a19305Safresh1=head2 Instances
159*f2a19305Safresh1
160*f2a19305Safresh1Object instances are represented by an entirely new SV type, whose base type
161*f2a19305Safresh1is C<SVt_PVOBJ>. This should still be blessed into its class stash and wrapped
162*f2a19305Safresh1in an RV in the usual manner for classical object.
163*f2a19305Safresh1
164*f2a19305Safresh1As these are their own unique container type, distinct from hashes or arrays,
165*f2a19305Safresh1the core C<builtin::reftype> function returns a new value when asked about
166*f2a19305Safresh1these. That value is C<"OBJECT">.
167*f2a19305Safresh1
168*f2a19305Safresh1Internally, such an object is an array of SV pointers whose size is fixed at
169*f2a19305Safresh1creation time (because the number of fields in a class is known after
170*f2a19305Safresh1compilation). An object instance stores the max field index within it (for
171*f2a19305Safresh1basic error-checking on access), and a fixed-size array of SV pointers storing
172*f2a19305Safresh1the individual field values.
173*f2a19305Safresh1
174*f2a19305Safresh1Fields of array and hash type directly store AV or HV pointers into the array;
175*f2a19305Safresh1they are not stored via an intervening RV.
176*f2a19305Safresh1
177*f2a19305Safresh1=head1 API
178*f2a19305Safresh1
179*f2a19305Safresh1The data structures described above are supported by the following API
180*f2a19305Safresh1functions.
181*f2a19305Safresh1
182*f2a19305Safresh1=head2 Class Manipulation
183*f2a19305Safresh1
184*f2a19305Safresh1=head3 class_setup_stash
185*f2a19305Safresh1
186*f2a19305Safresh1    void class_setup_stash(HV *stash);
187*f2a19305Safresh1
188*f2a19305Safresh1Called by the parser on encountering the C<class> keyword. It upgrades the
189*f2a19305Safresh1stash into being a class and prepares it for receiving class-specific items
190*f2a19305Safresh1like methods and fields.
191*f2a19305Safresh1
192*f2a19305Safresh1=head3 class_seal_stash
193*f2a19305Safresh1
194*f2a19305Safresh1    void class_seal_stash(HV *stash);
195*f2a19305Safresh1
196*f2a19305Safresh1Called by the parser at the end of a C<class> block, or for unit classes its
197*f2a19305Safresh1containing scope. This function performs various finalisation activities that
198*f2a19305Safresh1are required before instances of the class can be constructed, but could not
199*f2a19305Safresh1have been done until all the information about the members of the class is
200*f2a19305Safresh1known.
201*f2a19305Safresh1
202*f2a19305Safresh1Any additions to or modifications of the class under compilation must be
203*f2a19305Safresh1performed between these two function calls. Classes cannot be modified once
204*f2a19305Safresh1they have been sealed.
205*f2a19305Safresh1
206*f2a19305Safresh1=head3 class_add_field
207*f2a19305Safresh1
208*f2a19305Safresh1    void class_add_field(HV *stash, PADNAME *pn);
209*f2a19305Safresh1
210*f2a19305Safresh1Called by F<pad.c> as part of defining a new field name in the current pad.
211*f2a19305Safresh1Note that this function does I<not> create the padname; that must already be
212*f2a19305Safresh1done by F<pad.c>. This API function simply informs the class that the new
213*f2a19305Safresh1field name has been created and is now available for it.
214*f2a19305Safresh1
215*f2a19305Safresh1=head3 class_add_ADJUST
216*f2a19305Safresh1
217*f2a19305Safresh1    void class_add_ADJUST(HV *stash, CV *cv);
218*f2a19305Safresh1
219*f2a19305Safresh1Called by the parser once it has parsed and constructed a CV for a new
220*f2a19305Safresh1C<ADJUST> block. This gets added to the list stored by the class.
221*f2a19305Safresh1
222*f2a19305Safresh1=head2 Field Manipulation
223*f2a19305Safresh1
224*f2a19305Safresh1=head3 class_prepare_initfield_parse
225*f2a19305Safresh1
226*f2a19305Safresh1    void class_prepare_initfield_parse();
227*f2a19305Safresh1
228*f2a19305Safresh1Called by the parser just before parsing an initializing expression for a
229*f2a19305Safresh1field variable. This makes use of a suspended compcv to combine all the field
230*f2a19305Safresh1initializing expressions into the same CV.
231*f2a19305Safresh1
232*f2a19305Safresh1=head3 class_set_field_defop
233*f2a19305Safresh1
234*f2a19305Safresh1    void class_set_field_defop(PADNAME *pn, OPCODE defmode, OP *defop);
235*f2a19305Safresh1
236*f2a19305Safresh1Called by the parser after it has parsed an initializing expression for the
237*f2a19305Safresh1field. Sets the defaulting expression and mode of application. C<defmode>
238*f2a19305Safresh1should either be zero, or one of C<OP_ORASSIGN> or C<OP_DORASSIGN> depending
239*f2a19305Safresh1on the defaulting mode.
240*f2a19305Safresh1
241*f2a19305Safresh1=head3 padadd_FIELD
242*f2a19305Safresh1
243*f2a19305Safresh1    #define padadd_FIELD
244*f2a19305Safresh1
245*f2a19305Safresh1This flag constant tells the C<pad_add_name_*> family of functions that the
246*f2a19305Safresh1new name should be added as a field. There is no need to call
247*f2a19305Safresh1C<class_add_field()>; this will be done automatically.
248*f2a19305Safresh1
249*f2a19305Safresh1=head2 Method Manipulation
250*f2a19305Safresh1
251*f2a19305Safresh1=head3 class_prepare_method_parse
252*f2a19305Safresh1
253*f2a19305Safresh1    void class_prepare_method_parse(CV *cv);
254*f2a19305Safresh1
255*f2a19305Safresh1Called by the parser after C<start_subparse()> but immediately before doing
256*f2a19305Safresh1anything else. This prepares the C<PL_compcv> for parsing a method; arranging
257*f2a19305Safresh1for the C<CvIsMETHOD> test to be true, adding the C<$self> lexical, and any
258*f2a19305Safresh1other activities that may be required.
259*f2a19305Safresh1
260*f2a19305Safresh1=head3 class_wrap_method_body
261*f2a19305Safresh1
262*f2a19305Safresh1    OP *class_wrap_method_body(OP *o);
263*f2a19305Safresh1
264*f2a19305Safresh1Called by the parser at the end of parsing a method body into an optree but
265*f2a19305Safresh1just before wrapping it in the eventual CV. This function inserts extra ops
266*f2a19305Safresh1into the optree to make the method work correctly.
267*f2a19305Safresh1
268*f2a19305Safresh1=head2 Object Instances
269*f2a19305Safresh1
270*f2a19305Safresh1=head3 SVt_PVOBJ
271*f2a19305Safresh1
272*f2a19305Safresh1    #define SVt_PVOBJ
273*f2a19305Safresh1
274*f2a19305Safresh1An SV type constant used for comparison with the C<SvTYPE()> macro.
275*f2a19305Safresh1
276*f2a19305Safresh1=head3 ObjectMAXFIELD
277*f2a19305Safresh1
278*f2a19305Safresh1    SSize_t ObjectMAXFIELD(sv);
279*f2a19305Safresh1
280*f2a19305Safresh1A function-like macro that obtains the maximum valid field index that can be
281*f2a19305Safresh1accessed from the C<ObjectFIELDS> array.
282*f2a19305Safresh1
283*f2a19305Safresh1=head3 ObjectFIELDS
284*f2a19305Safresh1
285*f2a19305Safresh1    SV **ObjectFIELDS(sv);
286*f2a19305Safresh1
287*f2a19305Safresh1A function-like macro that obtains the fields array directly out of an object
288*f2a19305Safresh1instance. Fields can be accessed by their field index, from 0 up to the maximum
289*f2a19305Safresh1valid index given by C<ObjectMAXFIELD>.
290*f2a19305Safresh1
291*f2a19305Safresh1=head1 OPCODES
292*f2a19305Safresh1
293*f2a19305Safresh1=head2 OP_METHSTART
294*f2a19305Safresh1
295*f2a19305Safresh1    newUNOP_AUX(OP_METHSTART, ...);
296*f2a19305Safresh1
297*f2a19305Safresh1An C<OP_METHSTART> is an C<UNOP_AUX> which must be present at the start of a
298*f2a19305Safresh1method CV in order to make it work properly. This is inserted by
299*f2a19305Safresh1C<class_wrap_method_body()>, and even appears before any optree fragment
300*f2a19305Safresh1associated with signature argument checking or extraction.
301*f2a19305Safresh1
302*f2a19305Safresh1This op is responsible for shifting the value of C<$self> out of the arguments
303*f2a19305Safresh1list and binding any field variables that the method requires access to into
304*f2a19305Safresh1the pad. The AUX vector will contain details of the field/pad index pairings
305*f2a19305Safresh1required.
306*f2a19305Safresh1
307*f2a19305Safresh1This op also performs sanity checking on the invocant value. It checks that it
308*f2a19305Safresh1is definitely an object reference of a compatible class type. If not, an
309*f2a19305Safresh1exception is thrown.
310*f2a19305Safresh1
311*f2a19305Safresh1If the C<op_private> field includes the C<OPpINITFIELDS> flag, this indicates
312*f2a19305Safresh1that the op begins the special C<xhv_class_initfields_cv> CV. In this case it
313*f2a19305Safresh1should additionally take the second value from the arguments list, which
314*f2a19305Safresh1should be a plain HV pointer (I<directly>, not via RV). and bind it to the
315*f2a19305Safresh1second pad slot, where the generated optree will expect to find it.
316*f2a19305Safresh1
317*f2a19305Safresh1=head2 OP_INITFIELD
318*f2a19305Safresh1
319*f2a19305Safresh1An C<OP_INITFIELD> is only invoked as part of the C<xhv_class_initfields_cv>
320*f2a19305Safresh1CV during the construction phase of an instance. This is the time that the
321*f2a19305Safresh1individual SVs that make up the mutable fields of the instance (including AVs
322*f2a19305Safresh1and HVs) are actually assigned into the C<ObjectFIELDS> array. The
323*f2a19305Safresh1C<OPpINITFIELD_AV> and C<OPpINITFIELD_HV> private flags indicate whether it is
324*f2a19305Safresh1creating an AV or HV; if neither is set then an SV is created.
325*f2a19305Safresh1
326*f2a19305Safresh1If the op has the C<OPf_STACKED> flag it expects to find an initializing value
327*f2a19305Safresh1on the stack. For SVs this is the topmost SV on the data stack. For AVs and
328*f2a19305Safresh1HVs it expects a marked list.
329*f2a19305Safresh1
330*f2a19305Safresh1=head1 COMPILE-TIME BEHAVIOUR
331*f2a19305Safresh1
332*f2a19305Safresh1=head2 C<ADJUST> Phasers
333*f2a19305Safresh1
334*f2a19305Safresh1During compiletime, parsing of an C<ADJUST> phaser is handled in a
335*f2a19305Safresh1fundamentally different way to the existing perl phasers (C<BEGIN>, etc...)
336*f2a19305Safresh1
337*f2a19305Safresh1Rather than taking the usual route, the tokenizer recognises that the
338*f2a19305Safresh1C<ADJUST> keyword introduces a phaser block. The parser then parses the body
339*f2a19305Safresh1of this block similarly to how it would parse an (anonymous) method body,
340*f2a19305Safresh1creating a CV that has no name GV. This is then inserted directly into the
341*f2a19305Safresh1class information by calling C<class_add_ADJUST>, entirely bypassing the
342*f2a19305Safresh1symbol table.
343*f2a19305Safresh1
344*f2a19305Safresh1=head2 Attributes
345*f2a19305Safresh1
346*f2a19305Safresh1During compilation, attributes of both classes and fields are handled in a
347*f2a19305Safresh1different way to existing perl attributes on subroutines and lexical
348*f2a19305Safresh1variables.
349*f2a19305Safresh1
350*f2a19305Safresh1The parser still forms an C<OP_LIST> optree of C<OP_CONST> nodes, but these
351*f2a19305Safresh1are passed to the C<class_apply_attributes> or C<class_apply_field_attributes>
352*f2a19305Safresh1functions. Rather than using a class lookup for a method in the class being
353*f2a19305Safresh1parsed, a fixed internal list of known attributes is used to find functions to
354*f2a19305Safresh1apply the attribute to the class or field. In future this may support
355*f2a19305Safresh1user-supplied extension attribute, though at present it only recognises ones
356*f2a19305Safresh1defined by the core itself.
357*f2a19305Safresh1
358*f2a19305Safresh1=head2 Field Initializing Expressions
359*f2a19305Safresh1
360*f2a19305Safresh1During compilation, the parser makes use of a suspended compcv when parsing
361*f2a19305Safresh1the defaulting expression for a field. All the expressions for all the fields
362*f2a19305Safresh1in the class share the same suspended compcv, which is then compiled up into
363*f2a19305Safresh1the same internal CV called by the constructor to initialize all the fields
364*f2a19305Safresh1provided by that class.
365*f2a19305Safresh1
366*f2a19305Safresh1=head1 RUNTIME BEHAVIOUR
367*f2a19305Safresh1
368*f2a19305Safresh1=head2 Constructor
369*f2a19305Safresh1
370*f2a19305Safresh1The generated constructor for a class itself is an XSUB which performs three
371*f2a19305Safresh1tasks in order: it creates the instance SV itself, invokes the field
372*f2a19305Safresh1initializers, then invokes the ADJUST block CVs. The constructor for any class
373*f2a19305Safresh1is always the same basic shape, regardless of whether the class has a
374*f2a19305Safresh1superclass or not.
375*f2a19305Safresh1
376*f2a19305Safresh1The field initializers are collected into a generated optree-based CV called
377*f2a19305Safresh1the field initializer CV. This is the CV which contains all the optree
378*f2a19305Safresh1fragments for the field initializing expressions. When invoked, the field
379*f2a19305Safresh1initializer CV might make a chained call to the superclass initializer if one
380*f2a19305Safresh1exists, before invoking all of the individual field initialization ops. The
381*f2a19305Safresh1field initializer CV is invoked with two items on the stack; being the
382*f2a19305Safresh1instance SV and a direct HV containing the constructor parameters. Note
383*f2a19305Safresh1carefully: this HV is passed I<directly>, not via an RV reference. This is
384*f2a19305Safresh1permitted because both the caller and the callee are directly generated code
385*f2a19305Safresh1and not arbitrary pure-perl subroutines.
386*f2a19305Safresh1
387*f2a19305Safresh1The ADJUST block CVs are all collected into a single flat list, merging all of
388*f2a19305Safresh1the ones defined by the superclass as well. They are all invoked in order,
389*f2a19305Safresh1after the field initializer CV.
390*f2a19305Safresh1
391*f2a19305Safresh1=head2 C<$self> Access During Methods
392*f2a19305Safresh1
393*f2a19305Safresh1When C<class_prepare_method_parse()> is called, it arranges that the pad of
394*f2a19305Safresh1the new CV body will begin with a lexical called C<$self>. Because the pad
395*f2a19305Safresh1should be freshly-created at this point, this will have the pad index of 1.
396*f2a19305Safresh1The function checks this and aborts if that is not true.
397*f2a19305Safresh1
398*f2a19305Safresh1Because of this fact, code within the body of a method or method-like CV can
399*f2a19305Safresh1reliably use pad index 1 to obtain the invocant reference. The C<OP_INITFIELD>
400*f2a19305Safresh1opcode also relies on this fact.
401*f2a19305Safresh1
402*f2a19305Safresh1In similar fashion, during the C<xhv_class_initfields_cv> the next pad slot is
403*f2a19305Safresh1relied on to store the constructor parameters HV, at pad index 2.
404*f2a19305Safresh1
405*f2a19305Safresh1=head1 AUTHORS
406*f2a19305Safresh1
407*f2a19305Safresh1Paul Evans
408*f2a19305Safresh1
409*f2a19305Safresh1=cut
410