From: Stefan Monnier <monnier@IRO.UMontreal.CA>
Subject: Alignment of Lisp_Subr
Date: 12 Nov 2003 11:22:33 -0500 [thread overview]
Message-ID: <jwv8ymld1jm.fsf-monnier+emacs/devel@vor.iro.umontreal.ca> (raw)
So I have finally gotten around to move my tags from the top 3 to the
bottom 3 bits of a Lisp_Object so that Lisp_Objects can now be allocated
anywhere.
Here are the problems I'm facing (all of them due to the new constraint
that objects need to be aligned on 8 byte boundaries) and I'm wondering what
is the best solution for them:
- Lisp_Misc has currently a size that is not a multiple of 8.
I solved that by adding some padding with
/* A miscellaneous object, when it's on the free list. */
struct Lisp_Free
{
int type : 16; /* = Lisp_Misc_Free */
unsigned gcmarkbit : 1;
int spacer : 15;
union Lisp_Misc *chain;
#ifdef USE_LSB_TAG
/* Try to make sure that sizeof(Lisp_Misc) is a multiple of 8.
This assumes that Lisp_Marker is the largest of the alternatives. */
char padding[8 * ((sizeof (struct Lisp_Marker) - 1) / 8 + 1)
- sizeof (struct Lisp_Intfwd)];
#endif
};
I think this solution is acceptable since it only increases the size
of Lisp_Misc objects from 5 words to 6 words (i.e. by 20%) on typical
32bit machines. Maybe we could reduce this cost by making use of this
extra word, although I'm not sure how.
- Structures of type Lisp_Subr are statically allocated and are not
guaranteed to be aligned on a multiple of 8. I currently solve this
by adding __attributes__ ((__aligned__ (8))), but this only works for GCC
AFAIK. The only alternative I can think of is to add a padding field
to Lisp_Subr and when its address is not a multiple of 8, memmove it
by a few bytes (I think `defsubr' is the only place where we refer
to these statically allocated Sfoo variables).
Any comment on which approach is preferable ?
- malloc does not guarantee on all systems that the returned value
will be a multiple of 8 (or does it?). How can I check it so as
to automatically determine whether I can set USE_LSB_TAG (i.e. in
`configure'). Is a heuristic check of calling malloc a few times
with a few different odd sizes sufficient?
Stefan
next reply other threads:[~2003-11-12 16:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-12 16:22 Stefan Monnier [this message]
2003-11-12 23:30 ` Alignment of Lisp_Subr Miles Bader
2003-11-13 16:18 ` Stephen J. Turnbull
2003-11-14 5:23 ` Gaute B Strokkenes
2003-11-14 11:28 ` Stephen J. Turnbull
2003-11-16 10:25 ` Gaute B Strokkenes
2003-11-13 2:40 ` Richard Stallman
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/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv8ymld1jm.fsf-monnier+emacs/devel@vor.iro.umontreal.ca \
--to=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).