This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
disable cwd_enoent test
[perl5.git] / scope.c
diff --git a/scope.c b/scope.c
index a7c17e8..b09a25d 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -55,6 +55,10 @@ Perl_stack_grow(pTHX_ SV **sp, SV **p, SSize_t n)
         Perl_croak(aTHX_ "Out of memory during stack extend");
 
     av_extend(PL_curstack, current + n + extra);
+#ifdef DEBUGGING
+        PL_curstackinfo->si_stack_hwm = current + n + extra;
+#endif
+
     return PL_stack_sp;
 }
 
@@ -326,6 +330,17 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
 {
     PERL_ARGS_ASSERT_SAVE_GP;
 
+    /* XXX For now, we just upgrade any coderef in the stash to a full GV
+           during localisation.  Maybe at some point we could make localis-
+           ation work without needing the upgrade.  (In which case our
+           callers should probably call a different function, not save_gp.)
+     */
+    if (!isGV(gv)) {
+        assert(isGV_or_RVCV(gv));
+        (void)CvGV(SvRV((SV *)gv)); /* CvGV does the upgrade */
+        assert(isGV(gv));
+    }
+
     save_pushptrptr(SvREFCNT_inc(gv), GvGP(gv), SAVEt_GP);
 
     if (empty) {
@@ -334,7 +349,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
        bool isa_changed = 0;
 
        if (stash && HvENAME(stash)) {
-           if (GvNAMELEN(gv) == 3 && strnEQ(GvNAME(gv), "ISA", 3))
+           if (memEQs(GvNAME(gv), GvNAMELEN(gv), "ISA"))
                isa_changed = TRUE;
            else if (GvCVu(gv))
                /* taking a method out of circulation ("local")*/
@@ -1076,9 +1091,7 @@ Perl_leave_scope(pTHX_ I32 base)
            gp_free(a0.any_gv);
            GvGP_set(a0.any_gv, (GP*)a1.any_ptr);
            if ((hv=GvSTASH(a0.any_gv)) && HvENAME_get(hv)) {
-               if (   GvNAMELEN(a0.any_gv) == 3
-                    && strnEQ(GvNAME(a0.any_gv), "ISA", 3)
-                )
+               if (memEQs(GvNAME(a0.any_gv), GvNAMELEN(a0.any_gv), "ISA"))
                    mro_isa_changed_in(hv);
                 else if (had_method || GvCVu(a0.any_gv))
                     /* putting a method back into circulation ("local")*/      
@@ -1190,10 +1203,7 @@ Perl_leave_scope(pTHX_ I32 base)
                         break;
                     case SVt_PVCV:
                     {
-                        HEK *hek =
-                             CvNAMED(sv)
-                               ? CvNAME_HEK((CV *)sv)
-                               : GvNAME_HEK(CvGV(sv));
+                        HEK *hek = CvGvNAME_HEK(sv);
                         assert(hek);
                         (void)share_hek_hek(hek);
                         cv_undef((CV *)sv);
@@ -1219,9 +1229,7 @@ Perl_leave_scope(pTHX_ I32 base)
                     case SVt_PVHV:     *svp = MUTABLE_SV(newHV());     break;
                     case SVt_PVCV:
                     {
-                        HEK * const hek = CvNAMED(sv)
-                                             ? CvNAME_HEK((CV *)sv)
-                                             : GvNAME_HEK(CvGV(sv));
+                        HEK * const hek = CvGvNAME_HEK(sv);
 
                         /* Create a stub */
                         *svp = newSV_type(SVt_PVCV);
@@ -1522,6 +1530,7 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
                PTR2UV(cx->blk_eval.retop));
        break;
 
+    case CXt_LOOP_GIVEN:
     case CXt_LOOP_PLAIN:
     case CXt_LOOP_LAZYIV:
     case CXt_LOOP_LAZYSV:
@@ -1535,7 +1544,8 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
                     PTR2UV(CxITERVAR(cx)));
             PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%" UVxf "\n",
                     PTR2UV(cx->blk_loop.itersave));
-            /* XXX: not accurate for LAZYSV/IV/LIST */
+       }
+       if (CxTYPE(cx) == CXt_LOOP_ARY) {
             PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%" UVxf "\n",
                     PTR2UV(cx->blk_loop.state_u.ary.ary));
             PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",