develooper Front page | perl.perl5.porters | Postings from February 2023

Re: PERL_RC_STACK branch: first cut

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
February 28, 2023 10:50
Subject:
Re: PERL_RC_STACK branch: first cut
Message ID:
Y/3cXA4ox2i8cvUP@iabyn.com
On Tue, Feb 28, 2023 at 02:03:11AM -0800, Darren Duncan wrote:
> To be completely clear, in a default build, should all known XS also compile
> and run properly without alterations?  Or does the "mostly unchanged"
> exclude some things that XS may be sensitive to?

In a default build, virtually everything is unchanged behaviour-wise. The
main changes are internal to core in some PP functions, where the exact
point where things get pushed on and popped off the stack within the pp
function changes. For example in a highly-simplified version of the
pp_add() function, after expanding most of the macros, the code used to
look a bit like:

    OP*
    Perl_pp_add(pTHX)
    {
        SV* right = *PL_stack_sp--;
        SV*  left = *PL_stack_sp--;
        SV *targ = PAD_SV(PL_op->op_targ));
        sv_setiv(targ, SvIV(left) + SvIV(right));
        *++PL_stack_sp = targ;
    }

while now it expands to something like:

    OP*
    Perl_pp_add(pTHX)
    {
        SV* right = *PL_stack_sp;
        SV*  left = *PL_stack_sp;
        SV *targ = PAD_SV(PL_op->op_targ));
        sv_setiv(targ, SvIV(left) + SvIV(right));
        PL_stack_sp--;
        *PL_stack_sp = targ;
    }

I.e. during the course of execution of pp_add(), things are now not
actually popped off the stack until they are finished with.

On PERL_RC_STACK builds only, for those last couple of lines the macros
and inline functions would instead expand to the equivalent of:

        SvREFCNT_dec(*PL_stack_sp--);
        SvREFCNT_dec(*PL_stack_sp);
        *PL_stack_sp = SvREFCNT_inc(targ);

I would be very surprised if if any XS code could spot the difference on
default builds. But this is perl, and we're constantly being surprised
what breaks from trivial changes in core! On the other hand, even when
built with PERL_RC_STACK, no CPAN module under dist/ or cpan/ needed
fixing or tweaking to run, and Moose and its huge list of dependencies all
installed ok.

But I understand that we are very late in the release cycle, and it
may well be better to wait till after 5.38.


-- 
Red sky at night - gerroff my land!
Red sky at morning - gerroff my land!
    -- old farmers' sayings #14

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About