3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, 2003, by Larry Wall and others
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
12 * "For the fashion of Minas Tirith was such that it was built on seven
17 #define PERL_IN_SCOPE_C
20 #if defined(PERL_FLEXIBLE_EXCEPTIONS)
22 Perl_default_protect(pTHX_ volatile JMPENV *pcur_env, int *excpt,
23 protect_body_t body, ...)
28 ret = vdefault_protect(pcur_env, excpt, body, &args);
34 Perl_vdefault_protect(pTHX_ volatile JMPENV *pcur_env, int *excpt,
35 protect_body_t body, va_list *args)
44 ret = CALL_FPTR(body)(aTHX_ *args);
52 Perl_stack_grow(pTHX_ SV **sp, SV **p, int n)
55 #ifndef STRESS_REALLOC
56 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 128);
58 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 1);
63 #ifndef STRESS_REALLOC
64 #define GROW(old) ((old) * 3 / 2)
66 #define GROW(old) ((old) + 1)
70 Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
73 New(56, si, 1, PERL_SI);
74 si->si_stack = newAV();
75 AvREAL_off(si->si_stack);
76 av_extend(si->si_stack, stitems > 0 ? stitems-1 : 0);
77 AvALLOC(si->si_stack)[0] = &PL_sv_undef;
78 AvFILLp(si->si_stack) = 0;
81 si->si_cxmax = cxitems - 1;
83 si->si_type = PERLSI_UNDEF;
84 New(56, si->si_cxstack, cxitems, PERL_CONTEXT);
85 /* Without any kind of initialising PUSHSUBST()
86 * in pp_subst() will read uninitialised heap. */
87 Poison(si->si_cxstack, cxitems, PERL_CONTEXT);
94 IV old_max = cxstack_max;
95 cxstack_max = GROW(cxstack_max);
96 Renew(cxstack, cxstack_max + 1, PERL_CONTEXT); /* XXX should fix CXINC macro */
97 /* Without any kind of initialising deep enough recursion
98 * will end up reading uninitialised PERL_CONTEXTs. */
99 Poison(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT);
100 return cxstack_ix + 1;
104 Perl_push_return(pTHX_ OP *retop)
106 if (PL_retstack_ix == PL_retstack_max) {
107 PL_retstack_max = GROW(PL_retstack_max);
108 Renew(PL_retstack, PL_retstack_max, OP*);
110 PL_retstack[PL_retstack_ix++] = retop;
114 Perl_pop_return(pTHX)
116 if (PL_retstack_ix > 0)
117 return PL_retstack[--PL_retstack_ix];
123 Perl_push_scope(pTHX)
125 if (PL_scopestack_ix == PL_scopestack_max) {
126 PL_scopestack_max = GROW(PL_scopestack_max);
127 Renew(PL_scopestack, PL_scopestack_max, I32);
129 PL_scopestack[PL_scopestack_ix++] = PL_savestack_ix;
136 I32 oldsave = PL_scopestack[--PL_scopestack_ix];
137 LEAVE_SCOPE(oldsave);
141 Perl_markstack_grow(pTHX)
143 I32 oldmax = PL_markstack_max - PL_markstack;
144 I32 newmax = GROW(oldmax);
146 Renew(PL_markstack, newmax, I32);
147 PL_markstack_ptr = PL_markstack + oldmax;
148 PL_markstack_max = PL_markstack + newmax;
152 Perl_savestack_grow(pTHX)
154 PL_savestack_max = GROW(PL_savestack_max) + 4;
155 Renew(PL_savestack, PL_savestack_max, ANY);
159 Perl_savestack_grow_cnt(pTHX_ I32 need)
161 PL_savestack_max = PL_savestack_ix + need;
162 Renew(PL_savestack, PL_savestack_max, ANY);
168 Perl_tmps_grow(pTHX_ I32 n)
170 #ifndef STRESS_REALLOC
172 n = (PL_tmps_max < 512) ? 128 : 512;
174 PL_tmps_max = PL_tmps_ix + n + 1;
175 Renew(PL_tmps_stack, PL_tmps_max, SV*);
182 /* XXX should tmps_floor live in cxstack? */
183 I32 myfloor = PL_tmps_floor;
184 while (PL_tmps_ix > myfloor) { /* clean up after last statement */
185 SV* sv = PL_tmps_stack[PL_tmps_ix];
186 PL_tmps_stack[PL_tmps_ix--] = Nullsv;
187 if (sv && sv != &PL_sv_undef) {
189 SvREFCNT_dec(sv); /* note, can modify tmps_ix!!! */
195 S_save_scalar_at(pTHX_ SV **sptr)
200 sv = *sptr = NEWSV(0,0);
201 if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
203 sv_upgrade(sv, SvTYPE(osv));
204 if (SvGMAGICAL(osv)) {
205 bool oldtainted = PL_tainted;
206 mg_get(osv); /* note, can croak! */
207 if (PL_tainting && PL_tainted &&
208 (mg = mg_find(osv, PERL_MAGIC_taint))) {
209 SAVESPTR(mg->mg_obj);
212 SvFLAGS(osv) |= (SvFLAGS(osv) &
213 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
214 PL_tainted = oldtainted;
216 SvMAGIC(sv) = SvMAGIC(osv);
217 /* if it's a special scalar or if it has no 'set' magic,
218 * propagate the SvREADONLY flag. --rgs 20030922 */
219 for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
220 if (SvMAGIC(sv)->mg_type == '\0'
221 || !SvMAGIC(sv)->mg_virtual->svt_set)
223 SvFLAGS(sv) |= SvREADONLY(osv);
227 SvFLAGS(sv) |= SvMAGICAL(osv);
228 /* XXX SvMAGIC() is *shared* between osv and sv. This can
229 * lead to coredumps when both SVs are destroyed without one
230 * of their SvMAGIC() slots being NULLed. */
239 Perl_save_scalar(pTHX_ GV *gv)
241 SV **sptr = &GvSV(gv);
243 SSPUSHPTR(SvREFCNT_inc(gv));
244 SSPUSHPTR(SvREFCNT_inc(*sptr));
246 return save_scalar_at(sptr);
250 Perl_save_svref(pTHX_ SV **sptr)
254 SSPUSHPTR(SvREFCNT_inc(*sptr));
255 SSPUSHINT(SAVEt_SVREF);
256 return save_scalar_at(sptr);
259 /* Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to
260 * restore a global SV to its prior contents, freeing new value. */
262 Perl_save_generic_svref(pTHX_ SV **sptr)
266 SSPUSHPTR(SvREFCNT_inc(*sptr));
267 SSPUSHINT(SAVEt_GENERIC_SVREF);
270 /* Like save_pptr(), but also Safefree()s the new value if it is different
271 * from the old one. Can be used to restore a global char* to its prior
272 * contents, freeing new value. */
274 Perl_save_generic_pvref(pTHX_ char **str)
279 SSPUSHINT(SAVEt_GENERIC_PVREF);
282 /* Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree().
283 * Can be used to restore a shared global char* to its prior
284 * contents, freeing new value. */
286 Perl_save_shared_pvref(pTHX_ char **str)
291 SSPUSHINT(SAVEt_SHARED_PVREF);
294 /* set the SvFLAGS specified by mask to the values in val */
297 Perl_save_set_svflags(pTHX_ SV* sv, U32 mask, U32 val)
303 SSPUSHINT(SAVEt_SET_SVFLAGS);
307 Perl_save_gp(pTHX_ GV *gv, I32 empty)
310 SSPUSHIV((IV)SvLEN(gv));
311 SvLEN(gv) = 0; /* forget that anything was allocated here */
312 SSPUSHIV((IV)SvCUR(gv));
313 SSPUSHPTR(SvPVX(gv));
315 SSPUSHPTR(SvREFCNT_inc(gv));
322 Newz(602, gp, 1, GP);
325 PL_sub_generation++; /* taking a method out of circulation */
326 if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
328 IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
330 GvGP(gv) = gp_ref(gp);
331 GvSV(gv) = NEWSV(72,0);
332 GvLINE(gv) = CopLINE(PL_curcop);
333 GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : "";
343 Perl_save_ary(pTHX_ GV *gv)
348 if (!AvREAL(oav) && AvREIFY(oav))
355 GvAV(gv) = Null(AV*);
358 SvMAGIC(av) = SvMAGIC(oav);
359 SvFLAGS((SV*)av) |= SvMAGICAL(oav);
370 Perl_save_hash(pTHX_ GV *gv)
376 SSPUSHPTR(ohv = GvHVn(gv));
379 GvHV(gv) = Null(HV*);
382 SvMAGIC(hv) = SvMAGIC(ohv);
383 SvFLAGS((SV*)hv) |= SvMAGICAL(ohv);
394 Perl_save_item(pTHX_ register SV *item)
396 register SV *sv = NEWSV(0,0);
400 SSPUSHPTR(item); /* remember the pointer */
401 SSPUSHPTR(sv); /* remember the value */
402 SSPUSHINT(SAVEt_ITEM);
406 Perl_save_int(pTHX_ int *intp)
411 SSPUSHINT(SAVEt_INT);
415 Perl_save_long(pTHX_ long int *longp)
420 SSPUSHINT(SAVEt_LONG);
424 Perl_save_bool(pTHX_ bool *boolp)
429 SSPUSHINT(SAVEt_BOOL);
433 Perl_save_I32(pTHX_ I32 *intp)
438 SSPUSHINT(SAVEt_I32);
442 Perl_save_I16(pTHX_ I16 *intp)
447 SSPUSHINT(SAVEt_I16);
451 Perl_save_I8(pTHX_ I8 *bytep)
460 Perl_save_iv(pTHX_ IV *ivp)
468 /* Cannot use save_sptr() to store a char* since the SV** cast will
469 * force word-alignment and we'll miss the pointer.
472 Perl_save_pptr(pTHX_ char **pptr)
477 SSPUSHINT(SAVEt_PPTR);
481 Perl_save_vptr(pTHX_ void *ptr)
484 SSPUSHPTR(*(char**)ptr);
486 SSPUSHINT(SAVEt_VPTR);
490 Perl_save_sptr(pTHX_ SV **sptr)
495 SSPUSHINT(SAVEt_SPTR);
499 Perl_save_padsv(pTHX_ PADOFFSET off)
502 ASSERT_CURPAD_ACTIVE("save_padsv");
503 SSPUSHPTR(PL_curpad[off]);
504 SSPUSHPTR(PL_comppad);
505 SSPUSHLONG((long)off);
506 SSPUSHINT(SAVEt_PADSV);
510 Perl_save_threadsv(pTHX_ PADOFFSET i)
512 Perl_croak(aTHX_ "panic: save_threadsv called in non-threaded perl");
517 Perl_save_nogv(pTHX_ GV *gv)
521 SSPUSHINT(SAVEt_NSTAB);
525 Perl_save_hptr(pTHX_ HV **hptr)
530 SSPUSHINT(SAVEt_HPTR);
534 Perl_save_aptr(pTHX_ AV **aptr)
539 SSPUSHINT(SAVEt_APTR);
543 Perl_save_freesv(pTHX_ SV *sv)
547 SSPUSHINT(SAVEt_FREESV);
551 Perl_save_mortalizesv(pTHX_ SV *sv)
555 SSPUSHINT(SAVEt_MORTALIZESV);
559 Perl_save_freeop(pTHX_ OP *o)
563 SSPUSHINT(SAVEt_FREEOP);
567 Perl_save_freepv(pTHX_ char *pv)
571 SSPUSHINT(SAVEt_FREEPV);
575 Perl_save_clearsv(pTHX_ SV **svp)
577 ASSERT_CURPAD_ACTIVE("save_clearsv");
579 SSPUSHLONG((long)(svp-PL_curpad));
580 SSPUSHINT(SAVEt_CLEARSV);
581 SvPADSTALE_off(*svp); /* mark lexical as active */
585 Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen)
590 SSPUSHPTR(SvREFCNT_inc(hv));
591 SSPUSHINT(SAVEt_DELETE);
595 Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
600 for (i = 1; i <= maxsarg; i++) {
602 sv_setsv(sv,sarg[i]);
604 SSPUSHPTR(sarg[i]); /* remember the pointer */
605 SSPUSHPTR(sv); /* remember the value */
606 SSPUSHINT(SAVEt_ITEM);
611 Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p)
616 SSPUSHINT(SAVEt_DESTRUCTOR);
620 Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
625 SSPUSHINT(SAVEt_DESTRUCTOR_X);
629 Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
633 SSPUSHPTR(SvREFCNT_inc(av));
635 SSPUSHPTR(SvREFCNT_inc(*sptr));
636 SSPUSHINT(SAVEt_AELEM);
637 /* if it gets reified later, the restore will have the wrong refcnt */
638 if (!AvREAL(av) && AvREIFY(av))
640 save_scalar_at(sptr);
642 /* If we're localizing a tied array element, this new sv
643 * won't actually be stored in the array - so it won't get
644 * reaped when the localize ends. Ensure it gets reaped by
645 * mortifying it instead. DAPM */
646 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
651 Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
655 SSPUSHPTR(SvREFCNT_inc(hv));
656 SSPUSHPTR(SvREFCNT_inc(key));
657 SSPUSHPTR(SvREFCNT_inc(*sptr));
658 SSPUSHINT(SAVEt_HELEM);
659 save_scalar_at(sptr);
661 /* If we're localizing a tied hash element, this new sv
662 * won't actually be stored in the hash - so it won't get
663 * reaped when the localize ends. Ensure it gets reaped by
664 * mortifying it instead. DAPM */
665 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
678 Perl_save_alloc(pTHX_ I32 size, I32 pad)
680 register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
681 - (char*)PL_savestack);
682 register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
684 /* SSCHECK may not be good enough */
685 while (PL_savestack_ix + elems + 2 > PL_savestack_max)
688 PL_savestack_ix += elems;
690 SSPUSHINT(SAVEt_ALLOC);
695 Perl_leave_scope(pTHX_ I32 base)
707 Perl_croak(aTHX_ "panic: corrupt saved stack index");
708 while (PL_savestack_ix > base) {
710 case SAVEt_ITEM: /* normal string */
711 value = (SV*)SSPOPPTR;
713 sv_replace(sv,value);
718 case SAVEt_SV: /* scalar reference */
719 value = (SV*)SSPOPPTR;
722 av = (AV*)gv; /* what to refcnt_dec */
724 case SAVEt_GENERIC_PVREF: /* generic pv */
725 str = (char*)SSPOPPTR;
727 if (*(char**)ptr != str) {
728 Safefree(*(char**)ptr);
732 case SAVEt_SHARED_PVREF: /* shared pv */
733 str = (char*)SSPOPPTR;
735 if (*(char**)ptr != str) {
737 PerlMem_free(*(char**)ptr);
739 PerlMemShared_free(*(char**)ptr);
744 case SAVEt_GENERIC_SVREF: /* generic sv */
745 value = (SV*)SSPOPPTR;
752 case SAVEt_SVREF: /* scalar reference */
753 value = (SV*)SSPOPPTR;
755 av = Nullav; /* what to refcnt_dec */
758 DEBUG_S(PerlIO_printf(Perl_debug_log,
759 "restore svref: %p %p:%s -> %p:%s\n",
760 ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
761 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
762 SvTYPE(sv) != SVt_PVGV)
764 (void)SvUPGRADE(value, SvTYPE(sv));
765 SvMAGIC(value) = SvMAGIC(sv);
766 SvFLAGS(value) |= SvMAGICAL(sv);
770 /* XXX This branch is pretty bogus. This code irretrievably
771 * clears(!) the magic on the SV (either to avoid further
772 * croaking that might ensue when the SvSETMAGIC() below is
773 * called, or to avoid two different SVs pointing at the same
774 * SvMAGIC()). This needs a total rethink. --GSAR */
775 else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
776 SvTYPE(value) != SVt_PVGV)
778 SvFLAGS(value) |= (SvFLAGS(value) &
779 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
780 SvMAGICAL_off(value);
781 /* XXX this is a leak when we get here because the
782 * mg_get() in save_scalar_at() croaked */
791 if (av) /* actually an av, hv or gv */
794 case SAVEt_AV: /* array reference */
798 AV *goner = GvAV(gv);
799 SvMAGIC(av) = SvMAGIC(goner);
800 SvFLAGS((SV*)av) |= SvMAGICAL(goner);
801 SvMAGICAL_off(goner);
812 case SAVEt_HV: /* hash reference */
816 HV *goner = GvHV(gv);
817 SvMAGIC(hv) = SvMAGIC(goner);
818 SvFLAGS(hv) |= SvMAGICAL(goner);
819 SvMAGICAL_off(goner);
830 case SAVEt_INT: /* int reference */
832 *(int*)ptr = (int)SSPOPINT;
834 case SAVEt_LONG: /* long reference */
836 *(long*)ptr = (long)SSPOPLONG;
838 case SAVEt_BOOL: /* bool reference */
840 *(bool*)ptr = (bool)SSPOPBOOL;
842 case SAVEt_I32: /* I32 reference */
844 *(I32*)ptr = (I32)SSPOPINT;
846 case SAVEt_I16: /* I16 reference */
848 *(I16*)ptr = (I16)SSPOPINT;
850 case SAVEt_I8: /* I8 reference */
852 *(I8*)ptr = (I8)SSPOPINT;
854 case SAVEt_IV: /* IV reference */
856 *(IV*)ptr = (IV)SSPOPIV;
858 case SAVEt_SPTR: /* SV* reference */
860 *(SV**)ptr = (SV*)SSPOPPTR;
862 case SAVEt_VPTR: /* random* reference */
863 case SAVEt_PPTR: /* char* reference */
865 *(char**)ptr = (char*)SSPOPPTR;
867 case SAVEt_HPTR: /* HV* reference */
869 *(HV**)ptr = (HV*)SSPOPPTR;
871 case SAVEt_APTR: /* AV* reference */
873 *(AV**)ptr = (AV*)SSPOPPTR;
877 (void)sv_clear((SV*)gv);
879 case SAVEt_GP: /* scalar reference */
882 if (SvPVX(gv) && SvLEN(gv) > 0) {
885 SvPVX(gv) = (char *)SSPOPPTR;
886 SvCUR(gv) = (STRLEN)SSPOPIV;
887 SvLEN(gv) = (STRLEN)SSPOPIV;
891 PL_sub_generation++; /* putting a method back into circulation */
896 SvREFCNT_dec((SV*)ptr);
898 case SAVEt_MORTALIZESV:
900 sv_2mortal((SV*)ptr);
904 ASSERT_CURPAD_LEGAL("SAVEt_FREEOP"); /* XXX DAPM tmp */
909 Safefree((char*)ptr);
912 ptr = (void*)&PL_curpad[SSPOPLONG];
915 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
916 "Pad 0x%"UVxf"[0x%"UVxf"] clearsv: %ld sv=0x%"UVxf"<%"IVdf"> %s\n",
917 PTR2UV(PL_comppad), PTR2UV(PL_curpad),
918 (long)((SV **)ptr-PL_curpad), PTR2UV(sv), (IV)SvREFCNT(sv),
919 (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) ? "clear" : "abandon"
922 /* Can clear pad variable in place? */
923 if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
925 * if a my variable that was made readonly is going out of
926 * scope, we want to remove the readonlyness so that it can
927 * go out of scope quietly
929 if (SvPADMY(sv) && !SvFAKE(sv))
932 if (SvTHINKFIRST(sv))
933 sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
937 switch (SvTYPE(sv)) {
947 Perl_croak(aTHX_ "panic: leave_scope pad code");
958 SvPADSTALE_on(sv); /* mark as no longer live */
960 else { /* Someone has a claim on this, so abandon it. */
961 U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
962 switch (SvTYPE(sv)) { /* Console ourselves with a new value */
963 case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
964 case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
965 default: *(SV**)ptr = NEWSV(0,0); break;
967 SvREFCNT_dec(sv); /* Cast current value to the winds. */
968 /* preserve pad nature, but also mark as not live
969 * for any closure capturing */
970 SvFLAGS(*(SV**)ptr) |= padflags | SVs_PADSTALE;
977 (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
981 case SAVEt_DESTRUCTOR:
985 case SAVEt_DESTRUCTOR_X:
987 (*SSPOPDXPTR)(aTHX_ ptr);
989 case SAVEt_REGCONTEXT:
992 PL_savestack_ix -= i; /* regexp must have croaked */
994 case SAVEt_STACK_POS: /* Position on Perl stack */
996 PL_stack_sp = PL_stack_base + i;
998 case SAVEt_AELEM: /* array element */
999 value = (SV*)SSPOPPTR;
1002 if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
1003 SvREFCNT_dec(value);
1004 ptr = av_fetch(av,i,1);
1007 if (sv && sv != &PL_sv_undef) {
1008 if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
1009 (void)SvREFCNT_inc(sv);
1014 SvREFCNT_dec(value);
1016 case SAVEt_HELEM: /* hash element */
1017 value = (SV*)SSPOPPTR;
1020 ptr = hv_fetch_ent(hv, sv, 1, 0);
1022 SV *oval = HeVAL((HE*)ptr);
1023 if (oval && oval != &PL_sv_undef) {
1024 ptr = &HeVAL((HE*)ptr);
1025 if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
1026 (void)SvREFCNT_inc(*(SV**)ptr);
1028 av = (AV*)hv; /* what to refcnt_dec */
1034 SvREFCNT_dec(value);
1037 PL_op = (OP*)SSPOPPTR;
1040 if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) {
1041 SvREFCNT_dec((SV*)GvHV(PL_hintgv));
1042 GvHV(PL_hintgv) = NULL;
1044 *(I32*)&PL_hints = (I32)SSPOPINT;
1047 PL_comppad = (PAD*)SSPOPPTR;
1049 PL_curpad = AvARRAY(PL_comppad);
1051 PL_curpad = Null(SV**);
1055 PADOFFSET off = (PADOFFSET)SSPOPLONG;
1058 AvARRAY((PAD*)ptr)[off] = (SV*)SSPOPPTR;
1061 case SAVEt_SET_SVFLAGS:
1063 U32 val = (U32)SSPOPINT;
1064 U32 mask = (U32)SSPOPINT;
1066 SvFLAGS(sv) &= ~mask;
1071 Perl_croak(aTHX_ "panic: leave_scope inconsistency");
1077 Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
1080 PerlIO_printf(Perl_debug_log, "CX %ld = %s\n", (long)(cx - cxstack), PL_block_type[CxTYPE(cx)]);
1081 if (CxTYPE(cx) != CXt_SUBST) {
1082 PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp);
1083 PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%"UVxf"\n",
1084 PTR2UV(cx->blk_oldcop));
1085 PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp);
1086 PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp);
1087 PerlIO_printf(Perl_debug_log, "BLK_OLDRETSP = %ld\n", (long)cx->blk_oldretsp);
1088 PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%"UVxf"\n",
1089 PTR2UV(cx->blk_oldpm));
1090 PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR");
1092 switch (CxTYPE(cx)) {
1097 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1098 PTR2UV(cx->blk_sub.cv));
1099 PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
1100 PTR2UV(cx->blk_sub.gv));
1101 PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
1102 PTR2UV(cx->blk_sub.dfoutgv));
1103 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1104 (int)cx->blk_sub.hasargs);
1107 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1108 PTR2UV(cx->blk_sub.cv));
1109 PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
1110 (long)cx->blk_sub.olddepth);
1111 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1112 (int)cx->blk_sub.hasargs);
1113 PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
1114 (int)cx->blk_sub.lval);
1117 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n",
1118 (long)cx->blk_eval.old_in_eval);
1119 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
1120 PL_op_name[cx->blk_eval.old_op_type],
1121 PL_op_desc[cx->blk_eval.old_op_type]);
1122 if (cx->blk_eval.old_namesv)
1123 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
1124 SvPVX(cx->blk_eval.old_namesv));
1125 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
1126 PTR2UV(cx->blk_eval.old_eval_root));
1130 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n",
1131 cx->blk_loop.label);
1132 PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
1133 (long)cx->blk_loop.resetsp);
1134 PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
1135 PTR2UV(cx->blk_loop.redo_op));
1136 PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
1137 PTR2UV(cx->blk_loop.next_op));
1138 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
1139 PTR2UV(cx->blk_loop.last_op));
1140 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
1141 (long)cx->blk_loop.iterix);
1142 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
1143 PTR2UV(cx->blk_loop.iterary));
1144 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
1145 PTR2UV(CxITERVAR(cx)));
1147 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
1148 PTR2UV(cx->blk_loop.itersave));
1149 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%"UVxf"\n",
1150 PTR2UV(cx->blk_loop.iterlval));
1154 PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n",
1155 (long)cx->sb_iters);
1156 PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n",
1157 (long)cx->sb_maxiters);
1158 PerlIO_printf(Perl_debug_log, "SB_RFLAGS = %ld\n",
1159 (long)cx->sb_rflags);
1160 PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n",
1162 PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n",
1164 PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%"UVxf"\n",
1165 PTR2UV(cx->sb_dstr));
1166 PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%"UVxf"\n",
1167 PTR2UV(cx->sb_targ));
1168 PerlIO_printf(Perl_debug_log, "SB_S = 0x%"UVxf"\n",
1170 PerlIO_printf(Perl_debug_log, "SB_M = 0x%"UVxf"\n",
1172 PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%"UVxf"\n",
1173 PTR2UV(cx->sb_strend));
1174 PerlIO_printf(Perl_debug_log, "SB_RXRES = 0x%"UVxf"\n",
1175 PTR2UV(cx->sb_rxres));
1178 #endif /* DEBUGGING */