diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-10-08 00:20:21 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-11-27 07:05:01 -0800 |
commit | db2c6cb33ec067c880a2cb3c4efdb33f7e3e3d0f (patch) | |
tree | 2460f0a21a4cfde265cd5fd481296eee2515c150 /regexp.h | |
parent | 08bf00be470db7b367e14733226d4fddc004c796 (diff) | |
download | perl-db2c6cb33ec067c880a2cb3c4efdb33f7e3e3d0f.tar.gz |
New COW mechanism
This was discussed in ticket #114820.
This new copy-on-write mechanism stores a reference count for the
PV inside the PV itself, at the very end. (I was using SvEND+1
at first, but parts of the regexp engine expect to be able to do
SvCUR_set(sv,0), which causes the wrong byte of the string to be used
as the reference count.) Only 256 SVs can share the same PV this way.
Also, only strings with allocated space after the trailing null can
be used for copy-on-write.
Much of the code is shared with PERL_OLD_COPY_ON_WRITE. The restric-
tion against doing copy-on-write with magical variables has hence been
inherited, though it is not necessary. A future commit will take
care of that.
I had to modify _core_swash_init to handle $@ differently. The exist-
ing mechanism of copying $@ to a new scalar and back again was very
fragile. With copy-on-write, $@ =~ s/// can cause pp_subst’s string
pointers to become stale. So now we remove the scalar from *@ and
allow the utf8-table-loading code to autovivify a new one. Then we
restore the untouched $@ afterwards if all goes well.
Diffstat (limited to 'regexp.h')
-rw-r--r-- | regexp.h | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -46,7 +46,7 @@ struct reg_substr_data { struct reg_substr_datum data[3]; /* Actual array */ }; -#ifdef PERL_OLD_COPY_ON_WRITE +#ifdef PERL_ANY_COW #define SV_SAVED_COPY SV *saved_copy; /* If non-NULL, SV which is COW from original */ #else #define SV_SAVED_COPY @@ -495,7 +495,7 @@ get_regex_charset_name(const U32 flags, STRLEN* const lenp) /* Stuff that needs to be included in the pluggable extension goes below here */ -#ifdef PERL_OLD_COPY_ON_WRITE +#ifdef PERL_ANY_COW #define RX_MATCH_COPY_FREE(rx) \ STMT_START {if (RX_SAVED_COPY(rx)) { \ SV_CHECK_THINKFIRST_COW_DROP(RX_SAVED_COPY(rx)); \ @@ -790,7 +790,7 @@ struct re_save_state { U32 re_state_regsize; /* from regexec.c */ char *re_state_reg_poscache; /* cache of pos of WHILEM */ char *re_state_reg_starttry; /* from regexec.c */ -#ifdef PERL_OLD_COPY_ON_WRITE +#ifdef PERL_ANY_COW SV *re_state_nrs; /* was placeholder: unused since 5.8.0 (5.7.2 patch #12027 for bug ID 20010815.012). Used to save rx->saved_copy */ #endif }; |