[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3
From: |
Ludovic Courtès |
Subject: |
Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3 |
Date: |
Tue, 11 Jun 2019 10:39:38 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Hello,
Mark H Weaver <address@hidden> skribis:
> Ludovic Courtès <address@hidden> writes:
[...]
>> IIUC, your plan is to have a different tagging on 32-bit platforms,
>> without fixflos, right? I’m curious to see how much complexity would
>> entail from that.
>
> Yes, although I'm avoiding the term "fixflos" because IEEE doubles are
> also fixed width, and thus the term "fixflos" wouldn't adequately
> distinguish them from IEEE doubles.
Right!
> Anyway, I agree that it's inconvenient to have different tags on
> different targets, and I've been working to minimize the differences.
>
> At present, I'm currently implementing an alternative strategy where
> pairs are tagged in their pointers instead of in their CARs, which
> enables us to separate the heap tags and immediate tags into two
> independent spaces.
At first this sounds rather radical :-), but maybe it’s preferable this
way.
> In this new approach, the heap tags are left unchanged, and the only
> tags that vary with target word size are the fixints, fixrats, iflos,
> and pair pointers. All other tags will be uniform across targets,
> including the non-number immediates. Here's the new version:
>
> ;; /* with iflos: xxx: iflo (000 < xxx < 110)
> ;; (64-bit) 0111: fixrat
> ;; 1111: fixnum
> ;; 0110: pair
> ;; 000: tagged heap object (thob)
> ;; tttt1110: other immediate
> ;;
> ;; without iflos: 1: fixnum
> ;; (32-bit) 010: fixrat
> ;; 100: pair
> ;; 000: tagged heap object (thob)
> ;; tttt1110: other immediate
>
> This new approach brings its own complications, mainly two:
>
> (1) It breaks the long-standing assumptions in Guile that all
> non-immediates have a tag in their first word and that pointers are
> always untagged. In my preliminary patch, I introduce a new concept
> called a "tagged heap object" or "thob", and most existing checks
> for SCM_NIMP or !SCM_IMP must be changed to use SCM_THOB_P.
Though an immediate, like a fixnum or an iflo, is still something
different from a tagged heap object like a pair, right? So I would
expect SCM_THOB_P to be a different test, not a drop-in replacement for
SCM_NIMP, is that correct?
> (2) Our existing VM instructions almost invariably specify offsets with
> a granularity of whole words. To support tagged pair pointers with
> good performance, I think we need a few new instructions that
> specify byte offsets, to avoid the expensive extra step of removing
> the tag before accessing the CAR or CDR of a pair.
So instead of a pointer dereference, SCM_CAR becomes mask + dereference,
right?
I think we disable GC “interior pointer” scanning. With this scheme, an
SCM for a pair would actually point in the middle of a pair; could this
be an issue for GC?
Thank you!
Ludo’.
Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3, Mark H Weaver, 2019/06/07