In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/9a3da3ad91578c710ccb88f36e117c5a4cb0f7d1?hp=2310e17474d466b55500d4967d2d30e25058760c>
- Log ----------------------------------------------------------------- commit 9a3da3ad91578c710ccb88f36e117c5a4cb0f7d1 Author: Father Chrysostomos <[email protected]> Date: Thu Dec 4 17:28:19 2014 -0800 Correct dependencies for charclass_invlists.h regen.t should fail if Unicode tables are updated and this header is not regenerated. See commit 713f4b7fa and the thread beginning at <[email protected]>. M charclass_invlists.h M regen/mk_invlists.pl commit 964751a437e0e3c2a2f6c744e85be6ade383c34f Author: Father Chrysostomos <[email protected]> Date: Thu Dec 4 16:13:19 2014 -0800 op.c:fold_constants: Remove OP_RV2GV/newGVOP OP_RV2GV is not foldable, so it never reaches this code, which goes back to 79072805 (perl 5.0 alpha 2). Even back then it was unreachable. M op.c commit db722616f095a0f15e29aad3b5e164b2fa9f5f05 Author: Father Chrysostomos <[email protected]> Date: Thu Dec 4 16:11:02 2014 -0800 op.c:fold_constants: Simplify OP_STRINGIFY logic Donât put the same condition in two places. We are already using a bool- ean. We can put the result of the condition in it. M op.c commit 6d4eed2136c73d9331ed2edb2e7650c90b974ea7 Author: Father Chrysostomos <[email protected]> Date: Thu Dec 4 16:07:45 2014 -0800 Return fresh scalar from join(const,const) $ perl5.20.1 -Ilib -le 'for(1,2) { push @_, \join "x", 1 } print for @_' SCALAR(0x7fb131005438) SCALAR(0x7fb131005648) $ ./perl -Ilib -le 'for(1,2) { push @_, \join "x", 1 } print for @_' SCALAR(0x7fe612831b30) SCALAR(0x7fe612831b30) Notice how we now get two references to the same scalar. I broke this accidentally in 987c9691. If join has two arguments, it gets con- verted to a stringify op. The stringify op might get constant-folded, and folding of stringify is special, because the parser uses it itself to implement qq(). So I had ck_join set op_folded to flag the op as being a folded join. Only that came too late, because op_convert_list(OP_STRINGIFY,...) folds the op before it returns it. Hence, the folded constant was flagged the wrong way, and stopped being implicitly copied by refgen (\). M op.c M op.h M t/op/join.t ----------------------------------------------------------------------- Summary of changes: charclass_invlists.h | 43 ++++++++++++++++++++++++++++++++++++++++++- op.c | 29 +++++++++++++---------------- op.h | 4 ++++ regen/mk_invlists.pl | 14 +++++++++++++- t/op/join.t | 6 +++++- 5 files changed, 77 insertions(+), 19 deletions(-) diff --git a/charclass_invlists.h b/charclass_invlists.h index 0907f12..2d4abf9 100644 --- a/charclass_invlists.h +++ b/charclass_invlists.h @@ -50101,5 +50101,46 @@ static const UV _Perl_IDCont_invlist[] = { /* for EBCDIC POSIX-BC */ #endif /* EBCDIC POSIX-BC */ /* Generated from: - * d8772d2511bca9f2072104eb35b5a3943111af908dfe772214d64baf0fef3cbd regen/mk_invlists.pl + * b42e5a66f6ee1e7586e2d9b70c61cac003a4567fa242c3b5b74fb1edf57f2abc lib/Unicode/UCD.pm + * 827aa7ee45ca9fe09f3e0969a5a27a69ce58a6c7134548125266210018d27b49 lib/unicore/ArabicShaping.txt + * 3748fbbe9d280a9da700bfd0c28beaaf6f32a67ec263a124fcb0a4095a30fae5 lib/unicore/BidiBrackets.txt + * 3925329c2432fa7248b2e180cddcedb9a4f9eafbbb10ab9e105eaf833043b2fb lib/unicore/BidiMirroring.txt + * 7f5a1b4a346c6cdbe948d3baf50fc31fff29c26bcd4ad422dc1fbcc1c23b0bde lib/unicore/Blocks.txt + * 82f3cc8217455f22d294d7df767a62906baf31456ea8902336ae7fee943a2538 lib/unicore/CaseFolding.txt + * 8be553529f7dd22e3e0ffa25eb3f1743f5243bbfe868559be73bf3a163c21913 lib/unicore/CompositionExclusions.txt + * ab64278818411762311b9d5974438ac5cf14e98c79b44a6373022f0780de38a7 lib/unicore/DAge.txt + * f2ff892add5e6624cee8300c297373216df7f1a596c6e74510afe5e8b96c8d91 lib/unicore/DCoreProperties.txt + * 656aa2c6996a049e84c6d38676bc73c3245c808869d64073b812690ae475d534 lib/unicore/DNormalizationProps.txt + * e064b066e555cbace95951fcba9b5336a4d04c88c5949a1ff7615190eaa67682 lib/unicore/EastAsianWidth.txt + * 2aa574984e9cea6980eddd6e36044168d543b7f0449266fa3248aca28790cf06 lib/unicore/HangulSyllableType.txt + * e7122c4d4d598854b5fbefeb2b1ee9f05aef6a8d6e718b5f56c2a8ea31145f12 lib/unicore/IndicMatraCategory.txt + * 478ca00ea86b47209f0b27eb3959ad83cb2b76f5159213d242390d07d5af2b8d lib/unicore/IndicSyllabicCategory.txt + * 0aa8af5cbb4d0570b1006aefffc021c6ef637dffb15572a5a85e7f7e7778fe22 lib/unicore/Jamo.txt + * 3b359eeff325f7e773ea9d5feb8af053b94c579844f0db7ce648f418c9d136d8 lib/unicore/LineBreak.txt + * af85d961d0ed6055271ca6e0174451a8dc1822e31de9e07e1246535318b9341a lib/unicore/NameAliases.txt + * 1c379b9c1b0f6cd14208b766f74fc92ff5a9528aee66083db307f1fc9a615729 lib/unicore/NamedSequences.txt + * 0df343d93293f14e9ff0b0a721d8b8e6c23c86dbad7be18d362d6bf1281590d9 lib/unicore/PropList.txt + * 6c14f474761b8db46f95cf2d1e235ce40abf3382226c5b1a2210df83775fe6fa lib/unicore/PropValueAliases.txt + * 3f3dd77644faa905ce02de7c0e3167fdc4afdf94748f074192bd70821c8341ea lib/unicore/PropertyAliases.txt + * 2767531dec8c525a317ab488b95eed73461fe9c6fbb8088594f3886964724475 lib/unicore/ScriptExtensions.txt + * a638f9f0eb3c521ed6c7755fce93c04bf6e4ba89f23ac3d1bd4c4e486c400118 lib/unicore/Scripts.txt + * 35496d45fc8babd8deb866491ea82ff7b3d2d49ad4c9c656685cd14833101e25 lib/unicore/SpecialCasing.txt + * bfa3da58ea982199829e1107ac5a9a544b83100470a2d0cc28fb50ec234cb840 lib/unicore/UnicodeData.txt + * 916289f471c4a337fb1e0715985a11e6bc8bb205736e84164849d601d265d9e0 lib/unicore/auxiliary/GCBTest.txt + * 3d7ffae56e506d595f3e0e5d36978bc6721d53470e5ca9666ad7cdfc4a46cb3d lib/unicore/auxiliary/GraphemeBreakProperty.txt + * 28356f6912113a9fe8244d9396e9786115dbc10b3ffb5e31b08969122e91d3f3 lib/unicore/auxiliary/SentenceBreakProperty.txt + * 82f7304030e6866ef8e02cdfb0485c52c18a661282bfce9c259cc6300abd79ad lib/unicore/auxiliary/WordBreakProperty.txt + * b88801b4a469207892a0401697c6b1c5fd64042ae0ef867f4ad0ec04942b415c lib/unicore/extracted/DBidiClass.txt + * 074d33ea6c7349eab840d690369dffb3568e2f7b039552b7c10480274d321545 lib/unicore/extracted/DBinaryProperties.txt + * 8ad457aef3525aedce823b9177dad33e0088df536dff11e3df405ecefc92ba08 lib/unicore/extracted/DCombiningClass.txt + * 59ec46c1e30458ffff50d41196fd45e3bbaf3172a8111117af1b930199be2d96 lib/unicore/extracted/DDecompositionType.txt + * cf7c07557ae915a7508c6c7fc8c2e8c900782364ec62e8a5d2813f3b97449ee0 lib/unicore/extracted/DEastAsianWidth.txt + * 56a5b47331a7ec784e848bcaae1ddc08cbf72aab583ca82dcc98ecf2851a3d43 lib/unicore/extracted/DGeneralCategory.txt + * c14e83161e56eb15d78b1589352d6c0bd8feb7889a5d17f70a2ebb2a43cab86d lib/unicore/extracted/DJoinGroup.txt + * 8c9405c54d8b1dd3fe2f2d691b30c0816ca15481995152ed07fc9b844dfd0ad4 lib/unicore/extracted/DJoinType.txt + * a9791f08281d7b0a417e4ad882cf64463f6815db8156932acd85228ac717fd94 lib/unicore/extracted/DLineBreak.txt + * a17a0330e57d774343a53c019f1bc69827c2676982a1bf48e0898a76710e8877 lib/unicore/extracted/DNumType.txt + * c2cb810a67cc5fb4a8d236b6c1bc6dd4d89733d8603881997e8aae2c816a3db1 lib/unicore/extracted/DNumValues.txt + * 746472de66b936ac885ca6d6e68058242b4e909e3260c6317f3ec719f78f76cc lib/unicore/version + * 94e7dc7c1f9aa10a692d755661f597485c70b7eeb8eb14d72ba6ea3220ca9aca regen/mk_invlists.pl * ex: set ro: */ diff --git a/op.c b/op.c index 476d154..b58d791 100644 --- a/op.c +++ b/op.c @@ -4075,7 +4075,7 @@ S_fold_constants(pTHX_ OP *o) OP * VOL curop; OP *newop; VOL I32 type = o->op_type; - bool folded; + bool is_stringify; SV * VOL sv = NULL; int ret = 0; I32 oldscope; @@ -4222,25 +4222,21 @@ S_fold_constants(pTHX_ OP *o) if (ret) goto nope; - folded = cBOOL(o->op_folded); + /* OP_STRINGIFY and constant folding are used to implement qq. + Here the constant folding is an implementation detail that we + want to hide. If the stringify op is itself already marked + folded, however, then it is actually a folded join. */ + is_stringify = type == OP_STRINGIFY && !o->op_folded; op_free(o); assert(sv); - if (type == OP_STRINGIFY) SvPADTMP_off(sv); + if (is_stringify) + SvPADTMP_off(sv); else if (!SvIMMORTAL(sv)) { SvPADTMP_on(sv); SvREADONLY_on(sv); } - if (type == OP_RV2GV) - newop = newGVOP(OP_GV, 0, MUTABLE_GV(sv)); - else - { - newop = newSVOP(OP_CONST, 0, MUTABLE_SV(sv)); - /* OP_STRINGIFY and constant folding are used to implement qq. - Here the constant folding is an implementation detail that we - want to hide. If the stringify op is itself already marked - folded, however, then it is actually a folded join. */ - if (type != OP_STRINGIFY || folded) newop->op_folded = 1; - } + newop = newSVOP(OP_CONST, 0, MUTABLE_SV(sv)); + if (!is_stringify) newop->op_folded = 1; return newop; nope: @@ -4450,6 +4446,8 @@ Perl_op_convert_list(pTHX_ I32 type, I32 flags, OP *o) CHANGE_TYPE(o, type); o->op_flags |= flags; + if (flags & OPf_FOLDED) + o->op_folded = 1; o = CHECKOP(type, o); if (o->op_type != (unsigned)type) @@ -10973,10 +10971,9 @@ Perl_ck_join(pTHX_ OP *o) if (bairn && !OP_HAS_SIBLING(bairn) /* single-item list */ && PL_opargs[bairn->op_type] & OA_RETSCALAR) { - OP * const ret = op_convert_list(OP_STRINGIFY, 0, + OP * const ret = op_convert_list(OP_STRINGIFY, OPf_FOLDED, op_sibling_splice(o, kid, 1, NULL)); op_free(o); - ret->op_folded = 1; return ret; } } diff --git a/op.h b/op.h index 161c1a5..befdc79 100644 --- a/op.h +++ b/op.h @@ -139,6 +139,10 @@ Deprecated. Use C<GIMME_V> instead. /* On OP_PADRANGE, push @_ */ /* On OP_DUMP, has no label */ /* On OP_UNSTACK, in a C-style for loop */ +/* There is no room in op_flags for this one, so it has its own bit- + field member (op_folded) instead. The flag is only used to tell + op_convert_list to set op_folded. */ +#define OPf_FOLDED 1<<16 /* old names; don't use in new code, but don't break them, either */ #define OPf_LIST OPf_WANT_LIST diff --git a/regen/mk_invlists.pl b/regen/mk_invlists.pl index e0a5024..9dcc8c3 100644 --- a/regen/mk_invlists.pl +++ b/regen/mk_invlists.pl @@ -297,4 +297,16 @@ for my $charset (get_supported_code_pages()) { print $out_fh "\n" . get_conditional_compile_line_end(); } -read_only_bottom_close_and_rename($out_fh, [$0]) +my @sources = ($0, "lib/Unicode/UCD.pm"); +{ + # Depend on mktablesâ own sources. Itâs a shorter list of files than + # those that Unicode::UCD uses. + open my $mktables_list, "lib/unicore/mktables.lst" + or die "$0 cannot open lib/unicore/mktables.lst: $!"; + while(<$mktables_list>) { + last if /===/; + chomp; + push @sources, "lib/unicore/$_" if /^[^#]/; + } +} +read_only_bottom_close_and_rename($out_fh, \@sources) diff --git a/t/op/join.t b/t/op/join.t index 4117d49..17b618e 100644 --- a/t/op/join.t +++ b/t/op/join.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 28; +plan tests => 29; @x = (1, 2, 3); is( join(':',@x), '1:2:3', 'join an array with character'); @@ -124,3 +124,7 @@ package o { use overload q|""| => sub { ${$_[0]}++ } } is $_, "1a2a3a4a5a6a7a8a9a10", 'join, $overloaded, LIST'; is $$o, "b", 'overloading was called once on overloaded separator'; } + +for(1,2) { push @_, \join "x", 1 } +isnt $_[1], $_[0], + 'join(const, const) still returns a new scalar each time'; -- Perl5 Master Repository
