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

curious comment in pp_entersub

Thread Next
Nicholas Clark
January 30, 2010 08:08
curious comment in pp_entersub
Message ID:
pp_entersub contains this code:

	    AV *const av = MUTABLE_AV(PAD_SVl(0));
	    if (AvREAL(av)) {
		/* @_ is normally not REAL--this should only ever
		 * happen when DB::sub() calls things that modify @_ */
	    cx->blk_sub.savearray = GvAV(PL_defgv);
	    GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
	    cx->blk_sub.argarray = av;

I don't believe that that comment is accurate. Yes, &DB::sub is passed @_ from
this subroutine call, but &DB::sub is called in place of the real subroutine,
and if it wants to pass control on to the real subroutine, it has to make a
regular call to it. (Or goto &$DB::sub, but I don't think that anything chooses
to do that)

But a regular call to another subroutine either means that the contents of
&DB::sub's @_ is placed onto the stack (in which case PAD_SVl(0) for *this*
subroutine wasn't even made available to &DB::sub, or & notation is used, in
which case &DB::sub's @_ is passed directly onwards, and that branch of the
code isn't entered.

The code was originally from 5.000 (a0d0e21ea6ea90a22318550944fe6cb09ae10cda)
but this path was removed by Sarathy in d8b46c1bb1e2856c on 19th Sep, 1999
and re-added with the comment in 221373f040d37efa on 16th Oct, 1999

Given that between 19th Sep and 16th Oct Sarathy had an assertion in place


I'm wondering if something somehow caused the assertion to fail, but I can't
work out what, short of XS code performing direct manipulation of $DB::sub's

I ask, partly because I like to know why things are the way they are, and
partly because this looks like a little bit of dead code in pp_entersub.

Nicholas Clark

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About