develooper Front page | perl.perl5.porters | Postings from November 2010

Re: entersub target

Thread Previous
From:
Nicholas Clark
Date:
November 1, 2010 07:15
Subject:
Re: entersub target
Message ID:
20101101141506.GT24189@plum.flirble.org
On Sun, Oct 24, 2010 at 02:26:31AM +0100, Ben Morrow wrote:
> Quoth zefram@fysh.org (Zefram):
> > OP_ENTERSUB is marked (in opcode.pl) as "needs a target".  It appears,
> > on inspection, that neither pp_entersub nor ck_subr make any use of the
> > target slot.  What's going on?

This I didn't know:

> pp_entersub calls AMAGIC, and at least some of the AMAGIC stuff uses
> TARG. Is that the source? AFAICT the macros used currently *don't* use
> TARG, but it's rather hard to follow, and it's possible this has changed
> and noone realised.

but I think it's worth chasing down.

I know that there's this:

#define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
			     ? PAD_SV(PL_op->op_targ) : sv_newmortal())

so it looks like it's intended as an optimisation for XSUBs. However

1: most XSUB macros don't use this anyway
2: it's a "bit" wasteful to have every sub call point allocate* a temporary on
   the assumption that the called subroutine is XS


so I'm wondering if we can remove this, without actually breaking *anything*,
for some sort of a (net) speedup.

Nicholas Clark

* I'm right that this is something allocated in the pad?

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