[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tags in the 3 lowest bits
From: |
Kim F. Storm |
Subject: |
Re: tags in the 3 lowest bits |
Date: |
20 Nov 2003 11:21:52 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
Stefan Monnier <address@hidden> writes:
> > The only reason I can see for this is that there is a small
> > performance penalty on XFASTINT with LSB -- but I'd prefer that
> > penalty rather than having to support two different methods.
>
> I doubt the performance penalty is an issue. After all, manipulating MSB
> is generally slightly more costly than LSB, so the performance impact might
> even be positive. But I expect it's a wash.
Once LSB is in place, I would like us to get rid of XFASTINT
all-together. It's a potential danger lurking to hit us.
>
> > Or are there systems which cannot use LSB?
>
> The LSB code needs pointers values that are multiples of 8.
> On some systems, malloc does not guarantee it. Probably we can use
> gmalloc.c for those systems, but we'll need to make sure that's an option
> and we'll need to figure out when that's nmecessary.
We could wrap malloc and free on such systems to force 8 byte alignment like
this (it's a little costly in memory, but no big deal):
char *malloc_wrap(size_t len)
{
char *p = malloc(len + 16);
char *p1 = p;
p = (char *)((unsigned)(p + 15) & ~0x7);
*(char **)(p - 8) = p1;
return p;
}
char free_wrap(char *p)
{
free(*(char **)(p - 8));
}
> Also, there might be
> systems that are word-addressed rather than byte-addressed. I don't know
> if such systems are still in use and whether Emacs runs on them, but if
> yes, we'll probably need to find some other way to deal with them,
> maybe keeping the old behavior.
>
> I also hope we can switch to LSB everywhere, but I don't think we can
> do that right now.
>
> I suggest to start with something like along the lines of
>
> #if defined GLIBC || defined GNU_MALLOC
> #define USE_LSB_TAG
> #endif
That's a good starting point, yes.
Or we could use the above trick like this:
#if !(defined GLIBC || defined GNU_MALLOC)
#define malloc malloc_wrap
#define free free_wrap
#endif
--
Kim F. Storm <address@hidden> http://www.cua.dk
- tags in the 3 lowest bits, Stefan Monnier, 2003/11/19
- Re: tags in the 3 lowest bits, Kim F. Storm, 2003/11/19
- Re: tags in the 3 lowest bits, Stefan Monnier, 2003/11/20
- Re: tags in the 3 lowest bits, Stefan Monnier, 2003/11/21
- Re: tags in the 3 lowest bits, Kim F. Storm, 2003/11/21
- Re: tags in the 3 lowest bits, David Kastrup, 2003/11/21
- Re: tags in the 3 lowest bits, Kim F. Storm, 2003/11/21
- Re: tags in the 3 lowest bits, Stefan Monnier, 2003/11/23