develooper Front page | perl.perl5.porters | Postings from January 2016

Re: reworked context stack system

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
January 15, 2016 16:35
Subject:
Re: reworked context stack system
Message ID:
20160115163522.GN4007@iabyn.com
On Fri, Jan 15, 2016 at 03:58:05PM +0100, Vincent Pit (VPIT) wrote:
> 
> >For Vincent:
> >
> >My attached Scope::Upper WIP fix addresses two basic changes. First, that
> >context pushes don't push the old PL_savestack_ix onto the scope stack
> >any more, but instead store it as blk_oldsaveix. So saved savestack
> >indexes need adjusting in the context stack as well as the scope stack.
> >Second, pushing a context now usually involves pushing *nothing* on the
> >savestack (not even a SAVETMPS), so you can get a whole series of context
> >stack frames that all share the same blk_oldsaveix. So it makes it
> >difficult to trigger a call to leave_scope() and thus to su_pop() at the
> >right time.
> >
> >My solution to this was, when adjusting the chain of saved
> >PL_savestack_ix's, rather than adjusting each by the fixed size/offset,
> >adjust each so it is greater than the previous, so that leave_scope()
> >is always triggered when needed, and use extra padding if necessary.
> >Convert origin into an array of structs holding the original ix and the
> >offset.
> >When su_pop is called, rather than doing depth--, it assumes multiple
> >scopes may have been popped in one go (for example dounwind() will call
> >LEAVE_SCOPE() for every context popped, but not for any intervening
> >ENTERs). So instead it looks at the current value of PL_savestack_ix,
> >which points to the destructor currently being processed, then pops back
> >entries in origin until it finds one where origin[depth].ix +
> >origin[depth].offset < PL_savestack_ix.
> >
> 
> Thanks for having looked into this.
> 
> What you describe looks very much like a previous iteration of the
> implementation of Scope::Upper : it did seem more natural to flush all the
> empty save stack frames at once when the destructor fired instead of bumping
> all the save stack markers preemptively.

No, my patch explicitly ensures that every saved savestack_ix, after
adjustment is greater than the previous one. Also, my context branch
makes do_unwind call leave_scope() after each context is popped, not just
after sub contexts are popped.

-- 
Spock (or Data) is fired from his high-ranking position for not being able
to understand the most basic nuances of about one in three sentences that
anyone says to him.
    -- Things That Never Happen in "Star Trek" #19

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