From: Dirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Cc: guile-devel@gnu.org
Subject: Re: The relationship between SCM and scm_t_bits.
Date: Sat, 15 May 2004 17:00:12 +0200 [thread overview]
Message-ID: <40A6307C.9050809@dirk-herrmanns-seiten.de> (raw)
In-Reply-To: <lj7jvth7o3.fsf@troy.dt.e-technik.uni-dortmund.de>
Marius Vollmer wrote:
> I propose to remove the need to convert between scm_t_bits* and SCM*
> and to allow only SCMs to be in memory.
>
>
> The words in a scm_t_cell would be of type SCM. This would mean that
> SCM_CELL_WORD_LOC would be removed and replaced with
> SCM_CELL_OBJECT_LOC. Also, SCM_SET_SMOB_DATA (etc) might not be able
> to store all scm_t_bits values that it is handed (because scm_t_bits
> could be larger than a pointer). We could make a new guarantee that
> says that SCM_SET_SMOB_DATA (etc) can store any pointer that is cast
> to a scm_t_bits and any integer that fits into 'unsigned int', say.
>
> The type scm_t_bits would be restricted to temporary values that are
> mostly used to test tag bits etc. They would usually not stored in
> data structures and when they are, they can not be expected to
> protected the SCM value that they encode when they are scanned
> conservatively.
>
> Should we (gradually and with deprecation and everyhing) remove
> scm_t_bits from the smob API completely? I have not thought this
> thru, but we might and with something that is not really an
> improvement, just different.
I have tried to give it some more thought:
Since the introduction of scm_t_bits, it has been stated about SCM
variables,
that every SCM variable is known to hold a valid scheme object, while
scm_t_bits
variables may also hold arbitrary data.
On the heap, however, cells do typically _not_ hold valid scheme
objects. One of
the exceptions is the pair object, which has the property, that both of
its cell entries happen to hold valid scheme objects. This is the reason why
SCM_CARLOC and SCM_CDRLOC work on pairs. If you use SCM_CARLOC or
SCM_CDRLOC on anything else than a pair object, you will most likely crash
the system, because the SCM value that you get will not hold a valid scheme
object.
From this perspective, it is inconsistent to define scm_t_cell to hold
SCM objects.
I have not yet given it a try, but I found the suggestion to use a union
quite appaling:
typedef struct scm_t_cell
{
union {
scm_t_bits word_0;
SCM object_0;
} element_0;
union {
scm_t_bits word_1;
SCM object_1;
} element_1;
} scm_t_cell;
or even a more generic version, which would cover single cells as well
as double
cells and even allow to cleanly iterate over all cell elements in a loop:
typedef struct scm_t_cell
{
union {
scm_t_bits word;
SCM object;
} elements[];
} scm_t_cell;
I see no reason why either of the above solutions should have a negative
influence on performance. All of our cell accessing macros should be easily
re-definable with those types, in particular:
#define SCM_GC_CELL_WORD(x, n) (((SCM2PTR (x)) [n]).word)
#define SCM_GC_CELL_OBJECT(x, n) (((SCM2PTR (x)) [n]).object)
which does not require any casting to be performed any more :-)
Best regards,
Dirk Herrmann
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2004-05-15 15:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-03 15:06 The relationship between SCM and scm_t_bits Marius Vollmer
2004-05-03 16:10 ` Marius Vollmer
2004-05-03 16:21 ` Paul Jarc
2004-05-04 13:53 ` Marius Vollmer
2004-05-04 17:16 ` Paul Jarc
2004-05-04 17:49 ` Marius Vollmer
2004-05-04 18:35 ` Paul Jarc
2004-05-05 10:00 ` Marius Vollmer
2004-05-05 14:58 ` Paul Jarc
2004-05-10 13:42 ` Marius Vollmer
2004-05-15 7:31 ` Dirk Herrmann
2004-05-17 18:09 ` Marius Vollmer
2004-05-15 15:00 ` Dirk Herrmann [this message]
2004-05-15 16:42 ` Dirk Herrmann
2004-05-17 19:22 ` Marius Vollmer
2004-05-17 20:17 ` Paul Jarc
2004-05-21 19:37 ` Dirk Herrmann
2004-05-21 20:30 ` Paul Jarc
2004-05-22 6:48 ` Dirk Herrmann
2004-05-23 15:03 ` Paul Jarc
2004-08-09 21:09 ` Marius Vollmer
2004-08-20 19:17 ` Dirk Herrmann
2004-08-21 16:16 ` Marius Vollmer
2004-10-03 9:09 ` Dirk Herrmann
2004-10-04 14:12 ` Marius Vollmer
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=40A6307C.9050809@dirk-herrmanns-seiten.de \
--to=dirk@dirk-herrmanns-seiten.de \
--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).