diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-11-14 13:02:48 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-11-14 13:10:58 -0800 |
commit | e3918bb703cafa92e5a8d957a810cafe3334d9a1 (patch) | |
tree | 0dc55cf37087f45a20d83132e32b1f5fb8feb14d /sv.h | |
parent | e9cb264cbba0cfffe4b822389c0be43c54755b66 (diff) | |
download | perl-e3918bb703cafa92e5a8d957a810cafe3334d9a1.tar.gz |
SVf_IsCOW
As discussed in ticket #114820, instead of using READONLY+FAKE to mark
a copy-on-write string, we should make it a separate flag.
There are many modules in CPAN (and 1 in core, Compress::Raw::Zlib)
that assume that SvREADONLY means read-only. Only one CPAN module,
POSIX::pselect will definitely be broken by this. Others may need to
be tweaked. But I believe this is for the better.
It causes all tests except ext/Devel-Peek/t/Peek.t (which needs a tiny
tweak still) to pass under PERL_OLD_COPY_ON_WRITE, which is a prereq-
uisite for any new COW scheme that creates COWs under the same cir-
cumstances.
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -338,7 +338,8 @@ perform the upgrade if necessary. See C<svtype>. subroutine in another package. Set the GvIMPORTED_CV_on() if it needs to be expanded to a real GV */ -/* 0x00010000 *** FREE SLOT */ +#define SVf_IsCOW 0x00010000 /* copy on write (shared hash key if + SvLEN == 0) */ #define SVs_PADTMP 0x00020000 /* in use as tmp; only if ! SVs_PADMY */ #define SVs_PADSTALE 0x00020000 /* lexical has gone out of scope; only valid for SVs_PADMY */ @@ -353,17 +354,13 @@ perform the upgrade if necessary. See C<svtype>. #define SVf_FAKE 0x01000000 /* 0: glob is just a copy 1: SV head arena wasn't malloc()ed - 2: in conjunction with SVf_READONLY - marks a shared hash key scalar - (SvLEN == 0) or a copy on write - string (SvLEN != 0) [SvIsCOW(sv)] - 3: For PVCV, whether CvUNIQUE(cv) + 2: For PVCV, whether CvUNIQUE(cv) refers to an eval or once only [CvEVAL(cv), CvSPECIAL(cv)] - 4: On a pad name SV, that slot in the + 3: On a pad name SV, that slot in the frame AV is a REFCNT'ed reference to a lexical from "outside". */ -#define SVphv_REHASH SVf_FAKE /* 5: On a PVHV, hash values are being +#define SVphv_REHASH SVf_FAKE /* 4: On a PVHV, hash values are being recalculated */ #define SVf_OOK 0x02000000 /* has valid offset value. For a PVHV this means that a hv_aux struct is present @@ -377,7 +374,7 @@ perform the upgrade if necessary. See C<svtype>. -#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK|SVf_FAKE|SVs_RMG) +#define SVf_THINKFIRST (SVf_READONLY|SVf_ROK|SVf_FAKE|SVs_RMG|SVf_IsCOW) #define SVf_OK (SVf_IOK|SVf_NOK|SVf_POK|SVf_ROK| \ SVp_IOK|SVp_NOK|SVp_POK|SVpgv_GP) @@ -1765,9 +1762,9 @@ Like sv_utf8_upgrade, but doesn't do magic on C<sv>. || (PL_Xpv->xpv_cur && *PL_Sv->sv_u.svu_pv != '0'))) #endif /* __GNU__ */ -#define SvIsCOW(sv) ((SvFLAGS(sv) & (SVf_FAKE | SVf_READONLY)) == \ - (SVf_FAKE | SVf_READONLY) && !isGV_with_GP(sv) \ - && SvTYPE(sv) != SVt_REGEXP) +#define SvIsCOW(sv) (SvFLAGS(sv) & SVf_IsCOW) +#define SvIsCOW_on(sv) (SvFLAGS(sv) |= SVf_IsCOW) +#define SvIsCOW_off(sv) (SvFLAGS(sv) &= ~SVf_IsCOW) #define SvIsCOW_shared_hash(sv) (SvIsCOW(sv) && SvLEN(sv) == 0) #define SvSHARED_HEK_FROM_PV(pvx) \ |