diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-11-07 14:55:24 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-11-07 20:14:36 -0800 |
commit | 6abbd373e741488741fdb8a7d9b6ef6ae89ed48c (patch) | |
tree | 375e4ad7208cb9b3ef12faec0cba43adac66396e /regen | |
parent | db098081e3682316e8cf22b9705c2563fc91eaec (diff) | |
download | perl-6abbd373e741488741fdb8a7d9b6ef6ae89ed48c.tar.gz |
Allow OPpTARGET_MY optimisation for x
Many operators have a special SV allocated in the pad which is used
for return values (the target). If we make that pad offset point to
a lexical variable, then we can optimise, say, $lexical = "$foo" into
just "$foo", where $lexical is stringify’s ‘target’. And pp_stringify
doesn’t need to know any better. We already do that for many ops.
This can be extended to x. Despite what the comment in op_private
says, list return values do not matter here, because the OPpTARGET_MY
optimisation only happens when the operator is in scalar context. And
the scalar code paths use TARG and push TARG on to the stack.
Diffstat (limited to 'regen')
-rw-r--r-- | regen/op_private | 1 | ||||
-rw-r--r-- | regen/opcodes | 2 |
2 files changed, 1 insertions, 2 deletions
diff --git a/regen/op_private b/regen/op_private index 40c8bb9f64..a341a97df0 100644 --- a/regen/op_private +++ b/regen/op_private @@ -336,7 +336,6 @@ addbits($_, 7 => qw(OPpLVAL_INTRO LVINTRO)) # trans not OK (dTARG; TARG = sv_newmortal();) # ucfirst etc not OK: TMP arg processed inplace # quotemeta not OK (unsafe when TARG == arg) -# each repeat not OK too due to list context # pack split - unknown whether they are safe # sprintf: is calling do_sprintf(TARG,...) which can act on TARG # before other args are processed. diff --git a/regen/opcodes b/regen/opcodes index 0df672086b..6328b0ed29 100644 --- a/regen/opcodes +++ b/regen/opcodes @@ -126,7 +126,7 @@ divide division (/) ck_null IfsT2 S S i_divide integer division (/) ck_null ifsT2 S S modulo modulus (%) ck_null IifsT2 S S i_modulo integer modulus (%) ck_null ifsT2 S S -repeat repeat (x) ck_repeat fmt2 L S +repeat repeat (x) ck_repeat fmT2 L S add addition (+) ck_null IfsT2 S S i_add integer addition (+) ck_null ifsT2 S S |