Branch: refs/heads/yves/cop_file_rcpv
  Home:   https://github.com/Perl/perl5
  Commit: cbc4a6ff3cc1aabaade32945338306ac8ed6a2c4
      
https://github.com/Perl/perl5/commit/cbc4a6ff3cc1aabaade32945338306ac8ed6a2c4
  Author: Yves Orton <demer...@gmail.com>
  Date:   2022-11-01 (Tue, 01 Nov 2022)

  Changed paths:
    M cop.h
    M embed.fnc
    M embed.h
    M ext/B/B.pm
    M ext/B/B.xs
    M gv.c
    M op.c
    M op.h
    M perl.c
    M proto.h
    M scope.c
    M scope.h
    M sv.c

  Log Message:
  -----------
  cop.h - add support for refcounted filenames in cops under threads

We have a weird bifurcation of the cop logic around threads. With
threads we use a char * cop_file member, without it we use a GV * and
replace cop_file with cop_filegv.

The GV * code refcounts filenames and more or less efficiently shares
the filename amongst many opcodes. However under threads we were
simplify copying the filenames into each opcode. This is because in
theory opcodes created in one thread can be destroyed in another. I say
in theory because as far as I know the core code does not actually do
this. But we have tests that you can construct a perl, clone it, and
then destroy the original, and have the copy work just fine, this means
that opcodes constructed in the main thread will be destroyed in the
cloned thread. This in turn means that you can't put SV derived
structures into the op-tree under threads. Which is why we can not use
the GV * stategy under threads.

As such this code adds a new struct/type RCPV, which is a refcounted
string using shared memory. This is implemented in such a way that code
that previously used a char * can continue to do so, as the refcounting
data is located a specific offset before the char * pointer itself.
This also allows the len data to embedded "into" the PV, which allows
us to expose macros to acces the length of what is in theory a null
terminated string.

    struct rcpv {
        UV      refcount;
        STRLEN  len;
        char    pv[1];
    };
    typedef struct rcpv RCPV;

The struct is sized appropriately on creation in rcpv_new() so that the
pv member contains the full string plus a null byte. It then returns a
pointer to the pv member of the struct. Thus the refcount and length and
embedded at a predictable offset in front of the char *, which means we
do not have to change any types for members using this.

We provide three operations: rcpv_new(), rcpv_copy() and rcpv_free(),
which roughly correspond with newSVpv(), SvREFCNT_inc(), SvREFCNT_dec(),
and a handful of macros as well. We also expose SAVERCPVFREE which is
similar to SAVEGENERICSV but operates on pv's constructed with
rcpv_new().

Currently I have not restricted use of this logic to threaded perls. We
simply do not use it in unthreaded perls, but I see no reason we
couldn't normalize the code to use this in both cases, except possibly
that actually the GV case is more efficient.

Note that rcpv_new() does NOT use a hash table to dedup strings. Two
calls to rcpv_new() with the same arguments will produce two distinct
pointers with their own refcount data.

Refcounting the cop_file data was Tony Cook's idea.


  Commit: 34ad7dfcd463b508c65a4c5b87496237a7647f35
      
https://github.com/Perl/perl5/commit/34ad7dfcd463b508c65a4c5b87496237a7647f35
  Author: Yves Orton <demer...@gmail.com>
  Date:   2022-11-01 (Tue, 01 Nov 2022)

  Changed paths:
    M MANIFEST
    M scope.c
    M scope.h
    A scope_types.h

  Log Message:
  -----------
  scope_types.h - new header file for scope type data

Next patch this data will be autogenerated.


  Commit: d610a4c85c81319954504ec894e9f529e899f45e
      
https://github.com/Perl/perl5/commit/d610a4c85c81319954504ec894e9f529e899f45e
  Author: Yves Orton <demer...@gmail.com>
  Date:   2022-11-01 (Tue, 01 Nov 2022)

  Changed paths:
    M MANIFEST
    M regen.pl
    A regen/scope_types.pl
    M scope_types.h
    M t/porting/regen.t

  Log Message:
  -----------
  regen/scope_types.pl - add tool to manage the scope type defines

In scope.c and scope.h there are various defines that must be coordinated
with the contents of an array, and comments and ids which might have to be
mass changed manually in some circumstances. As this is error prone this
patch adds a new regen script to ensure it is kept in sync and to make the
process of adding new types trivial. The data that drives the script is
kept in the scripts __DATA__ section.


  Commit: 8fafc71922000d89bd2e05f2a9f6817b7d64af09
      
https://github.com/Perl/perl5/commit/8fafc71922000d89bd2e05f2a9f6817b7d64af09
  Author: Yves Orton <demer...@gmail.com>
  Date:   2022-11-01 (Tue, 01 Nov 2022)

  Changed paths:
    M cop.h
    M mg.c
    M op.c
    M perl.c
    M regen/warnings.pl
    M util.c
    M warnings.h

  Log Message:
  -----------
  op.c - use refcounted pv pointers for cop_warnings

this allows multiple ops to share the same underlying
warning bit vector. the vectors are not deduped, however
they are efficiently copied and shared.


Compare: https://github.com/Perl/perl5/compare/8049a8f94aa9...8fafc7192200

Reply via email to