develooper Front page | perl.perl5.porters | Postings from September 2017

[perl #129916] CV symbol table optimization only works in main::

Thread Previous
From:
Father Chrysostomos via RT
Date:
September 21, 2017 16:34
Subject:
[perl #129916] CV symbol table optimization only works in main::
Message ID:
rt-4.0.24-20982-1506011682-491.129916-15-0@perl.org
On Mon, 18 Sep 2017 09:00:58 -0700, atoomic wrote:
> On Mon, 28 Aug 2017 20:33:55 -0700, sprout wrote:
> > On Wed, 19 Oct 2016 07:20:42 -0700, mauke- wrote:
> > >
> > > This is a bug report for perl from l.mai@web.de,
> > > generated with the help of perlbug 1.40 running under perl 5.24.0.
> > >
> > >
> > > -----------------------------------------------------------------
> > > [Please describe your issue here]
> > >
> > > Here's the merge I'm talking about:
> > > http://perl5.git.perl.org/perl.git/commitdiff/f9d9e965
> > >
> > > Also listed in perl5220delta:
> > >
> > > Subroutines in packages no longer need to be stored in typeglobs:
> > > declaring a subroutine will now put a simple sub reference directly
> > > in
> > > the stash if possible, saving memory.
> > >
> > > This works fine for the main script:
> > >
> > > $ perl -wE 'sub foo { 42 } say $main::{foo}'
> > > CODE(0xa06f668)
> > >
> > > But not in other packages:
> > >
> > > $ perl -wE 'package Other; sub foo { 42 } say $Other::{foo}'
> > > *Other::foo
> > >
> > > I.e. this optimization doesn't apply to modules, which is where
> > > most
> > > subroutines come from.
> >
> > Fixing it causes this to fail:
> 
> Could you precise the 'fixing it' part. Where/what is the patch with
> your fix candidate ? is there any commit id / topic branch where we
> could read your attempt to fix it ?

Due to test failures, I had not actually committed it yet.  But now I have.  It is the ‘unfinished’ commit on the sprout/cv-in-stash branch.


> 
> >
> > use Test::More tests => 1;
> >
> > package Other;
> >
> > sub f1 { "f1" }
> > local $Other::{"f1"} = sub { "h1" };
> > ::is(f1(), "h1", "localised sub via stash");
> >
> > Does this matter?  This is pretty obscure code (from t/op/local.t)
> > that should probably be doing local *Other::f1 = sub { "h1" } instead
> > (if it were production code).


-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=129916

Thread Previous


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