summaryrefslogtreecommitdiff
path: root/opcode.pl
diff options
context:
space:
mode:
authorJim Cromie <jcromie@cpan.org>2008-02-10 05:52:59 -0700
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2008-02-25 08:02:50 +0000
commit6ecf81d654dfb4e99b0f99d78579deb3289aae3b (patch)
treeabb87fe3ab127dd5b0bf97f385955e374cf1e31d /opcode.pl
parentc13076132a20419dab956060b96f9d3ef3b25ad7 (diff)
downloadperl-6ecf81d654dfb4e99b0f99d78579deb3289aae3b.tar.gz
Re: [patch] optimize OP_IS_(FILETEST|SOCKET) macros
From: "Jim Cromie" <jim.cromie@gmail.com> Message-ID: <cfe85dfa0802101152n4e1b9e07pc7fb7ad9241a9794@mail.gmail.com> p4raw-id: //depot/perl@33364
Diffstat (limited to 'opcode.pl')
-rwxr-xr-xopcode.pl28
1 files changed, 17 insertions, 11 deletions
diff --git a/opcode.pl b/opcode.pl
index e8c43ddb55..a5dfa57787 100755
--- a/opcode.pl
+++ b/opcode.pl
@@ -344,6 +344,7 @@ my %opflags = (
my %OP_IS_SOCKET;
my %OP_IS_FILETEST;
+my %OP_IS_FT_ACCESS;
my $OCSHIFT = 9;
my $OASHIFT = 13;
@@ -366,6 +367,7 @@ for my $op (@ops) {
# record opnums of these opnames
$OP_IS_SOCKET{$op} = $opnum{$op} if $arg =~ s/s//;
$OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//;
+ $OP_IS_FT_ACCESS{$op} = $opnum{$op} if $arg =~ s/\+//;
}
my $argnum = ($arg =~ s/\?//) ? 8 : 0;
die "op = $op, arg = $arg\n"
@@ -403,6 +405,7 @@ EO_OP_IS_COMMENT
gen_op_is_macro( \%OP_IS_SOCKET, 'OP_IS_SOCKET');
gen_op_is_macro( \%OP_IS_FILETEST, 'OP_IS_FILETEST');
+gen_op_is_macro( \%OP_IS_FT_ACCESS, 'OP_IS_FILETEST_ACCESS');
sub gen_op_is_macro {
my ($op_is, $macname) = @_;
@@ -414,20 +417,21 @@ sub gen_op_is_macro {
} keys %$op_is;
my $last = pop @rest; # @rest slurped, get its last
-
+ die "invalid range of ops: $first .. $last" unless $last;
+
+ print ON "#define $macname(op) \\\n\t(";
+
# 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);
+ map { "(op) == OP_" . uc() } sort keys %$op_is);
print ON ")\n\n";
}
}
@@ -602,7 +606,9 @@ __END__
# Values for the operands are:
# scalar - S list - L array - A
# hash - H sub (CV) - C file - F
-# socket - Fs filetest - F- reference - R
+# socket - Fs filetest - F- filetest_access - F-+
+
+# reference - R
# "?" denotes an optional operand.
# Nothing.
@@ -948,12 +954,12 @@ getpeername getpeername ck_fun is% Fs
lstat lstat ck_ftst u- F
stat stat ck_ftst u- F
-ftrread -R ck_ftst isu- F-
-ftrwrite -W ck_ftst isu- F-
-ftrexec -X ck_ftst isu- F-
-fteread -r ck_ftst isu- F-
-ftewrite -w ck_ftst isu- F-
-fteexec -x ck_ftst isu- F-
+ftrread -R ck_ftst isu- F-+
+ftrwrite -W ck_ftst isu- F-+
+ftrexec -X ck_ftst isu- F-+
+fteread -r ck_ftst isu- F-+
+ftewrite -w ck_ftst isu- F-+
+fteexec -x ck_ftst isu- F-+
ftis -e ck_ftst isu- F-
ftsize -s ck_ftst istu- F-
ftmtime -M ck_ftst stu- F-