In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/247f9b19318882fd9a52fe49aa31fc8d3d3db4f7?hp=1e3f3188c877f8581aeccab7f8ec866b7a978b8b>
- Log ----------------------------------------------------------------- commit 247f9b19318882fd9a52fe49aa31fc8d3d3db4f7 Author: Karl Williamson <[email protected]> Date: Thu Jul 4 18:57:55 2013 -0600 Revert "regcomp.c: Move some #defines to only file that uses them" This reverts commit 05944450e0fc82eb8fc1fb5a4bf63f23785262a0. Blead won't compile with address sanitizer; commit 7cb47964955167736b2923b008cc8023a9b035e8 reverting an earlier commit failed to fix that. I'm trying two more reversions to get it back working. This is one of those M inline_invlist.c M regcomp.c commit 49cf1d6641a6dfd301302f616e4f25595dcc65d4 Author: Karl Williamson <[email protected]> Date: Thu Jul 4 18:55:11 2013 -0600 Revert "Create SVt_INVLIST" This reverts commit e045dbedc7da04e20cc8cfccec8a2e3ccc62cc8b. Blead won't compile with address sanitizer; commit 7cb47964955167736b2923b008cc8023a9b035e8 reverting an earlier commit failed to fix that. I'm trying two more reversions to get it back working. This is one of those M dist/Storable/Storable.pm M dist/Storable/Storable.xs M dump.c M ext/B/B.xs M perl.h M sv.c M sv.h ----------------------------------------------------------------------- Summary of changes: dist/Storable/Storable.pm | 2 +- dist/Storable/Storable.xs | 2 +- dump.c | 7 ++++--- ext/B/B.xs | 2 +- inline_invlist.c | 24 ++++++++++++++++++++++++ perl.h | 14 +++++++------- regcomp.c | 31 ++++++++++++------------------- sv.c | 18 +++++++++--------- sv.h | 20 ++++++-------------- 9 files changed, 65 insertions(+), 55 deletions(-) diff --git a/dist/Storable/Storable.pm b/dist/Storable/Storable.pm index 5f63871..1a73c3f 100644 --- a/dist/Storable/Storable.pm +++ b/dist/Storable/Storable.pm @@ -21,7 +21,7 @@ package Storable; @ISA = qw(Exporter); use vars qw($canonical $forgive_me $VERSION); -$VERSION = '2.44'; +$VERSION = '2.43'; BEGIN { if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) { diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs index f21f053..08641cd 100644 --- a/dist/Storable/Storable.xs +++ b/dist/Storable/Storable.xs @@ -3469,7 +3469,7 @@ static int sv_type(pTHX_ SV *sv) case SVt_PVCV: return svis_CODE; #if PERL_VERSION > 8 - /* case SVt_INVLIST: */ + /* case SVt_DUMMY: */ #endif default: break; diff --git a/dump.c b/dump.c index 6ba4fd2..5ca838b 100644 --- a/dump.c +++ b/dump.c @@ -27,12 +27,13 @@ #include "perl.h" #include "regcomp.h" + static const char* const svtypenames[SVt_LAST] = { "NULL", + "DUMMY", "IV", "NV", "PV", - "INVLIST", "PVIV", "PVNV", "PVMG", @@ -49,10 +50,10 @@ static const char* const svtypenames[SVt_LAST] = { static const char* const svshorttypenames[SVt_LAST] = { "UNDEF", + "DUMMY", "IV", "NV", "PV", - "INVLST", "PVIV", "PVNV", "PVMG", @@ -2797,7 +2798,7 @@ Perl_sv_xmlpeek(pTHX_ SV *sv) case SVt_PVGV: sv_catpv(t, " GV=\""); break; - case SVt_INVLIST: + case SVt_DUMMY: sv_catpv(t, " DUMMY=\""); break; case SVt_REGEXP: diff --git a/ext/B/B.xs b/ext/B/B.xs index e7049f0..fbe6be6 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -21,13 +21,13 @@ typedef FILE * InputStream; static const char* const svclassnames[] = { "B::NULL", + "B::BIND", "B::IV", "B::NV", #if PERL_VERSION <= 10 "B::RV", #endif "B::PV", - "B::INVLIST", "B::PVIV", "B::PVNV", "B::PVMG", diff --git a/inline_invlist.c b/inline_invlist.c index ced42d8..c6bc47e 100644 --- a/inline_invlist.c +++ b/inline_invlist.c @@ -8,6 +8,30 @@ #if defined(PERL_IN_UTF8_C) || defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_REGEXEC_C) +#define INVLIST_LEN_OFFSET 0 /* Number of elements in the inversion list */ + +/* This is a combination of a version and data structure type, so that one + * being passed in can be validated to be an inversion list of the correct + * vintage. When the structure of the header is changed, a new random number + * in the range 2**31-1 should be generated. Then, if an auxiliary program + * doesn't change correspondingly, it will be discovered immediately */ +#define INVLIST_VERSION_ID_OFFSET 1 +#define INVLIST_VERSION_ID 1826693541 + +#define INVLIST_OFFSET_OFFSET 2 /* 0 or 1 */ +/* The UV at this position contains either 0 or 1. If 0, the inversion list + * contains the code point U+00000, and begins at element [0] in the array, + * which always contains 0. If 1, the inversion list doesn't contain U+0000, + * and it begins at element [1]. Inverting an inversion list consists of + * adding or removing the 0 at the beginning of it. By reserving a space for + * that 0, inversion can be made very fast: we just flip this UV */ + +/* For safety, when adding new elements, remember to #undef them at the end of + * the inversion list code section */ + +#define HEADER_LENGTH (INVLIST_OFFSET_OFFSET + 1) /* includes 1 for the constant + 0 element */ + /* An element is in an inversion list iff its index is even numbered: 0, 2, 4, * etc */ #define ELEMENT_RANGE_MATCHES_INVLIST(i) (! ((i) & 1)) diff --git a/perl.h b/perl.h index 16e339c..0593461 100644 --- a/perl.h +++ b/perl.h @@ -5043,19 +5043,19 @@ EXTCONST U8 PL_magic_data[256]; #endif #ifdef DOINIT - /* NL IV NV PV INV PI PN MG RX GV LV AV HV CV FM IO */ + /* NL BD IV NV PV PI PN MG RX GV LV AV HV CV FM IO */ EXTCONST bool -PL_valid_types_IVX[] = { 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 }; +PL_valid_types_IVX[] = { 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 }; EXTCONST bool -PL_valid_types_NVX[] = { 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 }; +PL_valid_types_NVX[] = { 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 }; EXTCONST bool -PL_valid_types_PVX[] = { 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1 }; +PL_valid_types_PVX[] = { 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1 }; EXTCONST bool -PL_valid_types_RV[] = { 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 }; +PL_valid_types_RV[] = { 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 }; EXTCONST bool -PL_valid_types_IV_set[] = { 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1 }; +PL_valid_types_IV_set[] = { 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1 }; EXTCONST bool -PL_valid_types_NV_set[] = { 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; +PL_valid_types_NV_set[] = { 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; #else diff --git a/regcomp.c b/regcomp.c index 160ef717..3a5a417 100644 --- a/regcomp.c +++ b/regcomp.c @@ -7075,6 +7075,7 @@ S_reg_scan_name(pTHX_ RExC_state_t *pRExC_state, U32 flags) #define TO_INTERNAL_SIZE(x) (((x) + 1) * sizeof(UV)) #define FROM_INTERNAL_SIZE(x) (((x)/ sizeof(UV)) - 1) +#define INVLIST_INITIAL_LEN 10 PERL_STATIC_INLINE UV* S__invlist_array_init(pTHX_ SV* const invlist, const bool will_have_0) @@ -7210,7 +7211,7 @@ Perl__new_invlist(pTHX_ IV initial_size) U8* offset_addr; if (initial_size < 0) { - initial_size = 10; + initial_size = INVLIST_INITIAL_LEN; } /* Allocate the initial space */ @@ -7229,6 +7230,9 @@ Perl__new_invlist(pTHX_ IV initial_size) *offset_addr = (U8) UV_MAX; *get_invlist_previous_index_addr(new_list) = 0; +#if HEADER_LENGTH != 3 +# error Need to regenerate INVLIST_VERSION_ID by running perl -E 'say int(rand 2**31-1)', and then changing the #if to the new length +#endif return new_list; } @@ -7240,29 +7244,15 @@ S__new_invlist_C_array(pTHX_ const UV* const list) /* Return a pointer to a newly constructed inversion list, initialized to * point to <list>, which has to be in the exact correct inversion list * form, including internal fields. Thus this is a dangerous routine that - * should not be used in the wrong hands. The passed in 'list' contains - * several header fields at the beginning that are not part of the - * inversion list body proper */ - - const STRLEN length = (STRLEN) list[0]; - const UV version_id = list[1]; - const U8 offset = (U8) list[2]; -#define HEADER_LENGTH 3 - /* If any of the above changes in any way, you must change HEADER_LENGTH - * (if appropriate) and regenerate INVLIST_VERSION_ID by running - * perl -E 'say int(rand 2**31-1)' - */ -#define INVLIST_VERSION_ID 1826693541/* This is a combination of a version and - data structure type, so that one being - passed in can be validated to be an - inversion list of the correct vintage. - */ + * should not be used in the wrong hands */ SV* invlist = newSV_type(SVt_PVLV); + STRLEN length = (STRLEN) list[INVLIST_LEN_OFFSET]; + U8 offset = (U8) list[INVLIST_OFFSET_OFFSET]; PERL_ARGS_ASSERT__NEW_INVLIST_C_ARRAY; - if (version_id != INVLIST_VERSION_ID) { + if (list[INVLIST_VERSION_ID_OFFSET] != INVLIST_VERSION_ID) { Perl_croak(aTHX_ "panic: Incorrect version for previously generated inversion list"); } @@ -8399,8 +8389,11 @@ S__invlistEQ(pTHX_ SV* const a, SV* const b, const bool complement_b) #endif #undef HEADER_LENGTH +#undef INVLIST_INITIAL_LENGTH #undef TO_INTERNAL_SIZE #undef FROM_INTERNAL_SIZE +#undef INVLIST_LEN_OFFSET +#undef INVLIST_OFFSET_OFFSET #undef INVLIST_VERSION_ID /* End of inversion list object */ diff --git a/sv.c b/sv.c index 25aad04..0e33556 100644 --- a/sv.c +++ b/sv.c @@ -881,6 +881,11 @@ static const struct body_details bodies_by_type[] = { /* HEs use this offset for their arena. */ { 0, 0, 0, SVt_NULL, FALSE, NONV, NOARENA, 0 }, + /* The bind placeholder pretends to be an RV for now. + Also it's marked as "can't upgrade" to stop anyone using it before it's + implemented. */ + { 0, 0, 0, SVt_DUMMY, TRUE, NONV, NOARENA, 0 }, + /* IVs are in the head, so the allocation size is 0. */ { 0, sizeof(IV), /* This is used to copy out the IV body. */ @@ -898,11 +903,6 @@ static const struct body_details bodies_by_type[] = { SVt_PV, FALSE, NONV, HASARENA, FIT_ARENA(0, sizeof(XPV) - STRUCT_OFFSET(XPV, xpv_cur)) }, - /* The invlist placeholder pretends to be an RV for now. - Also it's marked as "can't upgrade" to stop anyone using it before it's - implemented. */ - { 0, 0, 0, SVt_INVLIST, TRUE, NONV, NOARENA, 0 }, - { sizeof(XPVIV) - STRUCT_OFFSET(XPV, xpv_cur), copy_length(XPVIV, xiv_u) - STRUCT_OFFSET(XPV, xpv_cur), + STRUCT_OFFSET(XPV, xpv_cur), @@ -4117,7 +4117,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, SV* sstr, const I32 flags) } break; - /* case SVt_INVLIST: */ + /* case SVt_DUMMY: */ case SVt_PVLV: case SVt_PVGV: case SVt_PVMG: @@ -6184,7 +6184,7 @@ Perl_sv_clear(pTHX_ SV *const orig_sv) SvREFCNT_dec(SvSTASH(sv)); } switch (type) { - /* case SVt_INVLIST: */ + /* case SVt_DUMMY: */ case SVt_PVIO: if (IoIFP(sv) && IoIFP(sv) != PerlIO_stdin() && @@ -9446,7 +9446,7 @@ Perl_sv_reftype(pTHX_ const SV *const sv, const int ob) ? "GLOB" : "SCALAR"); case SVt_PVFM: return "FORMAT"; case SVt_PVIO: return "IO"; - case SVt_INVLIST: return "INVLIST"; + case SVt_DUMMY: return "DUMMY"; case SVt_REGEXP: return "REGEXP"; default: return "UNKNOWN"; } @@ -12183,7 +12183,7 @@ S_sv_dup_common(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) SvANY(dstr) = new_XNV(); SvNV_set(dstr, SvNVX(sstr)); break; - /* case SVt_INVLIST: */ + /* case SVt_DUMMY: */ default: { /* These are all the types that need complex bodies allocating. */ diff --git a/sv.h b/sv.h index 475da61..0c1ded6 100644 --- a/sv.h +++ b/sv.h @@ -29,7 +29,6 @@ The types are: SVt_PVIV SVt_PVNV SVt_PVMG - SVt_INVLIST SVt_REGEXP SVt_PVGV SVt_PVLV @@ -57,8 +56,7 @@ typeglob has been assigned. Assigning to it again will stop it from being a typeglob. SVt_PVLV represents a scalar that delegates to another scalar behind the scenes. It is used, e.g., for the return value of C<substr> and for tied hash and array elements. It can hold any scalar value, including -a typeglob. SVt_REGEXP is for regular expressions. SVt_INVLIST is for Perl -core internal use only. +a typeglob. SVt_REGEXP is for regular expressions. SVt_PVMG represents a "normal" scalar (not a typeglob, regular expression, or delegate). Since most scalars do not need all the internal fields of a @@ -92,9 +90,6 @@ Type flag for scalars. See L</svtype>. =for apidoc AmU||SVt_PVMG Type flag for scalars. See L</svtype>. -=for apidoc AmU||SVt_INVLIST -Type flag for scalars. See L</svtype>. - =for apidoc AmU||SVt_REGEXP Type flag for regular expressions. See L</svtype>. @@ -124,12 +119,11 @@ Type flag for I/O objects. See L</svtype>. typedef enum { SVt_NULL, /* 0 */ - /* BIND was here, before INVLIST replaced it. */ - SVt_IV, /* 1 */ - SVt_NV, /* 2 */ + SVt_DUMMY, /* 1 */ + SVt_IV, /* 2 */ + SVt_NV, /* 3 */ /* RV was here, before it was merged with IV. */ - SVt_PV, /* 3 */ - SVt_INVLIST, /* 4, implemented as a PV */ + SVt_PV, /* 4 */ SVt_PVIV, /* 5 */ SVt_PVNV, /* 6 */ SVt_PVMG, /* 7 */ @@ -146,9 +140,7 @@ typedef enum { } svtype; /* *** any alterations to the SV types above need to be reflected in - * SVt_MASK and the various PL_valid_types_* tables. As of this writing those - * tables are in perl.h. There are also two affected names tables in dump.c, - * one in B.xs, and 'bodies_by_type[]' in sv.c */ + * SVt_MASK and the various PL_valid_types_* tables */ #define SVt_MASK 0xf /* smallest bitmask that covers all types */ -- Perl5 Master Repository
