develooper Front page | perl.perl5.porters | Postings from December 2013

Re: An article on writing Perl extensions without XS

Thread Previous | Thread Next
From:
Christian Walde
Date:
December 17, 2013 13:51
Subject:
Re: An article on writing Perl extensions without XS
Message ID:
op.w78or5nzydyjqt@digitizedsqueak
On Tue, 17 Dec 2013 13:02:19 +0100, Zefram <zefram@fysh.org> wrote:

> Christian Walde wrote:
>> I do think that, instead of forcing people to do `sp -= items;` just
>> to be able to iterate forwards through arguments with ++, someone
>> would probably have instead just made a macro that points to the
>> start of the arguments in the stack.
>
> This is one of the things that arises from efficiency concerns.
> You could replace sp[3] (used after sp-=items) with sp[3-items] (with no
> decrement of sp), but it's a more complex expression, which depending
> on CPU architecture may take longer to execute.  (It'll be the same on
> current x86 CPUs.)  The decrement also gets you into the right place to
> start pushing return values.  Decrementing sp is part of the stereotyped
> variable use that you'd likely reinvent, at least for variadic xsubs.

After explaining in #p5p that outputs need to replace the inputs on the  
stack, this all makes a lot more sense.

Steffen, you probably want to mention this fact early on in your article  
so the rest is more self-explanatory. :)

-- 
With regards,
Christian Walde

Thread Previous | 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