develooper Front page | perl.perl5.porters | Postings from February 2008

[patch] optimize OP_IS_(FILETEST|SOCKET) macros

Thread Next
From:
Jim Cromie
Date:
February 9, 2008 06:57
Subject:
[patch] optimize OP_IS_(FILETEST|SOCKET) macros
Message ID:
47ADBF3B.2050108@gmail.com

attached patch to opcode.pl generates faster/smaller versions
of 2 macros written to opcode.h

IE:

/* 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_FTRREAD && (op) <= OP_FTBINARY)


This optimized form is generated automatically when
the set of OPs have consecutive opnumbers, otherwize
the traditional form is generated.

I moved send & recv ops down in opcode.pl <DATA>
so that theyre contiguous with the others.
the OP_FT* ops were already consecutive.

Also, 1 unrelated touch to change enum opcode syntax
to explicitly number the enum symbols.

typedef enum opcode {
        OP_NULL          = 0,
        OP_STUB          = 1,
        OP_SCALAR        = 2,
        OP_PUSHMARK      = 3,
        OP_WANTARRAY     = 4,



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About