In struct block_eval, eliminate old_in_eval and old_op_type by storing
Nicholas Clark [Mon, 21 Jan 2008 15:47:15 +0000 (15:47 +0000)]
the data in blk_u16.

p4raw-id: //depot/perl@33030

cop.h
op.h

diff --git a/cop.h b/cop.h
index adfc51f..5dee181 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -393,8 +393,6 @@ struct block_format {
 struct block_eval {
     OP *       retop;  /* op to execute on exit from eval */
     /* Above here is the same for sub, format and eval.  */
-    U8         old_in_eval;
-    U16                old_op_type;
     SV *       old_namesv;
     OP *       old_eval_root;
     SV *       cur_text;
@@ -402,13 +400,18 @@ struct block_eval {
     JMPENV *   cur_top_env; /* value of PL_top_env when eval CX created */
 };
 
-#define CxOLD_IN_EVAL(cx)      (0 + (cx)->blk_eval.old_in_eval)
-#define CxOLD_OP_TYPE(cx)      (0 + (cx)->blk_eval.old_op_type)
+/* If we ever need more than 512 op types, change the shift from 7.
+   blku_gimme is actually also only 2 bits, so could be merged with something.
+*/
+
+#define CxOLD_IN_EVAL(cx)      (((cx)->blk_u16) & 0x7F)
+#define CxOLD_OP_TYPE(cx)      (((cx)->blk_u16) >> 7)
 
 #define PUSHEVAL(cx,n,fgv)                                             \
     STMT_START {                                                       \
-       cx->blk_eval.old_in_eval = PL_in_eval;                          \
-       cx->blk_eval.old_op_type = PL_op->op_type;                      \
+       assert(!(PL_in_eval & ~0x7F));                                  \
+       assert(!(PL_op->op_type & ~0x1FF));                             \
+       cx->blk_u16 = (PL_in_eval & 0x7F) | ((U16)PL_op->op_type << 7); \
        cx->blk_eval.old_namesv = (n ? newSVpv(n,0) : NULL);            \
        cx->blk_eval.old_eval_root = PL_eval_root;                      \
        cx->blk_eval.cur_text = PL_parser ? PL_parser->linestr : NULL;  \
@@ -535,7 +538,7 @@ struct block_givwhen {
 struct block {
     U8         blku_type;      /* what kind of context this is */
     U8         blku_gimme;     /* is this block running in list context? */
-    U16                blku_u16;       /* U16 of space used by block_sub */
+    U16                blku_u16;       /* used by block_sub and block_eval (so far) */
     I32                blku_oldsp;     /* stack pointer to copy stuff down to */
     COP *      blku_oldcop;    /* old curcop pointer */
     I32                blku_oldmarksp; /* mark stack index */
diff --git a/op.h b/op.h
index 63390ea..5863897 100644 (file)
--- a/op.h
+++ b/op.h
@@ -64,6 +64,8 @@
     U8         op_private;
 #endif
 
+/* If op_type:9 is changed to :10, also change PUSHEVAL in cop.h */
+
 #define OP_GIMME(op,dfl) \
        (((op)->op_flags & OPf_WANT) == OPf_WANT_VOID   ? G_VOID   : \
         ((op)->op_flags & OPf_WANT) == OPf_WANT_SCALAR ? G_SCALAR : \