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

curious comment in pp_entersub

Thread Next
From:
Nicholas Clark
Date:
January 30, 2010 08:08
Subject:
curious comment in pp_entersub
Message ID:
20100130160813.GC14940@plum.flirble.org
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 @_ */
		av_clear(av);
		AvREAL_off(av);
		AvREIFY_on(av);
	    }
	    cx->blk_sub.savearray = GvAV(PL_defgv);
	    GvAV(PL_defgv) = MUTABLE_AV(SvREFCNT_inc_simple(av));
	    CX_CURPAD_SAVE(cx->blk_sub);
	    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

    assert(!AvREAL(av));

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
pad.

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


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