From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: tags in the 3 lowest bits Date: 20 Nov 2003 01:28:56 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1069285130 21900 80.91.224.253 (19 Nov 2003 23:38:50 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 19 Nov 2003 23:38:50 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Nov 20 00:38:45 2003 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AMbuH-0006Cv-00 for ; Thu, 20 Nov 2003 00:38:45 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AMbuH-00039x-00 for ; Thu, 20 Nov 2003 00:38:45 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AMcmM-0006zE-F8 for emacs-devel@quimby.gnus.org; Wed, 19 Nov 2003 19:34:38 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AMclL-0006ra-FZ for emacs-devel@gnu.org; Wed, 19 Nov 2003 19:33:35 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AMckm-0006i9-FQ for emacs-devel@gnu.org; Wed, 19 Nov 2003 19:33:31 -0500 Original-Received: from [193.162.153.4] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AMciX-00069d-3z for emacs-devel@gnu.org; Wed, 19 Nov 2003 19:30:41 -0500 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id E22B42629D0; Thu, 20 Nov 2003 00:29:10 +0100 (CET) Original-To: Stefan Monnier In-Reply-To: Original-Lines: 119 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:17933 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:17933 Stefan Monnier writes: > Here is my proposed patch which adds a new macro USE_LSB_TAG: > if the macro is undefined, we behave as before, otherwise we > use the lowest 3 bits of words for tags. So the intention is to continue using MSB tags by default, and only use LSB on those systems which really need it (eg. FreeBSD) ? 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. Or are there systems which cannot use LSB? > > Additionally to the above patch we will need to #define USE_LSB_TAG > when appropriate: it seems that we'll have to put it into the > [sm]/*.h files. > > Any objection to my installing this patch ? > > > Stefan > > > PS: The point of putting the tag in the LSB is that we can then use > the whole address space, which can be important on some systems > such as FreeBSD. > > > Index: lread.c > =================================================================== > RCS file: /cvsroot/emacs/emacs/src/lread.c,v > retrieving revision 1.318 > diff -u -r1.318 lread.c > --- lread.c 1 Sep 2003 15:45:56 -0000 1.318 > +++ lread.c 19 Nov 2003 19:09:00 -0000 > @@ -3407,6 +3407,16 @@ > struct Lisp_Subr *sname; > { > Lisp_Object sym; > +#ifdef USE_LSB_TAG > + /* Make sure the object has multiple-of-8 alignment. */ > + if (XTYPE (sname) != 0) Clever :-) > + { > + struct Lisp_Subr *old_sname = sname; > + sname = (struct Lisp_Subr *) (4 + (char*) sname); > + memmove (sname, old_sname, sizeof (*sname) - 4); I suggest using sizeof(sname->padding) rather than constant 4 here. Or even better, use the actual "mis-offset", as this will work even if we increase GCTYPEBITS later (also see below): ((1 << GCTYPEBITS) - (int)XTYPE (sname)) > @@ -752,6 +772,13 @@ > char *symbol_name; > char *prompt; > char *doc; > +#ifdef USE_LSB_TAG > + /* Lisp_Subrs are statically allocated, so we cannot rely on malloc > + giving us a multiple-of-8 alignment. Instead, we assume that we > + get a multiple-of-4 alignment, and we memmove the object by 4 bytes > + if needed. The memmove is in lread.c:defsubr. */ > + char padding[4]; Suppose we later increase GCTYPEBITS, this is more correct: char padding[(1 << GCTYPEBITS) - 4]; > +#endif > }; > > > @@ -1150,6 +1177,13 @@ > 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 and > + that Lisp_Intfwd has the same size as Lisp_Free without padding. */ > + char padding[8 * ((sizeof (struct Lisp_Marker) - 1) / 8 + 1) > + - sizeof (struct Lisp_Intfwd)]; I would prefer if this was also expressed in terms of GCTYPEBITS. > + && offset < (STRING_BLOCK_SIZE * sizeof b->strings[0]) Why not offset < sizeof b->strings ? > + && offset < (SYMBOL_BLOCK_SIZE * sizeof b->symbols[0]) Why not offset < sizeof b->symbols ? > + && offset < (MARKER_BLOCK_SIZE * sizeof b->markers[0]) Ditto > +#ifdef USE_LSB_TAG > + /* Ensure a minimum of 3 bits for tags. */ > + size_t alignment = max (8, sizeof (EMACS_INT)); I suggest: /* Ensure a minimum of GCTYPEBITS bits for tags. */ size_t alignment = max ((1 << GCTYPEBITS), sizeof (EMACS_INT)); -- Kim F. Storm http://www.cua.dk