summaryrefslogtreecommitdiff
path: root/ext/B
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2014-02-23 00:53:17 +0000
committerDavid Mitchell <davem@iabyn.com>2014-02-28 13:35:12 +0000
commitb024352e692dd231fd32548e325d75b667bff29f (patch)
tree73006fac333d4519790bfac2e8434f555ecc0c9b /ext/B
parente958ef3d8fccb2d78757ebb06ce8b1030ef4f1d0 (diff)
downloadperl-b024352e692dd231fd32548e325d75b667bff29f.tar.gz
make OP_AELEMFAST work with negative indices
Use aelemfast for literal index array access where the index is in the range -128..127, rather than 0..255. You'd expect something like $a[-1] or $a[-2] to be a lot more common than $a[100] say. In fact a quick CPAN grep shows 66 distributions matching /\$\w+\[\d{3,}\]/, but "at least" 1000 matching /\$\w+\[\-\d\]/. And most of the former appear to be table initialisations.
Diffstat (limited to 'ext/B')
-rw-r--r--ext/B/t/optree_misc.t14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/B/t/optree_misc.t b/ext/B/t/optree_misc.t
index f012a50c85..f327bfc036 100644
--- a/ext/B/t/optree_misc.t
+++ b/ext/B/t/optree_misc.t
@@ -24,7 +24,7 @@ skip "no perlio in this build", 4 unless $Config::Config{useperlio};
# All this is much simpler, now that aelemfast_lex has been broken out from
# aelemfast
checkOptree ( name => 'OP_AELEMFAST opclass',
- code => sub { my @x; our @y; $x[0] + $y[0]},
+ code => sub { my @x; our @y; $x[127] + $y[-128]},
strip_open_hints => 1,
expect => <<'EOT_EOT', expect_nt => <<'EONT_EONT');
# a <1> leavesub[1 ref] K/REFC,1 ->(end)
@@ -37,12 +37,12 @@ checkOptree ( name => 'OP_AELEMFAST opclass',
# 6 <;> nextstate(main 636 optree_misc.t:25) v:>,<,%,{ ->7
# 9 <2> add[t6] sK/2 ->a
# - <1> ex-aelem sK/2 ->8
-# 7 <0> aelemfast_lex[@x:634,636] sR ->8
+# 7 <0> aelemfast_lex[@x:634,636] sR/127 ->8
# - <0> ex-const s ->-
# - <1> ex-aelem sK/2 ->9
# - <1> ex-rv2av sKR/1 ->-
-# 8 <#> aelemfast[*y] s ->9
-# - <0> ex-const s ->-
+# 8 <#> aelemfast[*y] s/128 ->9
+# - <0> ex-const s/FOLD ->-
EOT_EOT
# a <1> leavesub[1 ref] K/REFC,1 ->(end)
# - <@> lineseq KP ->a
@@ -54,12 +54,12 @@ EOT_EOT
# 6 <;> nextstate(main 636 optree_misc.t:27) v:>,<,%,{ ->7
# 9 <2> add[t4] sK/2 ->a
# - <1> ex-aelem sK/2 ->8
-# 7 <0> aelemfast_lex[@x:634,636] sR ->8
+# 7 <0> aelemfast_lex[@x:634,636] sR/127 ->8
# - <0> ex-const s ->-
# - <1> ex-aelem sK/2 ->9
# - <1> ex-rv2av sKR/1 ->-
-# 8 <$> aelemfast(*y) s ->9
-# - <0> ex-const s ->-
+# 8 <$> aelemfast(*y) s/128 ->9
+# - <0> ex-const s/FOLD ->-
EONT_EONT
checkOptree ( name => 'PMOP children',