📄 perlintern.pod
字号:
-*- buffer-read-only: t -*-!!!!!!! DO NOT EDIT THIS FILE !!!!!!!This file is built by autodoc.pl extracting documentation from the C sourcefiles.=head1 NAMEperlintern - autogenerated documentation of purely B<internal> Perl functions=head1 DESCRIPTIONX<internal Perl functions> X<interpreter functions>This file is the autogenerated documentation of functions in thePerl interpreter that are documented using Perl's internal documentationformat but are not marked as part of the Perl API. In other words,B<they are not for use in extensions>!=head1 CV reference counts and CvOUTSIDE=over 8=item CvWEAKOUTSIDEX<CvWEAKOUTSIDE>Each CV has a pointer, C<CvOUTSIDE()>, to its lexically enclosingCV (if any). Because pointers to anonymous sub prototypes arestored in C<&> pad slots, it is a possible to get a circular reference,with the parent pointing to the child and vice-versa. To avoid theensuing memory leak, we do not increment the reference count of the CVpointed to by C<CvOUTSIDE> in the I<one specific instance> that the parenthas a C<&> pad slot pointing back to us. In this case, we set theC<CvWEAKOUTSIDE> flag in the child. This allows us to determine under whatcircumstances we should decrement the refcount of the parent when freeingthe child.There is a further complication with non-closure anonymous subs (i.e. thosethat do not refer to any lexicals outside that sub). In this case, theanonymous prototype is shared rather than being cloned. This has theconsequence that the parent may be freed while there are still activechildren, eg BEGIN { $a = sub { eval '$x' } }In this case, the BEGIN is freed immediately after execution since thereare no active references to it: the anon sub prototype hasC<CvWEAKOUTSIDE> set since it's not a closure, and $a points to the sameCV, so it doesn't contribute to BEGIN's refcount either. When $a isexecuted, the C<eval '$x'> causes the chain of C<CvOUTSIDE>s to be followed,and the freed BEGIN is accessed.To avoid this, whenever a CV and its associated pad is freed, anyC<&> entries in the pad are explicitly removed from the pad, and if therefcount of the pointed-to anon sub is still positive, then thatchild's C<CvOUTSIDE> is set to point to its grandparent. This will onlyoccur in the single specific case of a non-closure anon prototypehaving one or more active references (such as C<$a> above).One other thing to consider is that a CV may be merely undefinedrather than freed, eg C<undef &foo>. In this case, its refcount maynot have reached zero, but we still delete its pad and its C<CvROOT> etc.Since various children may still have their C<CvOUTSIDE> pointing at thisundefined CV, we keep its own C<CvOUTSIDE> for the time being, so thatthe chain of lexical scopes is unbroken. For example, the followingshould print 123: my $x = 123; sub tmp { sub { eval '$x' } } my $a = tmp(); undef &tmp; print $a->(); bool CvWEAKOUTSIDE(CV *cv)=for hackersFound in file cv.h=back=head1 Functions in file pad.h=over 8=item CX_CURPAD_SAVEX<CX_CURPAD_SAVE>Save the current pad in the given context block structure. void CX_CURPAD_SAVE(struct context)=for hackersFound in file pad.h=item CX_CURPAD_SVX<CX_CURPAD_SV>Access the SV at offset po in the saved current pad in the givencontext block structure (can be used as an lvalue). SV * CX_CURPAD_SV(struct context, PADOFFSET po)=for hackersFound in file pad.h=item PAD_BASE_SVX<PAD_BASE_SV>Get the value from slot C<po> in the base (DEPTH=1) pad of a padlist SV * PAD_BASE_SV(PADLIST padlist, PADOFFSET po)=for hackersFound in file pad.h=item PAD_CLONE_VARSX<PAD_CLONE_VARS>|CLONE_PARAMS* paramClone the state variables associated with running and compiling pads. void PAD_CLONE_VARS(PerlInterpreter *proto_perl \)=for hackersFound in file pad.h=item PAD_COMPNAME_FLAGSX<PAD_COMPNAME_FLAGS>Return the flags for the current compiling pad nameat offset C<po>. Assumes a valid slot entry. U32 PAD_COMPNAME_FLAGS(PADOFFSET po)=for hackersFound in file pad.h=item PAD_COMPNAME_GENX<PAD_COMPNAME_GEN>The generation number of the name at offset C<po> in the currentcompiling pad (lvalue). Note that C<SvUVX> is hijacked for this purpose. STRLEN PAD_COMPNAME_GEN(PADOFFSET po)=for hackersFound in file pad.h=item PAD_COMPNAME_GEN_setX<PAD_COMPNAME_GEN_set>Sets the generation number of the name at offset C<po> in the currentling pad (lvalue) to C<gen>. Note that C<SvUV_set> is hijacked for this purpose. STRLEN PAD_COMPNAME_GEN_set(PADOFFSET po, int gen)=for hackersFound in file pad.h=item PAD_COMPNAME_OURSTASHX<PAD_COMPNAME_OURSTASH>Return the stash associated with an C<our> variable.Assumes the slot entry is a valid C<our> lexical. HV * PAD_COMPNAME_OURSTASH(PADOFFSET po)=for hackersFound in file pad.h=item PAD_COMPNAME_PVX<PAD_COMPNAME_PV>Return the name of the current compiling pad nameat offset C<po>. Assumes a valid slot entry. char * PAD_COMPNAME_PV(PADOFFSET po)=for hackersFound in file pad.h=item PAD_COMPNAME_TYPEX<PAD_COMPNAME_TYPE>Return the type (stash) of the current compiling pad name at offsetC<po>. Must be a valid name. Returns null if not typed. HV * PAD_COMPNAME_TYPE(PADOFFSET po)=for hackersFound in file pad.h=item PAD_DUPX<PAD_DUP>Clone a padlist. void PAD_DUP(PADLIST dstpad, PADLIST srcpad, CLONE_PARAMS* param)=for hackersFound in file pad.h=item PAD_RESTORE_LOCALX<PAD_RESTORE_LOCAL>Restore the old pad saved into the local variable opad by PAD_SAVE_LOCAL() void PAD_RESTORE_LOCAL(PAD *opad)=for hackersFound in file pad.h=item PAD_SAVE_LOCALX<PAD_SAVE_LOCAL>Save the current pad to the local variable opad, then make thecurrent pad equal to npad void PAD_SAVE_LOCAL(PAD *opad, PAD *npad)=for hackersFound in file pad.h=item PAD_SAVE_SETNULLPADX<PAD_SAVE_SETNULLPAD>Save the current pad then set it to null. void PAD_SAVE_SETNULLPAD()=for hackersFound in file pad.h=item PAD_SETSVX<PAD_SETSV>Set the slot at offset C<po> in the current pad to C<sv> SV * PAD_SETSV(PADOFFSET po, SV* sv)=for hackersFound in file pad.h=item PAD_SET_CURX<PAD_SET_CUR>Set the current pad to be pad C<n> in the padlist, savingthe previous current pad. NB currently this macro expands to a string toolong for some compilers, so it's best to replace it with SAVECOMPPAD(); PAD_SET_CUR_NOSAVE(padlist,n); void PAD_SET_CUR(PADLIST padlist, I32 n)=for hackersFound in file pad.h=item PAD_SET_CUR_NOSAVEX<PAD_SET_CUR_NOSAVE>like PAD_SET_CUR, but without the save void PAD_SET_CUR_NOSAVE(PADLIST padlist, I32 n)=for hackersFound in file pad.h=item PAD_SVX<PAD_SV>Get the value at offset C<po> in the current pad void PAD_SV(PADOFFSET po)=for hackersFound in file pad.h=item PAD_SVlX<PAD_SVl>Lightweight and lvalue version of C<PAD_SV>.Get or set the value at offset C<po> in the current pad.Unlike C<PAD_SV>, does not print diagnostics with -DX.For internal use only. SV * PAD_SVl(PADOFFSET po)=for hackersFound in file pad.h=item SAVECLEARSVX<SAVECLEARSV>Clear the pointed to pad value on scope exit. (i.e. the runtime action of 'my') void SAVECLEARSV(SV **svp)=for hackersFound in file pad.h=item SAVECOMPPADX<SAVECOMPPAD>save PL_comppad and PL_curpad void SAVECOMPPAD()=for hackersFound in file pad.h=item SAVEPADSVX<SAVEPADSV>Save a pad slot (used to restore after an iteration)XXX DAPM it would make more sense to make the arg a PADOFFSET void SAVEPADSV(PADOFFSET po)=for hackersFound in file pad.h=back=head1 GV Functions=over 8=item is_gv_magicalX<is_gv_magical>Returns C<TRUE> if given the name of a magical GV.Currently only useful internally when determining if a GV should becreated even in rvalue contexts.C<flags> is not used at present but available for future extension toallow selecting particular classes of magical variable.Currently assumes that C<name> is NUL terminated (as well as len being valid).This assumption is met by all callers within the perl core, which all passpointers returned by SvPV. bool is_gv_magical(const char *name, STRLEN len, U32 flags)=for hackersFound in file gv.c=item is_gv_magical_svX<is_gv_magical_sv>Returns C<TRUE> if given the name of a magical GV. Calls is_gv_magical. bool is_gv_magical_sv(SV *name, U32 flags)=for hackersFound in file gv.c=back=head1 Hash Manipulation Functions=over 8=item refcounted_he_chain_2hvX<refcounted_he_chain_2hv>Generates and returns a C<HV *> by walking up the tree starting at the passedin C<struct refcounted_he *>. HV * refcounted_he_chain_2hv(const struct refcounted_he *c)=for hackersFound in file hv.c=item refcounted_he_freeX<refcounted_he_free>Decrements the reference count of the passed in C<struct refcounted_he *>by one. If the reference count reaches zero the structure's memory is freed,and C<refcounted_he_free> iterates onto the parent node. void refcounted_he_free(struct refcounted_he *he)=for hackersFound in file hv.c=item refcounted_he_newX<refcounted_he_new>Creates a new C<struct refcounted_he>. As S<key> is copied, and value isstored in a compact form, all references remain the property of the caller.The C<struct refcounted_he> is returned with a reference count of 1. struct refcounted_he * refcounted_he_new(struct refcounted_he *const parent, SV *const key, SV *const value)=for hackersFound in file hv.c=back=head1 IO Functions=over 8=item start_globX<start_glob>Function called by C<do_readline> to spawn a glob (or do the glob insideperl on VMS). This code used to be inline, but now perl uses C<File::Glob>this glob starter is only used by miniperl during the build process.Moving it away shrinks pp_hot.c; shrinking pp_hot.c helps speed perl up. PerlIO* start_glob(SV* pattern, IO *io)=for hackersFound in file doio.c=back=head1 Magical Functions=over 8=item magic_sethintX<magic_sethint>Triggered by a delete from %^H, records the key toC<PL_compiling.cop_hints_hash>. int magic_sethint(SV* sv, MAGIC* mg)=for hackersFound in file mg.c=item mg_localizeX<mg_localize>Copy some of the magic from an existing SV to new localized version ofthat SV. Container magic (eg %ENV, $1, tie) gets copied, value magicdoesn't (eg taint, pos). void mg_localize(SV* sv, SV* nsv)=for hackersFound in file mg.c=back=head1 MRO Functions=over 8=item mro_get_linear_isa_c3X<mro_get_linear_isa_c3>Returns the C3 linearization of @ISAthe given stash. The return value is a read-only AV*.C<level> should be 0 (it is used internally in thisfunction's recursion).You are responsible for C<SvREFCNT_inc()> on thereturn value if you plan to store it anywheresemi-permanently (otherwise it might be deletedout from under you the next time the cache isinvalidated). AV* mro_get_linear_isa_c3(HV* stash, I32 level)=for hackersFound in file mro.c=item mro_get_linear_isa_dfsX<mro_get_linear_isa_dfs>Returns the Depth-First Search linearization of @ISAthe given stash. The return value is a read-only AV*.C<level> should be 0 (it is used internally in thisfunction's recursion).You are responsible for C<SvREFCNT_inc()> on thereturn value if you plan to store it anywheresemi-permanently (otherwise it might be deletedout from under you the next time the cache isinvalidated). AV* mro_get_linear_isa_dfs(HV* stash, I32 level)=for hackersFound in file mro.c=item mro_isa_changed_inX<mro_isa_changed_in>Takes the necessary steps (cache invalidations, mostly)when the @ISA of the given package has changed. Invokedby the C<setisa> magic, should not need to invoke directly. void mro_isa_changed_in(HV* stash)=for hackersFound in file mro.c=back=head1 Pad Data Structures=over 8=item CvPADLISTX<CvPADLIST>CV's can have CvPADLIST(cv) set to point to an AV.For these purposes "forms" are a kind-of CV, eval""s are too (except they'renot callable at will and are always thrown away after the eval"" is doneexecuting). Require'd files are simply evals without any outer lexicalscope.XSUBs don't have CvPADLIST set - dXSTARG fetches values from PL_curpad,but that is really the callers pad (a slot of which is allocated byevery entersub).The CvPADLIST AV has does not have AvREAL set, so REFCNT of component itemsis managed "manual" (mostly in pad.c) rather than normal av.c rules.The items in the AV are not SVs as for a normal AV, but other AVs:0'th Entry of the CvPADLIST is an AV which represents the "names" or ratherthe "static type information" for lexicals.The CvDEPTH'th entry of CvPADLIST AV is an AV which is the stack frame at thatdepth of recursion into the CV.The 0'th slot of a frame AV is an AV which is @_.other entries are storage for variables and op targets.During compilation:C<PL_comppad_name> is set to the names AV.C<PL_comppad> is set to the frame AV for the frame CvDEPTH == 1.C<PL_curpad> is set to the body of the frame AV (i.e. AvARRAY(PL_comppad)).During execution, C<PL_comppad> and C<PL_curpad> refer to the liveframe of the currently executing sub.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -