-
Notifications
You must be signed in to change notification settings - Fork 587
Description
Description
(Mentioned somewhere recently, I think by @bulk88, but I couldn't locate it just now.)
POK CONST OPs that happen to have the same string content will each have their own IsCOW
buffer.
For example, when the following is compiled, there will be three distinct allocations containing the word "perl
", each attached to a separate CONST OP's SV:
sub consts {
my $x = "perl";
if ($_[0] eq "perl") {
say "perl"
}
}
Having just one allocation for "perl
" rather than three would seem nice. Is there a fundamental reason for the current implementation, or does it just predate the shared string table and COW mechanisms?
If it's just a case of tuits, what would the next steps be, and should the approach be shared strings in PL_strtab
or something else that results in a shared buffers for such CONST OPs?
Note: toke.c produces OP_CONST
OPs via multiple different, non-identical paths. Any sharing implementation might best be implemented as:
- A proof-of-concept in
Perl_ck_svconst
that takes the OP's SVs as currently built and consolidates them.
Possibly in a later dev cycle:
- Amend the multiple
OP_CONST
construction sites in toke.c such that the sharing happens earlier and more efficiently.
Perl configuration
Blead and previous.