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

Re: optimising opcodes

Thread Previous | Thread Next
Paul Johnson
January 1, 2008 18:20
Re: optimising opcodes
Message ID:
On Mon, Dec 31, 2007 at 10:46:20AM +0000, Nicholas Clark wrote:
> On Mon, Dec 31, 2007 at 10:15:53AM +0100, Rafael Garcia-Suarez wrote:

> > Are we sure we don't use null ops at all ? an idea just crossed my mind:
> > some COPs can be nullified, (try with an if() statement for example),
> > but does the runtime still fetch a line number in it to add it to a
> > warning or an error message ?
> Paul Johnson seemed to think so:

I'm pretty sure I wrote the code which does it: closest_cop() in
util.c.  It seems that null ops which used to be nextstate are the
interesting ones.

I use the same trick in Devel::Cover to try and get the coverage more
accurately associated with the relevant line.

> On Wed, Dec 26, 2007 at 11:11:06AM +0100, Paul Johnson wrote:
> > Note that doing this would reduce the accuracy of some error messages.
> > In particular, we can get some line number information from nullops, and
> > whilst nothing would /break/ if the nullops weren't there (in this
> > sense), some line numbers would be reported incorrectly.
> > 
> > Unless that information could be copied somehow as the nullops were
> > removed.  This fits in with a discussion we were having previously about
> > including line numbers (and filenames) in more ops.
> However, with pointer games, I think it would be possible to add line number
> information to any op type. (By storing it before the op structure, and having
> a flag bit in the op to mean "by the way there is a line number structure
> before me in memory"). It would be the same sort of pointer arithmetic we're
> already using to avoid allocating NVs for the SV types RV, PV and PVIV.

That's an interesting idea.  And there are currently three spare bits so
it is feasible.

I wonder whether it might be worth making cop_file something a little
more clever than a char *.

Paul Johnson -

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