chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Reduce silly & needless scratch space allo


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Reduce silly & needless scratch space allocation when reading numbers
Date: Fri, 10 Mar 2017 08:35:13 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On Fri, Mar 10, 2017 at 02:37:13PM +1300, Evan Hanson wrote:
> > @@ -1815,7 +1815,7 @@ EOF
> > -                       ("C_s_a_i_digits_to_integer" 2)
> > +                       ("C_s_a_i_digits_to_integer" 5)
> 
> I'm probably missing something, but if I understand correctly, you're
> adding special cases for allocation sizes <= 2, so shouldn't the
> ##inline#allocate size be bumped by two to 4, rather than by three to 5?

It looks like you forgot about the header of the bignum vector.

The calculations are a little bit wonky, but I'll try to explain just so
it's completely clear to everyone:

A bignum consists of a "wrapper" object plus an internal bignum vector.
The wrapper object is basically just a pointer with a BIGNUM_TYPE header,
so this takes up 2 words.  In the old situation, that's all we needed
because the bignum vector itself (the pointer's target) was always
allocated in the scratch space.

Now that we're allocating in the nursery, we need to add the size that
an internal bignum vector of 2 limbs takes up.  This is exactly the same
calculation as any Scheme vector: 1 word for the header plus one word
per slot.  So for 2 "slots" (limbs), we end up at 3.  If we add the
wrapper object, we get 2+3=5 words.

Cheers,
Peter

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]