Change 29929 by [EMAIL PROTECTED] on 2007/01/22 23:29:42

        Integrate:
        [ 27671]
        Abstract all the accesses to cop_arybase (apart from ByteLoader)
        
        [ 27674]
        Convert ByteLoader to use CopARYBASE_set().
        
        [ 27677]
        Abstract all reads/writes of the hints in COPs with 2 new macros,
        CopHINTS_get() and CopHINTS_set().
        
        [ 27687]
        Change 27677 missed two direct accesses to op_private in COPs.
        I believe that all are now found, as redefining CopHINTS_get(c)
        to (~(c)->op_private) (with corresponding changes to CopHINTS_set()
        and the initialisation of PL_compiling) works.

Affected files ...

... //depot/maint-5.8/perl/bytecode.pl#19 integrate
... //depot/maint-5.8/perl/cop.h#28 integrate
... //depot/maint-5.8/perl/ext/B/B.xs#23 integrate
... //depot/maint-5.8/perl/ext/ByteLoader/bytecode.h#11 integrate
... //depot/maint-5.8/perl/ext/ByteLoader/byterun.c#13 integrate
... //depot/maint-5.8/perl/mg.c#130 integrate
... //depot/maint-5.8/perl/op.c#169 integrate
... //depot/maint-5.8/perl/perl.h#134 integrate
... //depot/maint-5.8/perl/pp.c#117 integrate
... //depot/maint-5.8/perl/pp_ctl.c#151 integrate
... //depot/maint-5.8/perl/pp_hot.c#117 integrate
... //depot/maint-5.8/perl/scope.c#58 integrate
... //depot/maint-5.8/perl/scope.h#21 integrate
... //depot/maint-5.8/perl/toke.c#140 integrate
... //depot/maint-5.8/perl/utf8.c#68 integrate
... //depot/maint-5.8/perl/utf8.h#16 integrate

Differences ...

==== //depot/maint-5.8/perl/bytecode.pl#19 (text) ====
Index: perl/bytecode.pl
--- perl/bytecode.pl#18~26716~  2006-01-08 07:57:01.000000000 -0800
+++ perl/bytecode.pl    2007-01-22 15:29:42.000000000 -0800
@@ -488,7 +488,7 @@
 cop_filegv     cCOP                                    svindex         x
 #endif
 cop_seq                cCOP->cop_seq                           U32
-cop_arybase    cCOP->cop_arybase                       I32
+cop_arybase    cCOP                                    I32             x
 cop_line       cCOP->cop_line                          line_t
 cop_io         cCOP->cop_io                            svindex
 cop_warnings   cCOP->cop_warnings                      svindex

==== //depot/maint-5.8/perl/cop.h#28 (text) ====
Index: perl/cop.h
--- perl/cop.h#27~29925~        2007-01-22 14:10:59.000000000 -0800
+++ perl/cop.h  2007-01-22 15:29:42.000000000 -0800
@@ -97,6 +97,18 @@
 #  define OutCopFILE(c) CopFILE(c)
 #endif
 
+/* CopARYBASE is likely to be removed soon.  */
+#define CopARYBASE(c)          ((c)->cop_arybase)
+#define CopARYBASE_get(c)      ((c)->cop_arybase + 0)
+#define CopARYBASE_set(c, b)   STMT_START { (c)->cop_arybase = (b); } STMT_END
+
+/* FIXME NATIVE_HINTS if this is changed from op_private (see perl.h)  */
+#define CopHINTS_get(c)                ((c)->op_private + 0)
+#define CopHINTS_set(c, h)     STMT_START {                            \
+                                   (c)->op_private                     \
+                                        = (U8)((h) & HINT_PRIVATE_MASK); \
+                               } STMT_END
+
 /*
  * Here we have some enormously heavy (or at least ponderous) wizardry.
  */

==== //depot/maint-5.8/perl/ext/B/B.xs#23 (text) ====
Index: perl/ext/B/B.xs
--- perl/ext/B/B.xs#22~29858~   2007-01-17 13:17:52.000000000 -0800
+++ perl/ext/B/B.xs     2007-01-22 15:29:42.000000000 -0800
@@ -1042,7 +1042,7 @@
 #define COP_file(o)    CopFILE(o)
 #define COP_filegv(o)  CopFILEGV(o)
 #define COP_cop_seq(o) o->cop_seq
-#define COP_arybase(o) o->cop_arybase
+#define COP_arybase(o) CopARYBASE_get(o)
 #define COP_line(o)    CopLINE(o)
 #define COP_warnings(o)        o->cop_warnings
 #define COP_io(o)      o->cop_io

==== //depot/maint-5.8/perl/ext/ByteLoader/bytecode.h#11 (text) ====
Index: perl/ext/ByteLoader/bytecode.h
--- perl/ext/ByteLoader/bytecode.h#10~29807~    2007-01-14 05:09:22.000000000 
-0800
+++ perl/ext/ByteLoader/bytecode.h      2007-01-22 15:29:42.000000000 -0800
@@ -348,6 +348,7 @@
                name, strlen(name), cv, 0))
 
 #define BSET_xhv_name(hv, name)        hv_name_set((HV*)hv, name, 
strlen(name), 0)
+#define BSET_cop_arybase(c, b) CopARYBASE_set(c, b)
 
 /* NOTE: the bytecode header only sanity-checks the bytecode. If a script 
cares about
  * what version of Perl it's being called under, it should do a 'use 
5.006_001' or

==== //depot/maint-5.8/perl/ext/ByteLoader/byterun.c#13 (text+w) ====
Index: perl/ext/ByteLoader/byterun.c
--- perl/ext/ByteLoader/byterun.c#12~25572~     2005-09-22 09:46:28.000000000 
-0700
+++ perl/ext/ByteLoader/byterun.c       2007-01-22 15:29:42.000000000 -0800
@@ -970,7 +970,7 @@
            {
                I32 arg;
                BGET_I32(arg);
-               cCOP->cop_arybase = arg;
+               BSET_cop_arybase(cCOP, arg);
                break;
            }
          case INSN_COP_LINE:           /* 130 */

==== //depot/maint-5.8/perl/mg.c#130 (text) ====
Index: perl/mg.c
--- perl/mg.c#129~29925~        2007-01-22 14:10:59.000000000 -0800
+++ perl/mg.c   2007-01-22 15:29:42.000000000 -0800
@@ -963,7 +963,7 @@
     case '/':
        break;
     case '[':
-       WITH_THR(sv_setiv(sv, (IV)PL_curcop->cop_arybase));
+       WITH_THR(sv_setiv(sv, (IV)CopARYBASE_get(PL_curcop)));
        break;
     case '|':
        if (GvIOp(PL_defoutgv))
@@ -1739,7 +1739,7 @@
 {
     AV *obj = (AV*)mg->mg_obj;
     if (obj) {
-       sv_setiv(sv, AvFILL(obj) + PL_curcop->cop_arybase);
+       sv_setiv(sv, AvFILL(obj) + CopARYBASE_get(PL_curcop));
     } else {
        SvOK_off(sv);
     }
@@ -1751,7 +1751,7 @@
 {
     AV *obj = (AV*)mg->mg_obj;
     if (obj) {
-       av_fill(obj, SvIV(sv) - PL_curcop->cop_arybase);
+       av_fill(obj, SvIV(sv) - CopARYBASE_get(PL_curcop));
     } else {
        if (ckWARN(WARN_MISC))
            Perl_warner(aTHX_ packWARN(WARN_MISC),
@@ -1771,7 +1771,7 @@
            I32 i = mg->mg_len;
            if (DO_UTF8(lsv))
                sv_pos_b2u(lsv, &i);
-           sv_setiv(sv, i + PL_curcop->cop_arybase);
+           sv_setiv(sv, i + CopARYBASE_get(PL_curcop));
            return 0;
        }
     }
@@ -1807,7 +1807,7 @@
     }
     len = SvPOK(lsv) ? SvCUR(lsv) : sv_len(lsv);
 
-    pos = SvIV(sv) - PL_curcop->cop_arybase;
+    pos = SvIV(sv) - CopARYBASE_get(PL_curcop);
 
     if (DO_UTF8(lsv)) {
        ulen = sv_len_utf8(lsv);
@@ -2397,7 +2397,7 @@
        PL_ofmt = savesvpv(sv);
        break;
     case '[':
-       PL_compiling.cop_arybase = SvIV(sv);
+       CopARYBASE_set(&PL_compiling, SvIV(sv));
        break;
     case '?':
 #ifdef COMPLEX_STATUS

==== //depot/maint-5.8/perl/op.c#169 (text) ====
Index: perl/op.c
--- perl/op.c#168~29925~        2007-01-22 14:10:59.000000000 -0800
+++ perl/op.c   2007-01-22 15:29:42.000000000 -0800
@@ -1074,12 +1074,13 @@
        if (!(o->op_private & OPpCONST_ARYBASE))
            goto nomod;
        if (PL_eval_start && PL_eval_start->op_type == OP_CONST) {
-           PL_compiling.cop_arybase = (I32)SvIV(cSVOPx(PL_eval_start)->op_sv);
+           CopARYBASE_set(&PL_compiling,
+                          (I32)SvIV(cSVOPx(PL_eval_start)->op_sv));
            PL_eval_start = 0;
        }
        else if (!type) {
-           SAVEI32(PL_compiling.cop_arybase);
-           PL_compiling.cop_arybase = 0;
+           SAVECOPARYBASE(&PL_compiling);
+           CopARYBASE_set(&PL_compiling, 0);
        }
        else if (type == OP_REFGEN)
            goto nomod;
@@ -1949,7 +1950,7 @@
     /* If there were syntax errors, don't try to close a block */
     if (PL_yynerrs) return retval;
     LEAVE_SCOPE(floor);
-    PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
+    CopHINTS_set(&PL_compiling, PL_hints);
     if (needblockscope)
        PL_hints |= HINT_BLOCK_SCOPE; /* propagate out */
     pad_leavemy();
@@ -3520,7 +3521,7 @@
            PL_eval_start = 0;
        else {
            op_free(o);
-           o = newSVOP(OP_CONST, 0, newSViv(PL_compiling.cop_arybase));
+           o = newSVOP(OP_CONST, 0, newSViv(CopARYBASE_get(&PL_compiling)));
            o->op_private |= OPpCONST_ARYBASE;
        }
     }
@@ -3543,11 +3544,11 @@
        cop->op_ppaddr = PL_ppaddr[ OP_NEXTSTATE ];
     }
     cop->op_flags = (U8)flags;
-    cop->op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
+    CopHINTS_set(cop, PL_hints);
 #ifdef NATIVE_HINTS
     cop->op_private |= NATIVE_HINTS;
 #endif
-    PL_compiling.op_private = cop->op_private;
+    CopHINTS_set(&PL_compiling, CopHINTS_get(cop));
     cop->op_next = (OP*)cop;
 
     if (label) {
@@ -3555,7 +3556,7 @@
        PL_hints |= HINT_BLOCK_SCOPE;
     }
     cop->cop_seq = seq;
-    cop->cop_arybase = PL_curcop->cop_arybase;
+    CopARYBASE_set(cop, CopARYBASE_get(PL_curcop));
     if (specialWARN(PL_curcop->cop_warnings))
         cop->cop_warnings = PL_curcop->cop_warnings ;
     else
@@ -4623,7 +4624,7 @@
            call_list(oldscope, PL_beginav);
 
            PL_curcop = &PL_compiling;
-           PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
+           CopHINTS_set(&PL_compiling, PL_hints);
            LEAVE;
        }
        else if (strEQ(s, "END") && !PL_error_count) {
@@ -6684,7 +6685,7 @@
                    pop->op_next->op_type == OP_AELEM &&
                    !(pop->op_next->op_private &
                      (OPpLVAL_INTRO|OPpLVAL_DEFER|OPpDEREF|OPpMAYBE_LVSUB)) &&
-                   (i = SvIV(((SVOP*)pop)->op_sv) - PL_curcop->cop_arybase)
+                   (i = SvIV(((SVOP*)pop)->op_sv) - CopARYBASE_get(PL_curcop))
                                <= 255 &&
                    i >= 0)
                {

==== //depot/maint-5.8/perl/perl.h#134 (text) ====
Index: perl/perl.h
--- perl/perl.h#133~29925~      2007-01-22 14:10:59.000000000 -0800
+++ perl/perl.h 2007-01-22 15:29:42.000000000 -0800
@@ -4948,7 +4948,7 @@
 #define SET_NUMERIC_LOCAL() \
        set_numeric_local();
 
-#define IN_LOCALE_RUNTIME      (PL_curcop->op_private & HINT_LOCALE)
+#define IN_LOCALE_RUNTIME      (CopHINTS_get(PL_curcop) & HINT_LOCALE)
 #define IN_LOCALE_COMPILETIME  (PL_hints & HINT_LOCALE)
 
 #define IN_LOCALE \

==== //depot/maint-5.8/perl/pp.c#117 (text) ====
Index: perl/pp.c
--- perl/pp.c#116~29925~        2007-01-22 14:10:59.000000000 -0800
+++ perl/pp.c   2007-01-22 15:29:42.000000000 -0800
@@ -328,7 +328,7 @@
                I32 i = mg->mg_len;
                if (DO_UTF8(sv))
                    sv_pos_b2u(sv, &i);
-               PUSHi(i + PL_curcop->cop_arybase);
+               PUSHi(i + CopARYBASE_get(PL_curcop));
                RETURN;
            }
        }
@@ -2906,7 +2906,7 @@
     I32 fail;
     const I32 lvalue = PL_op->op_flags & OPf_MOD || LVRET;
     const char *tmps;
-    const I32 arybase = PL_curcop->cop_arybase;
+    const I32 arybase = CopARYBASE_get(PL_curcop);
     SV *repl_sv = NULL;
     const char *repl = NULL;
     STRLEN repl_len;
@@ -3105,7 +3105,7 @@
     I32 retval;
     const char *big_p;
     const char *little_p;
-    const I32 arybase = PL_curcop->cop_arybase;
+    const I32 arybase = CopARYBASE_get(PL_curcop);
     bool big_utf8;
     bool little_utf8;
     const bool is_index = PL_op->op_type == OP_INDEX;
@@ -3722,7 +3722,7 @@
     register const I32 lval = (PL_op->op_flags & OPf_MOD || LVRET);
 
     if (SvTYPE(av) == SVt_PVAV) {
-       const I32 arybase = PL_curcop->cop_arybase;
+       const I32 arybase = CopARYBASE_get(PL_curcop);
        if (lval && PL_op->op_private & OPpLVAL_INTRO) {
            register SV **svp;
            I32 max = -1;
@@ -3986,7 +3986,7 @@
     SV ** const lastlelem = PL_stack_base + POPMARK;
     SV ** const firstlelem = PL_stack_base + POPMARK + 1;
     register SV ** const firstrelem = lastlelem + 1;
-    const I32 arybase = PL_curcop->cop_arybase;
+    const I32 arybase = CopARYBASE_get(PL_curcop);
     I32 is_something_there = PL_op->op_flags & OPf_MOD;
 
     register const I32 max = lastrelem - lastlelem;
@@ -4096,7 +4096,7 @@
        if (offset < 0)
            offset += AvFILLp(ary) + 1;
        else
-           offset -= PL_curcop->cop_arybase;
+           offset -= CopARYBASE_get(PL_curcop);
        if (offset < 0)
            DIE(aTHX_ PL_no_aelem, i);
        if (++MARK < SP) {

==== //depot/maint-5.8/perl/pp_ctl.c#151 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#150~29928~    2007-01-22 15:12:43.000000000 -0800
+++ perl/pp_ctl.c       2007-01-22 15:29:42.000000000 -0800
@@ -1560,8 +1560,7 @@
     /* XXX only hints propagated via op_private are currently
      * visible (others are not easily accessible, since they
      * use the global PL_hints) */
-    PUSHs(sv_2mortal(newSViv((I32)cx->blk_oldcop->op_private &
-                            HINT_PRIVATE_MASK)));
+    PUSHs(sv_2mortal(newSViv(CopHINTS_get(cx->blk_oldcop))));
     {
        SV * mask ;
        SV * const old_warnings = cx->blk_oldcop->cop_warnings ;
@@ -2722,7 +2721,7 @@
     *padp = (AV*)SvREFCNT_inc_simple(PL_comppad);
     LEAVE;
     if (IN_PERL_COMPILETIME)
-       PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
+       CopHINTS_set(&PL_compiling, PL_hints);
 #ifdef OP_IN_REGISTER
     op = PL_opsave;
 #endif
@@ -2831,7 +2830,7 @@
     PL_eval_root = NULL;
     PL_error_count = 0;
     PL_curcop = &PL_compiling;
-    PL_curcop->cop_arybase = 0;
+    CopARYBASE_set(PL_curcop, 0);
     if (saveop && (saveop->op_type != OP_REQUIRE) && (saveop->op_flags & 
OPf_SPECIAL))
        PL_in_eval |= EVAL_KEEPERR;
     else

==== //depot/maint-5.8/perl/pp_hot.c#117 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#116~29925~    2007-01-22 14:10:59.000000000 -0800
+++ perl/pp_hot.c       2007-01-22 15:29:42.000000000 -0800
@@ -3060,7 +3060,7 @@
     if (SvROK(elemsv) && !SvGAMAGIC(elemsv) && ckWARN(WARN_MISC))
        Perl_warner(aTHX_ packWARN(WARN_MISC), "Use of reference \"%"SVf"\" as 
array index", elemsv);
     if (elem > 0)
-       elem -= PL_curcop->cop_arybase;
+       elem -= CopARYBASE_get(PL_curcop);
     if (SvTYPE(av) != SVt_PVAV)
        RETPUSHUNDEF;
     svp = av_fetch(av, elem, lval && !defer);

==== //depot/maint-5.8/perl/scope.c#58 (text) ====
Index: perl/scope.c
--- perl/scope.c#57~29928~      2007-01-22 15:12:43.000000000 -0800
+++ perl/scope.c        2007-01-22 15:29:42.000000000 -0800
@@ -961,6 +961,11 @@
            ptr = SSPOPPTR;
            (*SSPOPDPTR)(ptr);
            break;
+       case SAVEt_COP_ARYBASE:
+           ptr = SSPOPPTR;
+           i = SSPOPINT;
+           CopARYBASE_set((COP *)ptr, i);
+           break;
        case SAVEt_RE_STATE:
            {
                const struct re_save_state *const state

==== //depot/maint-5.8/perl/scope.h#21 (text) ====
Index: perl/scope.h
--- perl/scope.h#20~29859~      2007-01-17 14:07:40.000000000 -0800
+++ perl/scope.h        2007-01-22 15:29:42.000000000 -0800
@@ -48,6 +48,7 @@
 #define SAVEt_SHARED_PVREF     37
 #define SAVEt_BOOL             38
 #define SAVEt_SAVESWITCHSTACK  40
+#define SAVEt_COP_ARYBASE      41
 #define SAVEt_RE_STATE         42
 #define SAVEt_GP_NEW           43
 
@@ -181,6 +182,15 @@
        PL_curstackinfo->si_stack = (t);                \
     } STMT_END
 
+#define SAVECOPARYBASE(c) \
+    STMT_START {                                       \
+       SSCHECK(3);                                     \
+       SSPUSHINT(CopARYBASE_get(c));                   \
+       SSPUSHPTR(c);                                   \
+       SSPUSHINT(SAVEt_COP_ARYBASE);                   \
+    } STMT_END
+
+
 #ifdef USE_ITHREADS
 #  define SAVECOPSTASH(c)      SAVEPPTR(CopSTASHPV(c))
 #  define SAVECOPSTASH_FREE(c) SAVESHAREDPV(CopSTASHPV(c))

==== //depot/maint-5.8/perl/toke.c#140 (text) ====
Index: perl/toke.c
--- perl/toke.c#139~29925~      2007-01-22 14:10:59.000000000 -0800
+++ perl/toke.c 2007-01-22 15:29:42.000000000 -0800
@@ -3756,7 +3756,7 @@
        /* This kludge not intended to be bulletproof. */
        if (PL_tokenbuf[1] == '[' && !PL_tokenbuf[2]) {
            yylval.opval = newSVOP(OP_CONST, 0,
-                                  newSViv(PL_compiling.cop_arybase));
+                                  newSViv(CopARYBASE_get(&PL_compiling)));
            yylval.opval->op_private = OPpCONST_ARYBASE;
            TERM(THING);
        }

==== //depot/maint-5.8/perl/utf8.c#68 (text) ====
Index: perl/utf8.c
--- perl/utf8.c#67~29925~       2007-01-22 14:10:59.000000000 -0800
+++ perl/utf8.c 2007-01-22 15:29:42.000000000 -0800
@@ -1585,7 +1585,7 @@
        const char* const pv = SvPV_const(tokenbufsv, len);
 
        Copy(pv, PL_tokenbuf, len+1, char);
-       PL_curcop->op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
+       CopHINTS_set(PL_curcop, PL_hints);
     }
     if (!SvROK(retval) || SvTYPE(SvRV(retval)) != SVt_PVHV) {
         if (SvPOK(retval))
@@ -1685,7 +1685,7 @@
                                needents);
 
            if (IN_PERL_COMPILETIME)
-               PL_curcop->op_private = (U8)(PL_hints & HINT_PRIVATE_MASK);
+               CopHINTS_set(PL_curcop, PL_hints);
 
            svp = hv_store(hv, (const char *)ptr, klen, swatch, 0);
 

==== //depot/maint-5.8/perl/utf8.h#16 (text) ====
Index: perl/utf8.h
--- perl/utf8.h#15~29770~       2007-01-12 04:22:53.000000000 -0800
+++ perl/utf8.h 2007-01-22 15:29:42.000000000 -0800
@@ -183,7 +183,7 @@
  * SpecialCasing.txt. */
 #define UTF8_MAXBYTES_CASE     6
 
-#define IN_BYTES (PL_curcop->op_private & HINT_BYTES)
+#define IN_BYTES (CopHINTS_get(PL_curcop) & HINT_BYTES)
 #define DO_UTF8(sv) (SvUTF8(sv) && !IN_BYTES)
 
 #define UTF8_ALLOW_EMPTY               0x0001
End of Patch.

Reply via email to