develooper Front page | perl.perl5.porters | Postings from October 2000

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous
From:
Simon Cozens
Date:
October 5, 2000 05:34
Subject:
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
20001005132932.C6419@the.earth.li
On Thu, Oct 05, 2000 at 07:26:38AM -0500, Jarkko Hietaniemi wrote:
> Yup, seems like it becomes an NV.  Grr.  It must be using
> some other routine than is being used in parse time since

At run-time, it doesn't use *any* routine. That's what I was complaining
about, roughly. You come into pp_add with two SVs. Let's say you're doing

    $a = "123foo"; $b = 3;

then our SVs, sitting on the top of the stack, would look like:

SV = IV(0x80fdc24) at 0x80fcf28
  REFCNT = 1
  FLAGS = (IOK,pIOK)
  IV = 3

and

SV = PV(0x80f31c4) at 0x80fcf30
  REFCNT = 1
  FLAGS = (POK,pPOK)
  PV = 0x8101b40 "123foo"\0
  CUR = 6
  LEN = 7

Now look what happens to the stack:


PP(pp_add)
{
    djSP; dATARGET; tryAMAGICbin(add,opASSIGN);
    {
      dPOPTOPnnrl_ul;

Here, two NVs are popped off; so Perl calls SvNV on the two topmost
SVs, whatever they are, which will convert them into NVs, whether we
want it or not.

      SETn( left + right );

Then the NVs are added and the sum is put back on the top.

-- 
A list is only as strong as its weakest link.
		-- Don Knuth

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