Change 33232 by [EMAIL PROTECTED] on 2008/02/04 13:59:21

        Micro-optimise the order of the context types. [Because I can :-)]
        Here saves 72 bytes in pp_ctl.o. Small, but in the right direction.

Affected files ...

... //depot/perl/cop.h#176 edit
... //depot/perl/perl.h#826 edit
... //depot/perl/pp_ctl.c#683 edit

Differences ...

==== //depot/perl/cop.h#176 (text) ====
Index: perl/cop.h
--- perl/cop.h#175~33086~       2008-01-28 02:23:21.000000000 -0800
+++ perl/cop.h  2008-02-04 05:59:21.000000000 -0800
@@ -650,20 +650,27 @@
 };
 #define cx_type cx_u.cx_subst.sbu_type
 
+/* If you re-order these, there is also an array of uppercase names in perl.h
+   and a static array of context names in pp_ctl.c  */
 #define CXTYPEMASK     0xf
 #define CXt_NULL       0
-#define CXt_SUB                1
-#define CXt_EVAL       2
-#define CXt_WHEN       3
-#define CXt_SUBST      4
-#define CXt_BLOCK      5
-#define CXt_FORMAT     6
-#define CXt_GIVEN      7
+#define CXt_WHEN       1
+#define CXt_BLOCK      2
+/* When micro-optimising :-) keep GIVEN next to the LOOPs, as these 5 share a
+   jump table in pp_ctl.c
+   The first 4 don't have a 'case' in at least one switch statement in pp_ctl.c
+*/
+#define CXt_GIVEN      3
 /* This is first so that CXt_LOOP_FOR|CXt_LOOP_LAZYIV is CXt_LOOP_LAZYIV */
-#define CXt_LOOP_FOR   8
-#define CXt_LOOP_PLAIN 9
-#define CXt_LOOP_LAZYSV        10
-#define CXt_LOOP_LAZYIV        11
+#define CXt_LOOP_FOR   4
+#define CXt_LOOP_PLAIN 5
+#define CXt_LOOP_LAZYSV        6
+#define CXt_LOOP_LAZYIV        7
+#define CXt_SUB                8
+#define CXt_FORMAT      9
+#define CXt_EVAL       10
+#define CXt_SUBST      11
+/* SUBST doesn't feature in all switch statements.  */
 
 /* private flags for CXt_SUB and CXt_NULL
    However, this is checked in many places which do not check the type, so
@@ -689,7 +696,7 @@
 #define CXp_ONCE       0x10    /* What was sbu_once in struct subst */
 
 #define CxTYPE(c)      ((c)->cx_type & CXTYPEMASK)
-#define CxTYPE_is_LOOP(c)      (((c)->cx_type & 0xC) == 0x8)
+#define CxTYPE_is_LOOP(c)      (((c)->cx_type & 0xC) == 0x4)
 #define CxMULTICALL(c) (((c)->cx_type & CXp_MULTICALL)                 \
                         == CXp_MULTICALL)
 #define CxREALEVAL(c)  (((c)->cx_type & (CXTYPEMASK|CXp_REAL))         \

==== //depot/perl/perl.h#826 (text) ====
Index: perl/perl.h
--- perl/perl.h#825~33152~      2008-01-31 07:39:14.000000000 -0800
+++ perl/perl.h 2008-02-04 05:59:21.000000000 -0800
@@ -4363,17 +4363,17 @@
 #ifdef DOINIT
 EXTCONST char* const PL_block_type[] = {
        "NULL",
-       "SUB",
-       "EVAL",
        "WHEN",
-       "SUBST",
        "BLOCK",
-       "FORMAT",
        "GIVEN",
        "LOOP_FOR",
        "LOOP_PLAIN",
        "LOOP_LAZYSV",
        "LOOP_LAZYIV",
+       "SUB",
+       "FORMAT",
+       "EVAL",
+       "SUBST"
 };
 #else
 EXTCONST char* PL_block_type[];

==== //depot/perl/pp_ctl.c#683 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#682~33109~    2008-01-29 09:39:41.000000000 -0800
+++ perl/pp_ctl.c       2008-02-04 05:59:21.000000000 -0800
@@ -1224,14 +1224,17 @@
 
 static const char * const context_name[] = {
     "pseudo-block",
+    "when",
+    NULL, /* CXt_BLOCK never actually needs "block" */
+    "given",
+    NULL, /* CXt_LOOP_FOR never actually needs "loop" */
+    NULL, /* CXt_LOOP_PLAIN never actually needs "loop" */
+    NULL, /* CXt_LOOP_LAZYSV never actually needs "loop" */
+    NULL, /* CXt_LOOP_LAZYIV never actually needs "loop" */
     "subroutine",
+    "format",
     "eval",
-    "loop",
     "substitution",
-    "block",
-    "format",
-    "given",
-    "when"
 };
 
 STATIC I32
End of Patch.

Reply via email to