From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Re: Imporved cons representatoin in guile
Date: Fri, 10 Jul 2015 13:37:53 +0200 [thread overview]
Message-ID: <CAGua6m21Y+nueibaT-zhmwGwkaPdQw13fuZ=DZLotuMcyCEMcw@mail.gmail.com> (raw)
In-Reply-To: <CAGua6m3yb8Z8OeLeHbnEHURE64C3+MJ0Onn03rGZHaMce2hoeg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]
I managed to push the send button prematurey,
Here is the code i think that would be needed
SCM SCM_CAR(SCM x)
SCM *pt = GET_REFERENCE(x)
scm_t_bits val = SCM_UNPACK(*pt) & SCM/2; (Mask out the first half)
if(1 & val == 0) //THIN
{
if(val & 6 == 0) //non emediate e.g. a pointer
{
int64 delta = promote_signed_ptr(val);
return UNREF(pt + delta);
}
if(val & 2 == 1) // integer
{
SCM_PACK(return promote_signed(val))
}
return SCM_PACK(val)
}
fat version of SCM comes here.
To note is that indeed we do get a more complex code here. But on the other
hand the extra logic is bit twiggelin and compiled using the cpu registers
only at most
a SCM_CAR will take twice the time. A SCM_CDR on the other hand need to
take in two SCM and is probably as fast or faster.
On Fri, Jul 10, 2015 at 1:20 PM, Stefan Israelsson Tampe <
stefan.itampe@gmail.com> wrote:
> Hi,
>
> I was complentating the cons cells in guile an was wondering if we could
> pack our cons cells better than today. So this is some notes about this.
>
> Currently if x is a cons cell we have the relation
> x -> [SCMCAR,SCMCDR]
>
> This is really neat and makes guiles conses quite compact e.g. a vector y
> of two elements is
> y -> [SCMTAG,SCMV1,SCMV2], where SCMTAG containes the datatype tag and
> length of the
> vector.
>
> To compress even further we need a way to could use
> x ->[SCM/2/SCM/2], witt SCM/2 the same tagging half the size as the normal
> SCM with the interpretation that if
> SCM/2 is a non emediate then it starts with 00 and is then interpreted as
> a signed integer i and the real adress is x + i, e.g. a relative adress
> regarding.
>
> We of cause must also add a fat cons cell of the form
> x -> [Tag,X,Y] for the case when SCM/2 is not fitting. Currently I can't
> see this beeing common. But
> if we later makes floating point represented via nan boxing e.g. stored
> directly in a 64bit value then
> the cons cell will be mostly fat and there would be a speed reduction
> using cons cells. On the other hand there has been a considerable speed.
>
> There is a final sematic case that needs to be fixed. if we do a setcar on
> a thin cons cell and the cell
> then becomes fat, we need to create the following
>
> x -> oldthin -> newfat
>
> e.g. we need to add a pointer type with the meaning of automatically
> follow the pointer if we encounter it. then oldthin is also tagging a
> variant of a cons cell. It is possible to keep it slim
> in the code that all fat cons cells is represented like that.
>
> How would a SCM_CAR be like?
>
> SCM SCM_CAR(SCM x)
> if(THIN(x))
> {
>
> }
>
>
>
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 4725 bytes --]
next prev parent reply other threads:[~2015-07-10 11:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 11:20 Imporved cons representatoin in guile Stefan Israelsson Tampe
2015-07-10 11:37 ` Stefan Israelsson Tampe [this message]
2015-07-10 17:31 ` Stefan Monnier
2015-07-14 13:18 ` Stefan Israelsson Tampe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGua6m21Y+nueibaT-zhmwGwkaPdQw13fuZ=DZLotuMcyCEMcw@mail.gmail.com' \
--to=stefan.itampe@gmail.com \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).