From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] trunk r117464: Shrink Lisp_Sub_Char_Table by preferring C integers to Lisp_Objects. Date: Thu, 03 Jul 2014 12:49:44 -0400 Message-ID: References: <53B42194.2040003@yandex.ru> <53B42B2E.7090404@yandex.ru> <53B4D81E.6010904@yandex.ru> <53B57898.6080003@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT X-Trace: ger.gmane.org 1404406214 25508 80.91.229.3 (3 Jul 2014 16:50:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 3 Jul 2014 16:50:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 03 18:50:07 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X2kCy-0005DA-II for ged-emacs-devel@m.gmane.org; Thu, 03 Jul 2014 18:50:04 +0200 Original-Received: from localhost ([::1]:60866 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2kCy-0000Vn-81 for ged-emacs-devel@m.gmane.org; Thu, 03 Jul 2014 12:50:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2kCm-0000VE-S5 for emacs-devel@gnu.org; Thu, 03 Jul 2014 12:50:01 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2kCf-0006nQ-CE for emacs-devel@gnu.org; Thu, 03 Jul 2014 12:49:52 -0400 Original-Received: from relais.videotron.ca ([24.201.245.36]:47112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2kCf-0006nL-7Y for emacs-devel@gnu.org; Thu, 03 Jul 2014 12:49:45 -0400 Original-Received: from ceviche.home ([24.201.170.218]) by VL-VM-MR006.ip.videotron.ca (Oracle Communications Messaging Exchange Server 7u4-22.01 64bit (built Apr 21 2011)) with ESMTP id <0N8500EENAQWOTA0@VL-VM-MR006.ip.videotron.ca> for emacs-devel@gnu.org; Thu, 03 Jul 2014 12:49:44 -0400 (EDT) Original-Received: by ceviche.home (Postfix, from userid 20848) id 49227660FA; Thu, 03 Jul 2014 12:49:44 -0400 (EDT) In-reply-to: <53B57898.6080003@yandex.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 24.201.245.36 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172871 Archived-At: >> But I don't see why that necessarily implies casting >> Lisp_Sub_Char_Table to a Lisp_Vector (I ask this question without >> having spent much time looking for the answer in the source, maybe the >> answer is obvious, but I think if you can tell me why it's a better use >> of my time than trying to figure it out myself). > Hm... look at mark_char_table in alloc.c - this function implies that > both Lisp_Char_Table and Lisp_Sub_Char_Table pointers can be treated > as a pointer to their base type Lisp_Vector. Having both mark_char_table > and mark_sub_char_table looks a bit overengineered for me. This also > applies to Lisp_Char_Table/Lisp_Sub_Char_Table printing code in > print_object, etc. Could you try to use something like the patch below to eliminate this alignment assumption? Stefan === modified file 'src/alloc.c' --- src/alloc.c 2014-07-02 03:26:19 +0000 +++ src/alloc.c 2014-07-03 16:47:25 +0000 @@ -5962,13 +5962,18 @@ { int size = ptr->header.size & PSEUDOVECTOR_SIZE_MASK; /* Consult the Lisp_Sub_Char_Table layout before changing this. */ - int i, idx = (pvectype == PVEC_SUB_CHAR_TABLE ? SUB_CHAR_TABLE_OFFSET : 0); + int i; + Lisp_Object *contents + = pvectype == PVEC_SUB_CHAR_TABLE + ? (size -= SUB_CHAR_TABLE_OFFSET, + ((struct Lisp_Sub_Char_Table *)ptr)->contents) + : ((struct Lisp_Char_Table *)ptr)->contents; eassert (!VECTOR_MARKED_P (ptr)); VECTOR_MARK (ptr); - for (i = idx; i < size; i++) + for (i = 0; i < size; i++) { - Lisp_Object val = ptr->contents[i]; + Lisp_Object val = contents[i]; if (INTEGERP (val) || (SYMBOLP (val) && XSYMBOL (val)->gcmarkbit)) continue;