Change 33267 by [EMAIL PROTECTED] on 2008/02/10 07:35:45

        Subject: [patch] optimize OP_IS_(FILETEST|SOCKET) macros
        From: Jim Cromie <[EMAIL PROTECTED]>
        Message-ID: <[EMAIL PROTECTED]>
        Date: Sat, 09 Feb 2008 07:56:59 -0700

Affected files ...

... //depot/perl/opcode.h#148 edit
... //depot/perl/opcode.pl#171 edit
... //depot/perl/opnames.h#28 edit
... //depot/perl/pp.sym#40 edit
... //depot/perl/pp_proto.h#48 edit

Differences ...

==== //depot/perl/opcode.h#148 (text+w) ====
Index: perl/opcode.h
--- perl/opcode.h#147~33072~    2008-01-26 02:46:12.000000000 -0800
+++ perl/opcode.h       2008-02-09 23:35:45.000000000 -0800
@@ -261,8 +261,6 @@
        "sysseek",
        "sysread",
        "syswrite",
-       "send",
-       "recv",
        "eof",
        "tell",
        "seek",
@@ -270,6 +268,8 @@
        "fcntl",
        "ioctl",
        "flock",
+       "send",
+       "recv",
        "socket",
        "sockpair",
        "bind",
@@ -632,8 +632,6 @@
        "sysseek",
        "sysread",
        "syswrite",
-       "send",
-       "recv",
        "eof",
        "tell",
        "seek",
@@ -641,6 +639,8 @@
        "fcntl",
        "ioctl",
        "flock",
+       "send",
+       "recv",
        "socket",
        "socketpair",
        "bind",
@@ -1017,8 +1017,6 @@
        MEMBER_TO_FPTR(Perl_pp_sysseek),
        MEMBER_TO_FPTR(Perl_pp_sysread),
        MEMBER_TO_FPTR(Perl_pp_send),   /* Perl_pp_syswrite */
-       MEMBER_TO_FPTR(Perl_pp_send),
-       MEMBER_TO_FPTR(Perl_pp_sysread),        /* Perl_pp_recv */
        MEMBER_TO_FPTR(Perl_pp_eof),
        MEMBER_TO_FPTR(Perl_pp_tell),
        MEMBER_TO_FPTR(Perl_pp_sysseek),        /* Perl_pp_seek */
@@ -1026,6 +1024,8 @@
        MEMBER_TO_FPTR(Perl_pp_ioctl),  /* Perl_pp_fcntl */
        MEMBER_TO_FPTR(Perl_pp_ioctl),
        MEMBER_TO_FPTR(Perl_pp_flock),
+       MEMBER_TO_FPTR(Perl_pp_send),
+       MEMBER_TO_FPTR(Perl_pp_sysread),        /* Perl_pp_recv */
        MEMBER_TO_FPTR(Perl_pp_socket),
        MEMBER_TO_FPTR(Perl_pp_sockpair),
        MEMBER_TO_FPTR(Perl_pp_bind),
@@ -1399,8 +1399,6 @@
        MEMBER_TO_FPTR(Perl_ck_fun),    /* sysseek */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* sysread */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* syswrite */
-       MEMBER_TO_FPTR(Perl_ck_fun),    /* send */
-       MEMBER_TO_FPTR(Perl_ck_fun),    /* recv */
        MEMBER_TO_FPTR(Perl_ck_eof),    /* eof */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* tell */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* seek */
@@ -1408,6 +1406,8 @@
        MEMBER_TO_FPTR(Perl_ck_fun),    /* fcntl */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* ioctl */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* flock */
+       MEMBER_TO_FPTR(Perl_ck_fun),    /* send */
+       MEMBER_TO_FPTR(Perl_ck_fun),    /* recv */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* socket */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* sockpair */
        MEMBER_TO_FPTR(Perl_ck_fun),    /* bind */
@@ -1775,8 +1775,6 @@
        0x0022c804,     /* sysseek */
        0x122ec81d,     /* sysread */
        0x1322c81d,     /* syswrite */
-       0x1222c81d,     /* send */
-       0x022ec81d,     /* recv */
        0x0001d614,     /* eof */
        0x0001d60c,     /* tell */
        0x0022c804,     /* seek */
@@ -1784,6 +1782,8 @@
        0x0022c80c,     /* fcntl */
        0x0022c80c,     /* ioctl */
        0x0002c91c,     /* flock */
+       0x1222c81d,     /* send */
+       0x022ec81d,     /* recv */
        0x0222c814,     /* socket */
        0x222cc814,     /* sockpair */
        0x0002c814,     /* bind */

==== //depot/perl/opcode.pl#171 (xtext) ====
Index: perl/opcode.pl
--- perl/opcode.pl#170~33072~   2008-01-26 02:46:12.000000000 -0800
+++ perl/opcode.pl      2008-02-09 23:35:45.000000000 -0800
@@ -17,7 +17,7 @@
 # Read data.
 
 my %seen;
-my (@ops, %desc, %check, %ckname, %flags, %args);
+my (@ops, %desc, %check, %ckname, %flags, %args, %opnum);
 
 while (<DATA>) {
     chop;
@@ -32,6 +32,7 @@
     $seen{$key} = qq[opcode "$key"];
 
     push(@ops, $key);
+    $opnum{$key} = $#ops;
     $desc{$key} = $desc;
     $check{$key} = $check;
     $ckname{$check}++;
@@ -149,7 +150,8 @@
 
 my $i = 0;
 for (@ops) {
-    print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
+    # print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
+      print ON "\t", &tab(3,"OP_\U$_"), " = ", $i++, ",\n";
 }
 print ON "\t", &tab(3,"OP_max"), "\n";
 print ON "} opcode;\n";
@@ -361,8 +363,9 @@
     my $argshift = $OASHIFT;
     for my $arg (split(' ',$args{$op})) {
        if ($arg =~ /^F/) {
-           $OP_IS_SOCKET{$op}   = 1 if $arg =~ s/s//;
-           $OP_IS_FILETEST{$op} = 1 if $arg =~ s/-//;
+           # record opnums of these opnames
+           $OP_IS_SOCKET{$op}   = $opnum{$op} if $arg =~ s/s//;
+           $OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//;
         }
        my $argnum = ($arg =~ s/\?//) ? 8 : 0;
         die "op = $op, arg = $arg\n"
@@ -388,18 +391,46 @@
 
 END
 
-if (keys %OP_IS_SOCKET) {
-    print ON "\n#define OP_IS_SOCKET(op)       \\\n\t(";
-    print ON join(" || \\\n\t ",
-               map { "(op) == OP_" . uc() } sort keys %OP_IS_SOCKET);
-    print ON ")\n\n";
-}
+# Emit OP_IS_* macros
+
+print ON <<EO_OP_IS_COMMENT;
 
-if (keys %OP_IS_FILETEST) {
-    print ON "\n#define OP_IS_FILETEST(op)     \\\n\t(";
-    print ON join(" || \\\n\t ",
-               map { "(op) == OP_" . uc() } sort keys %OP_IS_FILETEST);
-    print ON ")\n\n";
+/* the OP_IS_(SOCKET|FILETEST) macros are optimized to a simple range
+    check because all the member OPs are contiguous in opcode.pl
+    <DATA> table.  opcode.pl verifies the range contiguity.  */
+
+EO_OP_IS_COMMENT
+
+gen_op_is_macro( \%OP_IS_SOCKET, 'OP_IS_SOCKET');
+gen_op_is_macro( \%OP_IS_FILETEST, 'OP_IS_FILETEST');
+
+sub gen_op_is_macro {
+    my ($op_is, $macname) = @_;
+    if (keys %$op_is) {
+       
+       # get opnames whose numbers are lowest and highest
+       my ($first, @rest) = sort {
+           $op_is->{$a} <=> $op_is->{$b}
+       } keys %$op_is;
+       
+       my $last = pop @rest;   # @rest slurped, get its last
+       
+       # verify that op-ct matches 1st..last range (and fencepost)
+       # (we know there are no dups)
+       if ( $op_is->{$last} - $op_is->{$first} == scalar @rest + 1) {
+           
+           # contiguous ops -> optimized version
+           print ON "#define $macname(op)      \\\n\t(";
+           print ON "(op) >= OP_" . uc($first) . " && (op) <= OP_" . uc($last);
+           print ON ")\n\n";
+       }
+       else {
+           print ON "\n#define $macname(op)    \\\n\t(";
+           print ON join(" || \\\n\t ",
+                         map { "(op) == OP_" . uc() } sort keys %OP_IS_SOCKET);
+           print ON ")\n\n";
+       }
+    }
 }
 
 print OC "/* ex: set ro: */\n";
@@ -883,9 +914,6 @@
 sysread                sysread                 ck_fun          imst@   F R S S?
 syswrite       syswrite                ck_fun          imst@   F S S? S?
 
-send           send                    ck_fun          imst@   Fs S S S?
-recv           recv                    ck_fun          imst@   Fs R S S
-
 eof            eof                     ck_eof          is%     F?
 tell           tell                    ck_fun          st%     F?
 seek           seek                    ck_fun          s@      F S S
@@ -896,7 +924,10 @@
 ioctl          ioctl                   ck_fun          st@     F S S
 flock          flock                   ck_fun          isT@    F S
 
-# Sockets.
+# Sockets.  OP_IS_SOCKET wants them consecutive (so moved 1st 2)
+
+send           send                    ck_fun          imst@   Fs S S S?
+recv           recv                    ck_fun          imst@   Fs R S S
 
 socket         socket                  ck_fun          is@     Fs S S S
 sockpair       socketpair              ck_fun          is@     Fs Fs S S S
@@ -913,7 +944,7 @@
 getsockname    getsockname             ck_fun          is%     Fs
 getpeername    getpeername             ck_fun          is%     Fs
 
-# Stat calls.
+# Stat calls.  OP_IS_FILETEST wants them consecutive.
 
 lstat          lstat                   ck_ftst         u-      F
 stat           stat                    ck_ftst         u-      F

==== //depot/perl/opnames.h#28 (text+w) ====
Index: perl/opnames.h
--- perl/opnames.h#27~33072~    2008-01-26 02:46:12.000000000 -0800
+++ perl/opnames.h      2008-02-09 23:35:45.000000000 -0800
@@ -15,370 +15,370 @@
  */
 
 typedef enum opcode {
-       OP_NULL,        /* 0 */
-       OP_STUB,        /* 1 */
-       OP_SCALAR,      /* 2 */
-       OP_PUSHMARK,    /* 3 */
-       OP_WANTARRAY,   /* 4 */
-       OP_CONST,       /* 5 */
-       OP_GVSV,        /* 6 */
-       OP_GV,          /* 7 */
-       OP_GELEM,       /* 8 */
-       OP_PADSV,       /* 9 */
-       OP_PADAV,       /* 10 */
-       OP_PADHV,       /* 11 */
-       OP_PADANY,      /* 12 */
-       OP_PUSHRE,      /* 13 */
-       OP_RV2GV,       /* 14 */
-       OP_RV2SV,       /* 15 */
-       OP_AV2ARYLEN,   /* 16 */
-       OP_RV2CV,       /* 17 */
-       OP_ANONCODE,    /* 18 */
-       OP_PROTOTYPE,   /* 19 */
-       OP_REFGEN,      /* 20 */
-       OP_SREFGEN,     /* 21 */
-       OP_REF,         /* 22 */
-       OP_BLESS,       /* 23 */
-       OP_BACKTICK,    /* 24 */
-       OP_GLOB,        /* 25 */
-       OP_READLINE,    /* 26 */
-       OP_RCATLINE,    /* 27 */
-       OP_REGCMAYBE,   /* 28 */
-       OP_REGCRESET,   /* 29 */
-       OP_REGCOMP,     /* 30 */
-       OP_MATCH,       /* 31 */
-       OP_QR,          /* 32 */
-       OP_SUBST,       /* 33 */
-       OP_SUBSTCONT,   /* 34 */
-       OP_TRANS,       /* 35 */
-       OP_SASSIGN,     /* 36 */
-       OP_AASSIGN,     /* 37 */
-       OP_CHOP,        /* 38 */
-       OP_SCHOP,       /* 39 */
-       OP_CHOMP,       /* 40 */
-       OP_SCHOMP,      /* 41 */
-       OP_DEFINED,     /* 42 */
-       OP_UNDEF,       /* 43 */
-       OP_STUDY,       /* 44 */
-       OP_POS,         /* 45 */
-       OP_PREINC,      /* 46 */
-       OP_I_PREINC,    /* 47 */
-       OP_PREDEC,      /* 48 */
-       OP_I_PREDEC,    /* 49 */
-       OP_POSTINC,     /* 50 */
-       OP_I_POSTINC,   /* 51 */
-       OP_POSTDEC,     /* 52 */
-       OP_I_POSTDEC,   /* 53 */
-       OP_POW,         /* 54 */
-       OP_MULTIPLY,    /* 55 */
-       OP_I_MULTIPLY,  /* 56 */
-       OP_DIVIDE,      /* 57 */
-       OP_I_DIVIDE,    /* 58 */
-       OP_MODULO,      /* 59 */
-       OP_I_MODULO,    /* 60 */
-       OP_REPEAT,      /* 61 */
-       OP_ADD,         /* 62 */
-       OP_I_ADD,       /* 63 */
-       OP_SUBTRACT,    /* 64 */
-       OP_I_SUBTRACT,  /* 65 */
-       OP_CONCAT,      /* 66 */
-       OP_STRINGIFY,   /* 67 */
-       OP_LEFT_SHIFT,  /* 68 */
-       OP_RIGHT_SHIFT, /* 69 */
-       OP_LT,          /* 70 */
-       OP_I_LT,        /* 71 */
-       OP_GT,          /* 72 */
-       OP_I_GT,        /* 73 */
-       OP_LE,          /* 74 */
-       OP_I_LE,        /* 75 */
-       OP_GE,          /* 76 */
-       OP_I_GE,        /* 77 */
-       OP_EQ,          /* 78 */
-       OP_I_EQ,        /* 79 */
-       OP_NE,          /* 80 */
-       OP_I_NE,        /* 81 */
-       OP_NCMP,        /* 82 */
-       OP_I_NCMP,      /* 83 */
-       OP_SLT,         /* 84 */
-       OP_SGT,         /* 85 */
-       OP_SLE,         /* 86 */
-       OP_SGE,         /* 87 */
-       OP_SEQ,         /* 88 */
-       OP_SNE,         /* 89 */
-       OP_SCMP,        /* 90 */
-       OP_BIT_AND,     /* 91 */
-       OP_BIT_XOR,     /* 92 */
-       OP_BIT_OR,      /* 93 */
-       OP_NEGATE,      /* 94 */
-       OP_I_NEGATE,    /* 95 */
-       OP_NOT,         /* 96 */
-       OP_COMPLEMENT,  /* 97 */
-       OP_SMARTMATCH,  /* 98 */
-       OP_ATAN2,       /* 99 */
-       OP_SIN,         /* 100 */
-       OP_COS,         /* 101 */
-       OP_RAND,        /* 102 */
-       OP_SRAND,       /* 103 */
-       OP_EXP,         /* 104 */
-       OP_LOG,         /* 105 */
-       OP_SQRT,        /* 106 */
-       OP_INT,         /* 107 */
-       OP_HEX,         /* 108 */
-       OP_OCT,         /* 109 */
-       OP_ABS,         /* 110 */
-       OP_LENGTH,      /* 111 */
-       OP_SUBSTR,      /* 112 */
-       OP_VEC,         /* 113 */
-       OP_INDEX,       /* 114 */
-       OP_RINDEX,      /* 115 */
-       OP_SPRINTF,     /* 116 */
-       OP_FORMLINE,    /* 117 */
-       OP_ORD,         /* 118 */
-       OP_CHR,         /* 119 */
-       OP_CRYPT,       /* 120 */
-       OP_UCFIRST,     /* 121 */
-       OP_LCFIRST,     /* 122 */
-       OP_UC,          /* 123 */
-       OP_LC,          /* 124 */
-       OP_QUOTEMETA,   /* 125 */
-       OP_RV2AV,       /* 126 */
-       OP_AELEMFAST,   /* 127 */
-       OP_AELEM,       /* 128 */
-       OP_ASLICE,      /* 129 */
-       OP_AEACH,       /* 130 */
-       OP_AKEYS,       /* 131 */
-       OP_AVALUES,     /* 132 */
-       OP_EACH,        /* 133 */
-       OP_VALUES,      /* 134 */
-       OP_KEYS,        /* 135 */
-       OP_DELETE,      /* 136 */
-       OP_EXISTS,      /* 137 */
-       OP_RV2HV,       /* 138 */
-       OP_HELEM,       /* 139 */
-       OP_HSLICE,      /* 140 */
-       OP_UNPACK,      /* 141 */
-       OP_PACK,        /* 142 */
-       OP_SPLIT,       /* 143 */
-       OP_JOIN,        /* 144 */
-       OP_LIST,        /* 145 */
-       OP_LSLICE,      /* 146 */
-       OP_ANONLIST,    /* 147 */
-       OP_ANONHASH,    /* 148 */
-       OP_SPLICE,      /* 149 */
-       OP_PUSH,        /* 150 */
-       OP_POP,         /* 151 */
-       OP_SHIFT,       /* 152 */
-       OP_UNSHIFT,     /* 153 */
-       OP_SORT,        /* 154 */
-       OP_REVERSE,     /* 155 */
-       OP_GREPSTART,   /* 156 */
-       OP_GREPWHILE,   /* 157 */
-       OP_MAPSTART,    /* 158 */
-       OP_MAPWHILE,    /* 159 */
-       OP_RANGE,       /* 160 */
-       OP_FLIP,        /* 161 */
-       OP_FLOP,        /* 162 */
-       OP_AND,         /* 163 */
-       OP_OR,          /* 164 */
-       OP_XOR,         /* 165 */
-       OP_DOR,         /* 166 */
-       OP_COND_EXPR,   /* 167 */
-       OP_ANDASSIGN,   /* 168 */
-       OP_ORASSIGN,    /* 169 */
-       OP_DORASSIGN,   /* 170 */
-       OP_METHOD,      /* 171 */
-       OP_ENTERSUB,    /* 172 */
-       OP_LEAVESUB,    /* 173 */
-       OP_LEAVESUBLV,  /* 174 */
-       OP_CALLER,      /* 175 */
-       OP_WARN,        /* 176 */
-       OP_DIE,         /* 177 */
-       OP_RESET,       /* 178 */
-       OP_LINESEQ,     /* 179 */
-       OP_NEXTSTATE,   /* 180 */
-       OP_DBSTATE,     /* 181 */
-       OP_UNSTACK,     /* 182 */
-       OP_ENTER,       /* 183 */
-       OP_LEAVE,       /* 184 */
-       OP_SCOPE,       /* 185 */
-       OP_ENTERITER,   /* 186 */
-       OP_ITER,        /* 187 */
-       OP_ENTERLOOP,   /* 188 */
-       OP_LEAVELOOP,   /* 189 */
-       OP_RETURN,      /* 190 */
-       OP_LAST,        /* 191 */
-       OP_NEXT,        /* 192 */
-       OP_REDO,        /* 193 */
-       OP_DUMP,        /* 194 */
-       OP_GOTO,        /* 195 */
-       OP_EXIT,        /* 196 */
-       OP_METHOD_NAMED,/* 197 */
-       OP_ENTERGIVEN,  /* 198 */
-       OP_LEAVEGIVEN,  /* 199 */
-       OP_ENTERWHEN,   /* 200 */
-       OP_LEAVEWHEN,   /* 201 */
-       OP_BREAK,       /* 202 */
-       OP_CONTINUE,    /* 203 */
-       OP_OPEN,        /* 204 */
-       OP_CLOSE,       /* 205 */
-       OP_PIPE_OP,     /* 206 */
-       OP_FILENO,      /* 207 */
-       OP_UMASK,       /* 208 */
-       OP_BINMODE,     /* 209 */
-       OP_TIE,         /* 210 */
-       OP_UNTIE,       /* 211 */
-       OP_TIED,        /* 212 */
-       OP_DBMOPEN,     /* 213 */
-       OP_DBMCLOSE,    /* 214 */
-       OP_SSELECT,     /* 215 */
-       OP_SELECT,      /* 216 */
-       OP_GETC,        /* 217 */
-       OP_READ,        /* 218 */
-       OP_ENTERWRITE,  /* 219 */
-       OP_LEAVEWRITE,  /* 220 */
-       OP_PRTF,        /* 221 */
-       OP_PRINT,       /* 222 */
-       OP_SAY,         /* 223 */
-       OP_SYSOPEN,     /* 224 */
-       OP_SYSSEEK,     /* 225 */
-       OP_SYSREAD,     /* 226 */
-       OP_SYSWRITE,    /* 227 */
-       OP_SEND,        /* 228 */
-       OP_RECV,        /* 229 */
-       OP_EOF,         /* 230 */
-       OP_TELL,        /* 231 */
-       OP_SEEK,        /* 232 */
-       OP_TRUNCATE,    /* 233 */
-       OP_FCNTL,       /* 234 */
-       OP_IOCTL,       /* 235 */
-       OP_FLOCK,       /* 236 */
-       OP_SOCKET,      /* 237 */
-       OP_SOCKPAIR,    /* 238 */
-       OP_BIND,        /* 239 */
-       OP_CONNECT,     /* 240 */
-       OP_LISTEN,      /* 241 */
-       OP_ACCEPT,      /* 242 */
-       OP_SHUTDOWN,    /* 243 */
-       OP_GSOCKOPT,    /* 244 */
-       OP_SSOCKOPT,    /* 245 */
-       OP_GETSOCKNAME, /* 246 */
-       OP_GETPEERNAME, /* 247 */
-       OP_LSTAT,       /* 248 */
-       OP_STAT,        /* 249 */
-       OP_FTRREAD,     /* 250 */
-       OP_FTRWRITE,    /* 251 */
-       OP_FTREXEC,     /* 252 */
-       OP_FTEREAD,     /* 253 */
-       OP_FTEWRITE,    /* 254 */
-       OP_FTEEXEC,     /* 255 */
-       OP_FTIS,        /* 256 */
-       OP_FTSIZE,      /* 257 */
-       OP_FTMTIME,     /* 258 */
-       OP_FTATIME,     /* 259 */
-       OP_FTCTIME,     /* 260 */
-       OP_FTROWNED,    /* 261 */
-       OP_FTEOWNED,    /* 262 */
-       OP_FTZERO,      /* 263 */
-       OP_FTSOCK,      /* 264 */
-       OP_FTCHR,       /* 265 */
-       OP_FTBLK,       /* 266 */
-       OP_FTFILE,      /* 267 */
-       OP_FTDIR,       /* 268 */
-       OP_FTPIPE,      /* 269 */
-       OP_FTSUID,      /* 270 */
-       OP_FTSGID,      /* 271 */
-       OP_FTSVTX,      /* 272 */
-       OP_FTLINK,      /* 273 */
-       OP_FTTTY,       /* 274 */
-       OP_FTTEXT,      /* 275 */
-       OP_FTBINARY,    /* 276 */
-       OP_CHDIR,       /* 277 */
-       OP_CHOWN,       /* 278 */
-       OP_CHROOT,      /* 279 */
-       OP_UNLINK,      /* 280 */
-       OP_CHMOD,       /* 281 */
-       OP_UTIME,       /* 282 */
-       OP_RENAME,      /* 283 */
-       OP_LINK,        /* 284 */
-       OP_SYMLINK,     /* 285 */
-       OP_READLINK,    /* 286 */
-       OP_MKDIR,       /* 287 */
-       OP_RMDIR,       /* 288 */
-       OP_OPEN_DIR,    /* 289 */
-       OP_READDIR,     /* 290 */
-       OP_TELLDIR,     /* 291 */
-       OP_SEEKDIR,     /* 292 */
-       OP_REWINDDIR,   /* 293 */
-       OP_CLOSEDIR,    /* 294 */
-       OP_FORK,        /* 295 */
-       OP_WAIT,        /* 296 */
-       OP_WAITPID,     /* 297 */
-       OP_SYSTEM,      /* 298 */
-       OP_EXEC,        /* 299 */
-       OP_KILL,        /* 300 */
-       OP_GETPPID,     /* 301 */
-       OP_GETPGRP,     /* 302 */
-       OP_SETPGRP,     /* 303 */
-       OP_GETPRIORITY, /* 304 */
-       OP_SETPRIORITY, /* 305 */
-       OP_TIME,        /* 306 */
-       OP_TMS,         /* 307 */
-       OP_LOCALTIME,   /* 308 */
-       OP_GMTIME,      /* 309 */
-       OP_ALARM,       /* 310 */
-       OP_SLEEP,       /* 311 */
-       OP_SHMGET,      /* 312 */
-       OP_SHMCTL,      /* 313 */
-       OP_SHMREAD,     /* 314 */
-       OP_SHMWRITE,    /* 315 */
-       OP_MSGGET,      /* 316 */
-       OP_MSGCTL,      /* 317 */
-       OP_MSGSND,      /* 318 */
-       OP_MSGRCV,      /* 319 */
-       OP_SEMOP,       /* 320 */
-       OP_SEMGET,      /* 321 */
-       OP_SEMCTL,      /* 322 */
-       OP_REQUIRE,     /* 323 */
-       OP_DOFILE,      /* 324 */
-       OP_ENTEREVAL,   /* 325 */
-       OP_LEAVEEVAL,   /* 326 */
-       OP_ENTERTRY,    /* 327 */
-       OP_LEAVETRY,    /* 328 */
-       OP_GHBYNAME,    /* 329 */
-       OP_GHBYADDR,    /* 330 */
-       OP_GHOSTENT,    /* 331 */
-       OP_GNBYNAME,    /* 332 */
-       OP_GNBYADDR,    /* 333 */
-       OP_GNETENT,     /* 334 */
-       OP_GPBYNAME,    /* 335 */
-       OP_GPBYNUMBER,  /* 336 */
-       OP_GPROTOENT,   /* 337 */
-       OP_GSBYNAME,    /* 338 */
-       OP_GSBYPORT,    /* 339 */
-       OP_GSERVENT,    /* 340 */
-       OP_SHOSTENT,    /* 341 */
-       OP_SNETENT,     /* 342 */
-       OP_SPROTOENT,   /* 343 */
-       OP_SSERVENT,    /* 344 */
-       OP_EHOSTENT,    /* 345 */
-       OP_ENETENT,     /* 346 */
-       OP_EPROTOENT,   /* 347 */
-       OP_ESERVENT,    /* 348 */
-       OP_GPWNAM,      /* 349 */
-       OP_GPWUID,      /* 350 */
-       OP_GPWENT,      /* 351 */
-       OP_SPWENT,      /* 352 */
-       OP_EPWENT,      /* 353 */
-       OP_GGRNAM,      /* 354 */
-       OP_GGRGID,      /* 355 */
-       OP_GGRENT,      /* 356 */
-       OP_SGRENT,      /* 357 */
-       OP_EGRENT,      /* 358 */
-       OP_GETLOGIN,    /* 359 */
-       OP_SYSCALL,     /* 360 */
-       OP_LOCK,        /* 361 */
-       OP_ONCE,        /* 362 */
-       OP_CUSTOM,      /* 363 */
+       OP_NULL          = 0,
+       OP_STUB          = 1,
+       OP_SCALAR        = 2,
+       OP_PUSHMARK      = 3,
+       OP_WANTARRAY     = 4,
+       OP_CONST         = 5,
+       OP_GVSV          = 6,
+       OP_GV            = 7,
+       OP_GELEM         = 8,
+       OP_PADSV         = 9,
+       OP_PADAV         = 10,
+       OP_PADHV         = 11,
+       OP_PADANY        = 12,
+       OP_PUSHRE        = 13,
+       OP_RV2GV         = 14,
+       OP_RV2SV         = 15,
+       OP_AV2ARYLEN     = 16,
+       OP_RV2CV         = 17,
+       OP_ANONCODE      = 18,
+       OP_PROTOTYPE     = 19,
+       OP_REFGEN        = 20,
+       OP_SREFGEN       = 21,
+       OP_REF           = 22,
+       OP_BLESS         = 23,
+       OP_BACKTICK      = 24,
+       OP_GLOB          = 25,
+       OP_READLINE      = 26,
+       OP_RCATLINE      = 27,
+       OP_REGCMAYBE     = 28,
+       OP_REGCRESET     = 29,
+       OP_REGCOMP       = 30,
+       OP_MATCH         = 31,
+       OP_QR            = 32,
+       OP_SUBST         = 33,
+       OP_SUBSTCONT     = 34,
+       OP_TRANS         = 35,
+       OP_SASSIGN       = 36,
+       OP_AASSIGN       = 37,
+       OP_CHOP          = 38,
+       OP_SCHOP         = 39,
+       OP_CHOMP         = 40,
+       OP_SCHOMP        = 41,
+       OP_DEFINED       = 42,
+       OP_UNDEF         = 43,
+       OP_STUDY         = 44,
+       OP_POS           = 45,
+       OP_PREINC        = 46,
+       OP_I_PREINC      = 47,
+       OP_PREDEC        = 48,
+       OP_I_PREDEC      = 49,
+       OP_POSTINC       = 50,
+       OP_I_POSTINC     = 51,
+       OP_POSTDEC       = 52,
+       OP_I_POSTDEC     = 53,
+       OP_POW           = 54,
+       OP_MULTIPLY      = 55,
+       OP_I_MULTIPLY    = 56,
+       OP_DIVIDE        = 57,
+       OP_I_DIVIDE      = 58,
+       OP_MODULO        = 59,
+       OP_I_MODULO      = 60,
+       OP_REPEAT        = 61,
+       OP_ADD           = 62,
+       OP_I_ADD         = 63,
+       OP_SUBTRACT      = 64,
+       OP_I_SUBTRACT    = 65,
+       OP_CONCAT        = 66,
+       OP_STRINGIFY     = 67,
+       OP_LEFT_SHIFT    = 68,
+       OP_RIGHT_SHIFT   = 69,
+       OP_LT            = 70,
+       OP_I_LT          = 71,
+       OP_GT            = 72,
+       OP_I_GT          = 73,
+       OP_LE            = 74,
+       OP_I_LE          = 75,
+       OP_GE            = 76,
+       OP_I_GE          = 77,
+       OP_EQ            = 78,
+       OP_I_EQ          = 79,
+       OP_NE            = 80,
+       OP_I_NE          = 81,
+       OP_NCMP          = 82,
+       OP_I_NCMP        = 83,
+       OP_SLT           = 84,
+       OP_SGT           = 85,
+       OP_SLE           = 86,
+       OP_SGE           = 87,
+       OP_SEQ           = 88,
+       OP_SNE           = 89,
+       OP_SCMP          = 90,
+       OP_BIT_AND       = 91,
+       OP_BIT_XOR       = 92,
+       OP_BIT_OR        = 93,
+       OP_NEGATE        = 94,
+       OP_I_NEGATE      = 95,
+       OP_NOT           = 96,
+       OP_COMPLEMENT    = 97,
+       OP_SMARTMATCH    = 98,
+       OP_ATAN2         = 99,
+       OP_SIN           = 100,
+       OP_COS           = 101,
+       OP_RAND          = 102,
+       OP_SRAND         = 103,
+       OP_EXP           = 104,
+       OP_LOG           = 105,
+       OP_SQRT          = 106,
+       OP_INT           = 107,
+       OP_HEX           = 108,
+       OP_OCT           = 109,
+       OP_ABS           = 110,
+       OP_LENGTH        = 111,
+       OP_SUBSTR        = 112,
+       OP_VEC           = 113,
+       OP_INDEX         = 114,
+       OP_RINDEX        = 115,
+       OP_SPRINTF       = 116,
+       OP_FORMLINE      = 117,
+       OP_ORD           = 118,
+       OP_CHR           = 119,
+       OP_CRYPT         = 120,
+       OP_UCFIRST       = 121,
+       OP_LCFIRST       = 122,
+       OP_UC            = 123,
+       OP_LC            = 124,
+       OP_QUOTEMETA     = 125,
+       OP_RV2AV         = 126,
+       OP_AELEMFAST     = 127,
+       OP_AELEM         = 128,
+       OP_ASLICE        = 129,
+       OP_AEACH         = 130,
+       OP_AKEYS         = 131,
+       OP_AVALUES       = 132,
+       OP_EACH          = 133,
+       OP_VALUES        = 134,
+       OP_KEYS          = 135,
+       OP_DELETE        = 136,
+       OP_EXISTS        = 137,
+       OP_RV2HV         = 138,
+       OP_HELEM         = 139,
+       OP_HSLICE        = 140,
+       OP_UNPACK        = 141,
+       OP_PACK          = 142,
+       OP_SPLIT         = 143,
+       OP_JOIN          = 144,
+       OP_LIST          = 145,
+       OP_LSLICE        = 146,
+       OP_ANONLIST      = 147,
+       OP_ANONHASH      = 148,
+       OP_SPLICE        = 149,
+       OP_PUSH          = 150,
+       OP_POP           = 151,
+       OP_SHIFT         = 152,
+       OP_UNSHIFT       = 153,
+       OP_SORT          = 154,
+       OP_REVERSE       = 155,
+       OP_GREPSTART     = 156,
+       OP_GREPWHILE     = 157,
+       OP_MAPSTART      = 158,
+       OP_MAPWHILE      = 159,
+       OP_RANGE         = 160,
+       OP_FLIP          = 161,
+       OP_FLOP          = 162,
+       OP_AND           = 163,
+       OP_OR            = 164,
+       OP_XOR           = 165,
+       OP_DOR           = 166,
+       OP_COND_EXPR     = 167,
+       OP_ANDASSIGN     = 168,
+       OP_ORASSIGN      = 169,
+       OP_DORASSIGN     = 170,
+       OP_METHOD        = 171,
+       OP_ENTERSUB      = 172,
+       OP_LEAVESUB      = 173,
+       OP_LEAVESUBLV    = 174,
+       OP_CALLER        = 175,
+       OP_WARN          = 176,
+       OP_DIE           = 177,
+       OP_RESET         = 178,
+       OP_LINESEQ       = 179,
+       OP_NEXTSTATE     = 180,
+       OP_DBSTATE       = 181,
+       OP_UNSTACK       = 182,
+       OP_ENTER         = 183,
+       OP_LEAVE         = 184,
+       OP_SCOPE         = 185,
+       OP_ENTERITER     = 186,
+       OP_ITER          = 187,
+       OP_ENTERLOOP     = 188,
+       OP_LEAVELOOP     = 189,
+       OP_RETURN        = 190,
+       OP_LAST          = 191,
+       OP_NEXT          = 192,
+       OP_REDO          = 193,
+       OP_DUMP          = 194,
+       OP_GOTO          = 195,
+       OP_EXIT          = 196,
+       OP_METHOD_NAMED  = 197,
+       OP_ENTERGIVEN    = 198,
+       OP_LEAVEGIVEN    = 199,
+       OP_ENTERWHEN     = 200,
+       OP_LEAVEWHEN     = 201,
+       OP_BREAK         = 202,
+       OP_CONTINUE      = 203,
+       OP_OPEN          = 204,
+       OP_CLOSE         = 205,
+       OP_PIPE_OP       = 206,
+       OP_FILENO        = 207,
+       OP_UMASK         = 208,
+       OP_BINMODE       = 209,
+       OP_TIE           = 210,
+       OP_UNTIE         = 211,
+       OP_TIED          = 212,
+       OP_DBMOPEN       = 213,
+       OP_DBMCLOSE      = 214,
+       OP_SSELECT       = 215,
+       OP_SELECT        = 216,
+       OP_GETC          = 217,
+       OP_READ          = 218,
+       OP_ENTERWRITE    = 219,
+       OP_LEAVEWRITE    = 220,
+       OP_PRTF          = 221,
+       OP_PRINT         = 222,
+       OP_SAY           = 223,
+       OP_SYSOPEN       = 224,
+       OP_SYSSEEK       = 225,
+       OP_SYSREAD       = 226,
+       OP_SYSWRITE      = 227,
+       OP_EOF           = 228,
+       OP_TELL          = 229,
+       OP_SEEK          = 230,
+       OP_TRUNCATE      = 231,
+       OP_FCNTL         = 232,
+       OP_IOCTL         = 233,
+       OP_FLOCK         = 234,
+       OP_SEND          = 235,
+       OP_RECV          = 236,
+       OP_SOCKET        = 237,
+       OP_SOCKPAIR      = 238,
+       OP_BIND          = 239,
+       OP_CONNECT       = 240,
+       OP_LISTEN        = 241,
+       OP_ACCEPT        = 242,
+       OP_SHUTDOWN      = 243,
+       OP_GSOCKOPT      = 244,
+       OP_SSOCKOPT      = 245,
+       OP_GETSOCKNAME   = 246,
+       OP_GETPEERNAME   = 247,
+       OP_LSTAT         = 248,
+       OP_STAT          = 249,
+       OP_FTRREAD       = 250,
+       OP_FTRWRITE      = 251,
+       OP_FTREXEC       = 252,
+       OP_FTEREAD       = 253,
+       OP_FTEWRITE      = 254,
+       OP_FTEEXEC       = 255,
+       OP_FTIS          = 256,
+       OP_FTSIZE        = 257,
+       OP_FTMTIME       = 258,
+       OP_FTATIME       = 259,
+       OP_FTCTIME       = 260,
+       OP_FTROWNED      = 261,
+       OP_FTEOWNED      = 262,
+       OP_FTZERO        = 263,
+       OP_FTSOCK        = 264,
+       OP_FTCHR         = 265,
+       OP_FTBLK         = 266,
+       OP_FTFILE        = 267,
+       OP_FTDIR         = 268,
+       OP_FTPIPE        = 269,
+       OP_FTSUID        = 270,
+       OP_FTSGID        = 271,
+       OP_FTSVTX        = 272,
+       OP_FTLINK        = 273,
+       OP_FTTTY         = 274,
+       OP_FTTEXT        = 275,
+       OP_FTBINARY      = 276,
+       OP_CHDIR         = 277,
+       OP_CHOWN         = 278,
+       OP_CHROOT        = 279,
+       OP_UNLINK        = 280,
+       OP_CHMOD         = 281,
+       OP_UTIME         = 282,
+       OP_RENAME        = 283,
+       OP_LINK          = 284,
+       OP_SYMLINK       = 285,
+       OP_READLINK      = 286,
+       OP_MKDIR         = 287,
+       OP_RMDIR         = 288,
+       OP_OPEN_DIR      = 289,
+       OP_READDIR       = 290,
+       OP_TELLDIR       = 291,
+       OP_SEEKDIR       = 292,
+       OP_REWINDDIR     = 293,
+       OP_CLOSEDIR      = 294,
+       OP_FORK          = 295,
+       OP_WAIT          = 296,
+       OP_WAITPID       = 297,
+       OP_SYSTEM        = 298,
+       OP_EXEC          = 299,
+       OP_KILL          = 300,
+       OP_GETPPID       = 301,
+       OP_GETPGRP       = 302,
+       OP_SETPGRP       = 303,
+       OP_GETPRIORITY   = 304,
+       OP_SETPRIORITY   = 305,
+       OP_TIME          = 306,
+       OP_TMS           = 307,
+       OP_LOCALTIME     = 308,
+       OP_GMTIME        = 309,
+       OP_ALARM         = 310,
+       OP_SLEEP         = 311,
+       OP_SHMGET        = 312,
+       OP_SHMCTL        = 313,
+       OP_SHMREAD       = 314,
+       OP_SHMWRITE      = 315,
+       OP_MSGGET        = 316,
+       OP_MSGCTL        = 317,
+       OP_MSGSND        = 318,
+       OP_MSGRCV        = 319,
+       OP_SEMOP         = 320,
+       OP_SEMGET        = 321,
+       OP_SEMCTL        = 322,
+       OP_REQUIRE       = 323,
+       OP_DOFILE        = 324,
+       OP_ENTEREVAL     = 325,
+       OP_LEAVEEVAL     = 326,
+       OP_ENTERTRY      = 327,
+       OP_LEAVETRY      = 328,
+       OP_GHBYNAME      = 329,
+       OP_GHBYADDR      = 330,
+       OP_GHOSTENT      = 331,
+       OP_GNBYNAME      = 332,
+       OP_GNBYADDR      = 333,
+       OP_GNETENT       = 334,
+       OP_GPBYNAME      = 335,
+       OP_GPBYNUMBER    = 336,
+       OP_GPROTOENT     = 337,
+       OP_GSBYNAME      = 338,
+       OP_GSBYPORT      = 339,
+       OP_GSERVENT      = 340,
+       OP_SHOSTENT      = 341,
+       OP_SNETENT       = 342,
+       OP_SPROTOENT     = 343,
+       OP_SSERVENT      = 344,
+       OP_EHOSTENT      = 345,
+       OP_ENETENT       = 346,
+       OP_EPROTOENT     = 347,
+       OP_ESERVENT      = 348,
+       OP_GPWNAM        = 349,
+       OP_GPWUID        = 350,
+       OP_GPWENT        = 351,
+       OP_SPWENT        = 352,
+       OP_EPWENT        = 353,
+       OP_GGRNAM        = 354,
+       OP_GGRGID        = 355,
+       OP_GGRENT        = 356,
+       OP_SGRENT        = 357,
+       OP_EGRENT        = 358,
+       OP_GETLOGIN      = 359,
+       OP_SYSCALL       = 360,
+       OP_LOCK          = 361,
+       OP_ONCE          = 362,
+       OP_CUSTOM        = 363,
        OP_max          
 } opcode;
 
@@ -387,49 +387,14 @@
 #define OP_phoney_OUTPUT_ONLY -2
 
 
-#define OP_IS_SOCKET(op)       \
-       ((op) == OP_ACCEPT || \
-        (op) == OP_BIND || \
-        (op) == OP_CONNECT || \
-        (op) == OP_GETPEERNAME || \
-        (op) == OP_GETSOCKNAME || \
-        (op) == OP_GSOCKOPT || \
-        (op) == OP_LISTEN || \
-        (op) == OP_RECV || \
-        (op) == OP_SEND || \
-        (op) == OP_SHUTDOWN || \
-        (op) == OP_SOCKET || \
-        (op) == OP_SOCKPAIR || \
-        (op) == OP_SSOCKOPT)
+/* the OP_IS_(SOCKET|FILETEST) macros are optimized to a simple range
+    check because all the member OPs are contiguous in opcode.pl
+    <DATA> table.  opcode.pl verifies the range contiguity.  */
 
+#define OP_IS_SOCKET(op)       \
+       ((op) >= OP_SEND && (op) <= OP_GETPEERNAME)
 
 #define OP_IS_FILETEST(op)     \
-       ((op) == OP_FTATIME || \
-        (op) == OP_FTBINARY || \
-        (op) == OP_FTBLK || \
-        (op) == OP_FTCHR || \
-        (op) == OP_FTCTIME || \
-        (op) == OP_FTDIR || \
-        (op) == OP_FTEEXEC || \
-        (op) == OP_FTEOWNED || \
-        (op) == OP_FTEREAD || \
-        (op) == OP_FTEWRITE || \
-        (op) == OP_FTFILE || \
-        (op) == OP_FTIS || \
-        (op) == OP_FTLINK || \
-        (op) == OP_FTMTIME || \
-        (op) == OP_FTPIPE || \
-        (op) == OP_FTREXEC || \
-        (op) == OP_FTROWNED || \
-        (op) == OP_FTRREAD || \
-        (op) == OP_FTRWRITE || \
-        (op) == OP_FTSGID || \
-        (op) == OP_FTSIZE || \
-        (op) == OP_FTSOCK || \
-        (op) == OP_FTSUID || \
-        (op) == OP_FTSVTX || \
-        (op) == OP_FTTEXT || \
-        (op) == OP_FTTTY || \
-        (op) == OP_FTZERO)
+       ((op) >= OP_FTRREAD && (op) <= OP_FTBINARY)
 
 /* ex: set ro: */

==== //depot/perl/pp.sym#40 (text+w) ====
Index: perl/pp.sym
--- perl/pp.sym#39~33072~       2008-01-26 02:46:12.000000000 -0800
+++ perl/pp.sym 2008-02-09 23:35:45.000000000 -0800
@@ -273,8 +273,6 @@
 Perl_pp_sysseek
 Perl_pp_sysread
 Perl_pp_syswrite
-Perl_pp_send
-Perl_pp_recv
 Perl_pp_eof
 Perl_pp_tell
 Perl_pp_seek
@@ -282,6 +280,8 @@
 Perl_pp_fcntl
 Perl_pp_ioctl
 Perl_pp_flock
+Perl_pp_send
+Perl_pp_recv
 Perl_pp_socket
 Perl_pp_sockpair
 Perl_pp_bind

==== //depot/perl/pp_proto.h#48 (text+w) ====
Index: perl/pp_proto.h
--- perl/pp_proto.h#47~33072~   2008-01-26 02:46:12.000000000 -0800
+++ perl/pp_proto.h     2008-02-09 23:35:45.000000000 -0800
@@ -274,8 +274,6 @@
 PERL_PPDEF(Perl_pp_sysseek)
 PERL_PPDEF(Perl_pp_sysread)
 PERL_PPDEF(Perl_pp_syswrite)
-PERL_PPDEF(Perl_pp_send)
-PERL_PPDEF(Perl_pp_recv)
 PERL_PPDEF(Perl_pp_eof)
 PERL_PPDEF(Perl_pp_tell)
 PERL_PPDEF(Perl_pp_seek)
@@ -283,6 +281,8 @@
 PERL_PPDEF(Perl_pp_fcntl)
 PERL_PPDEF(Perl_pp_ioctl)
 PERL_PPDEF(Perl_pp_flock)
+PERL_PPDEF(Perl_pp_send)
+PERL_PPDEF(Perl_pp_recv)
 PERL_PPDEF(Perl_pp_socket)
 PERL_PPDEF(Perl_pp_sockpair)
 PERL_PPDEF(Perl_pp_bind)
End of Patch.

Reply via email to