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

Re: pp_add -> pp_i_add efficiency hack?

Thread Previous
Simon Cozens
October 5, 2000 05:34
Re: pp_add -> pp_i_add efficiency hack?
Message ID:
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
  IV = 3


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

Now look what happens to the stack:

    djSP; dATARGET; tryAMAGICbin(add,opASSIGN);

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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About