Allow COW with magical and blessed scalars (among others)
authorFather Chrysostomos <sprout@cpan.org>
Sun, 4 Nov 2012 07:07:31 +0000 (00:07 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 27 Nov 2012 15:05:02 +0000 (07:05 -0800)
commitf7a8268cd8b5af71e2d24a595ca88e48464a3e94
tree36f89842cf7a318481d94bb21c06390ae330061e
parent9fd2152b911b1c311a72e55728050bfa2fc67ca6
Allow COW with magical and blessed scalars (among others)

Under PERL_NEW_COPY_ON_WRITE (and I suspect under
PERL_OLD_COPY_ON_WRITE, too, but have not confirmed) it is harmless to
do copy-on-write with a magical or blessed scalar.

Also, under PERL_NEW_COPY_ON_WRITE, it is safe to do copy-on-write
with scalars that have numbers in them as well as strings (though not
under PERL_OLD_COPY_ON_WRITE).

So redefine CAN_COW_MASK under PERL_NEW_COPY_ON_WRITE to be less
restrictive.  We still can’t do it when the SvOOK hack is in place,
and I don’t feel comfortable doing it with regexps, even if it could
be proven feasible (regexps are SVf_FAKE, so that covers them).

Anything SvROK cannot be SvPOK, so obviously we can’t COW with that,
but I left SVf_ROK in for good measure.

This change to CAN_COW_MASK affects whether non-cow scalars will be
turned into cows in sv_setsv_flags.  It is already possible for exist-
ing cows to become magical, blessed or numeric elsewhere.

Also, we don’t need to check the flags on the lhs in sv_setsv_flags,
except for SVf_BREAK.  This is similar to ecd5fa70f3, but applies to
another branch just below it.

pp_subst needs a little bit of adjustment, as it is not expecting a
vstring to turn into a cow.
pp_hot.c
sv.c
sv.h