diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2022-08-06 21:55:28 +0000 |
---|---|---|
committer | Richard Leach <richardleach@users.noreply.github.com> | 2022-09-07 20:27:27 +0100 |
commit | aafefcb90183e1d6ef62d9e1ccc1fae7fcdf9c8e (patch) | |
tree | b870aefc05d58e8daabe190802e82f35047d32c7 /lib | |
parent | ec18fac0008c98267fc560f7023d1d11703ed66d (diff) | |
download | perl-aafefcb90183e1d6ef62d9e1ccc1fae7fcdf9c8e.tar.gz |
OP_AELEMFASTLEX_STORE - combined sassign/aelemfast_lex
This commit introduces a new OP to replace simple cases of OP_SASSIGN
and OP_AELEMFAST_LEX. (Similar concept to GH #19943)
For example, `my @ary; $ary[0] = "boo"` is currently implemented as:
7 <2> sassign vKS/2 ->8
5 <$> const[PV "boo"] s ->6
- <1> ex-aelem sKRM*/2 ->7
6 <0> aelemfast_lex[@ary:1,2] sRM ->7
- <0> ex-const s ->-
But now will be turned into:
6 <1> aelemfastlex_store[@ary:1,2] vKS ->7
5 <$> const(PV "boo") s ->6
- <1> ex-aelem sKRM*/2 ->6
- <0> ex-aelemfast_lex sRM ->6
- <0> ex-const s ->-
This is intended to be a transparent performance optimization.
It should be applicable for RHS optrees of varying complexity.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/B/Deparse.pm | 11 | ||||
-rw-r--r-- | lib/B/Op_private.pm | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm index 8cd02ce4dc..8895204308 100644 --- a/lib/B/Deparse.pm +++ b/lib/B/Deparse.pm @@ -4305,6 +4305,17 @@ sub pp_gv { return $self->maybe_qualify("", $self->gv_name($gv)); } +sub pp_aelemfastlex_store { + my $self = shift; + my($op, $cx) = @_; + my $name = $self->padname($op->targ); + $name =~ s/^@/\$/; + my $i = $op->private; + $i -= 256 if $i > 127; + my $val = $self->deparse($op->first, 7); + return $self->maybe_parens("${name}[$i] = $val", $cx, 7); +} + sub pp_aelemfast_lex { my $self = shift; my($op, $cx) = @_; diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm index df34dff846..01931ed94f 100644 --- a/lib/B/Op_private.pm +++ b/lib/B/Op_private.pm @@ -254,6 +254,7 @@ $bits{aeach}{0} = $bf[0]; @{$bits{aelem}}{5,4,1,0} = ($bf[8], $bf[8], $bf[1], $bf[1]); @{$bits{aelemfast}}{7,6,5,4,3,2,1,0} = ($bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6]); @{$bits{aelemfast_lex}}{7,6,5,4,3,2,1,0} = ($bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6]); +@{$bits{aelemfastlex_store}}{7,6,5,4,3,2,1,0} = ($bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6], $bf[6]); $bits{akeys}{0} = $bf[0]; $bits{alarm}{0} = $bf[0]; $bits{and}{0} = $bf[0]; |