=head1 NAME Faster - do some things faster =head1 SYNOPSIS use Faster; =head1 DESCRIPTION =over 4 =cut package Faster; use strict; BEGIN { our $VERSION = '0.01'; require XSLoader; XSLoader::load __PACKAGE__, $VERSION; } use B (); our $source; our $label_next; our $label_last; our $label_redo; my %flag; for (split /\n/, <type; $source .= <START; while (my $op = shift @todo) { for (; $$op; $op = $op->next) { last if $opsseen{$$op}++; push @ops, $op; my $name = $op->name; if (B::class($op) eq "LOGOP") { push @todo, $op->other; } elsif ($name eq "subst" and ${ $op->pmreplstart }) { push @todo, $op->pmreplstart; } elsif ($name =~ /^enter(loop|iter)$/) { # if ($] > 5.009) { # $labels{${$op->nextop}} = "NEXT"; # $labels{${$op->lastop}} = "LAST"; # $labels{${$op->redoop}} = "REDO"; # } else { # $labels{$op->nextop->seq} = "NEXT"; # $labels{$op->lastop->seq} = "LAST"; # $labels{$op->redoop->seq} = "REDO"; # } } } } local $source; $source = "typedef OP *(*PPFUNC)(pTHX);\n\n"; $source .= "OP *func (pTHX)\n{\n dTHX;\n"; for my $op (@ops) { my $name = $op->name; my $ppaddr = ppaddr $op->type; $source .= "op_$$op: /* $name */\n"; if (my $can = __PACKAGE__->can ("op_$name")) { $can->($op); } elsif ("LOGOP" eq B::class $op or exists $flag{otherop}{$name}) { $source .= " PL_op = ((PPFUNC)${ppaddr}L)(aTHX);\n"; $source .= " if (PL_op == (OP *)${$op->other}L) goto op_${$op->other};\n"; $source .= " goto op_${$op->next};\n"; } elsif (exists $flag{unsafe}{$name}) { $source .= " return ((PPFUNC)${ppaddr}L)(aTHX);\n"; } else { $source .= " PL_op = ((PPFUNC)${ppaddr}L)(aTHX);\n"; $source .= " goto op_${$op->next};\n"; } } $source .= "}\n"; print < http://home.schmorp.de/ =cut