Fix nit in possessive quantifier descriptions.
[p5sagit/p5-mst-13.2.git] / cop.h
diff --git a/cop.h b/cop.h
index 65651b0..effdbf3 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -268,22 +268,12 @@ struct block_sub {
     AV *       savearray;
     AV *       argarray;
     I32                olddepth;
-    /* These are merged to to get struct context down to 64 bytes on ILP32.  */
-    U8         hasargs_lval;
+    U8         hasargs;
+    U8         lval;           /* XXX merge lval and hasargs? */
     PAD                *oldcomppad;
     OP *       retop;  /* op to execute on exit from sub */
 };
 
-#define CX_SUB_HASARGS_SET(cx, v)      ((cx)->blk_sub.hasargs_lval = \
- ((cx)->blk_sub.hasargs_lval & 0xFE) | ((v) ? 1 : 0))
-#define CX_SUB_HASARGS_GET(cx)         ((cx)->blk_sub.hasargs_lval & 0x01)
-
-#define CX_SUB_LVAL_SET(cx, v)         ((cx)->blk_sub.hasargs_lval = \
- (((cx)->blk_sub.hasargs_lval & 0x01) | ((v) & (OPpLVAL_INTRO|OPpENTERSUB_INARGS))))
-#define CX_SUB_LVAL(cx)                        ((cx)->blk_sub.hasargs_lval & 0xFE)
-#define CX_SUB_LVAL_INARGS(cx)         ((cx)->blk_sub.hasargs_lval & \
-                                        OPpENTERSUB_INARGS)
-
 /* base for the next two macros. Don't use directly.
  * Note that the refcnt of the cv is incremented twice;  The CX one is
  * decremented by LEAVESUB, the other by LEAVE. */
@@ -291,7 +281,7 @@ struct block_sub {
 #define PUSHSUB_BASE(cx)                                               \
        cx->blk_sub.cv = cv;                                            \
        cx->blk_sub.olddepth = CvDEPTH(cv);                             \
-       CX_SUB_HASARGS_SET(cx, hasargs);                                \
+       cx->blk_sub.hasargs = hasargs;                                  \
        cx->blk_sub.retop = NULL;                                       \
        if (!CvDEPTH(cv)) {                                             \
            SvREFCNT_inc_simple_void_NN(cv);                            \
@@ -302,19 +292,20 @@ struct block_sub {
 
 #define PUSHSUB(cx)                                                    \
        PUSHSUB_BASE(cx)                                                \
-       CX_SUB_LVAL_SET(cx, PL_op->op_private)
+       cx->blk_sub.lval = PL_op->op_private &                          \
+                             (OPpLVAL_INTRO|OPpENTERSUB_INARGS);
 
 /* variant for use by OP_DBSTATE, where op_private holds hint bits */
 #define PUSHSUB_DB(cx)                                                 \
        PUSHSUB_BASE(cx)                                                \
-       CX_SUB_LVAL_SET(cx, 0)
+       cx->blk_sub.lval = 0;
 
 
 #define PUSHFORMAT(cx)                                                 \
        cx->blk_sub.cv = cv;                                            \
        cx->blk_sub.gv = gv;                                            \
        cx->blk_sub.retop = NULL;                                       \
-       CX_SUB_HASARGS_SET(cx, 0);                                      \
+       cx->blk_sub.hasargs = 0;                                        \
        cx->blk_sub.dfoutgv = PL_defoutgv;                              \
        SvREFCNT_inc_void(cx->blk_sub.dfoutgv)
 
@@ -335,7 +326,7 @@ struct block_sub {
 
 #define POPSUB(cx,sv)                                                  \
     STMT_START {                                                       \
-       if (CX_SUB_HASARGS_GET(cx)) {                                   \
+       if (cx->blk_sub.hasargs) {                                      \
            POP_SAVEARRAY();                                            \
            /* abandon @_ if it got reified */                          \
            if (AvREAL(cx->blk_sub.argarray)) {                         \
@@ -367,8 +358,8 @@ struct block_sub {
 
 /* eval context */
 struct block_eval {
-    I32                old_in_eval;
-    I32                old_op_type;
+    U8         old_in_eval;
+    U16                old_op_type;
     SV *       old_namesv;
     OP *       old_eval_root;
     SV *       cur_text;
@@ -402,21 +393,39 @@ struct block_eval {
 struct block_loop {
     char *     label;
     I32                resetsp;
-    OP *       redo_op;
-    OP *       next_op;
-    OP *       last_op;
+    LOOP *     my_op;  /* My op, that contains redo, next and last ops.  */
+    /* (except for non_ithreads we need to modify next_op in pp_ctl.c, hence
+       why next_op is conditionally defined below.)  */
 #ifdef USE_ITHREADS
     void *     iterdata;
     PAD                *oldcomppad;
 #else
+    OP *       next_op;
     SV **      itervar;
 #endif
     SV *       itersave;
+    /* (from inspection of source code) for a .. range of strings this is the
+       current string.  */
     SV *       iterlval;
+    /* (from inspection of source code) for a foreach loop this is the array
+       being iterated over. For a .. range of numbers it's the current value.
+       A check is often made on the SvTYPE of iterary to determine whether
+       we are iterating over an array or a range. (numbers or strings)  */
     AV *       iterary;
     IV         iterix;
+    /* (from inspection of source code) for a .. range of numbers this is the
+       maximum value.  */
     IV         itermax;
 };
+/* It might be possible to squeeze this structure further. As best I can tell
+   itermax and iterlval are never used at the same time, so it might be possible
+   to make them into a union. However, I'm not confident that there are enough
+   flag bits/NULLable pointers in this structure alone to encode which is
+   active. There is, however, U8 of space free in struct block, which could be
+   used. Right now it may not be worth squeezing this structure further, as it's
+   the largest part of struct block, and currently struct block is 64 bytes on
+   an ILP32 system, which will give good cache alignment.
+*/
 
 #ifdef USE_ITHREADS
 #  define CxITERVAR(c)                                                 \
@@ -441,12 +450,19 @@ struct block_loop {
            cx->blk_loop.itersave = NULL;
 #endif
 
+#ifdef USE_ITHREADS
+#  define PUSHLOOP_OP_NEXT             /* No need to do anything.  */
+#  define CX_LOOP_NEXTOP_GET(cx)       ((cx)->blk_loop.my_op->op_nextop + 0)
+#else
+#  define PUSHLOOP_OP_NEXT             cx->blk_loop.next_op = cLOOP->op_nextop
+#  define CX_LOOP_NEXTOP_GET(cx)       ((cx)->blk_loop.next_op + 0)
+#endif
+
 #define PUSHLOOP(cx, dat, s)                                           \
        cx->blk_loop.label = PL_curcop->cop_label;                      \
        cx->blk_loop.resetsp = s - PL_stack_base;                       \
-       cx->blk_loop.redo_op = cLOOP->op_redoop;                        \
-       cx->blk_loop.next_op = cLOOP->op_nextop;                        \
-       cx->blk_loop.last_op = cLOOP->op_lastop;                        \
+       cx->blk_loop.my_op = cLOOP;                                     \
+       PUSHLOOP_OP_NEXT;                                               \
        cx->blk_loop.iterlval = NULL;                                   \
        cx->blk_loop.iterary = NULL;                                    \
        cx->blk_loop.iterix = -1;                                       \