unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <jwvmwcq9yog.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <53B57898.6080003@yandex.ru>

>> 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;




  reply	other threads:[~2014-07-03 16:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1X2BBz-0000lE-Hh@vcs.savannah.gnu.org>
2014-07-02 14:30 ` [Emacs-diffs] trunk r117464: Shrink Lisp_Sub_Char_Table by preferring C integers to Lisp_Objects Stefan Monnier
2014-07-02 15:13   ` Dmitry Antipov
2014-07-02 15:42     ` Stefan Monnier
2014-07-02 15:54       ` Dmitry Antipov
2014-07-02 18:27         ` Stefan Monnier
2014-07-03  4:12           ` Dmitry Antipov
2014-07-03  5:01             ` Stephen J. Turnbull
2014-07-03 14:55               ` Eli Zaretskii
2014-07-03 16:12                 ` Dmitry Antipov
2014-07-03 16:37                   ` Nano-improvements " Eli Zaretskii
2014-07-03 13:57             ` [Emacs-diffs] trunk r117464: Shrink Lisp_Sub_Char_Table by preferring " Stefan Monnier
2014-07-03 15:36               ` Dmitry Antipov
2014-07-03 16:49                 ` Stefan Monnier [this message]
2014-07-03 17:01                   ` Dmitry Antipov
2014-07-03 19:52                     ` Stefan Monnier
2014-07-03 14:53             ` Nano-improvements (was: [Emacs-diffs] trunk r117464: Shrink Lisp_Sub_Char_Table by preferring C integers to Lisp_Objects.) Eli Zaretskii
2014-07-03 15:58               ` Nano-improvements Dmitry Antipov
2014-07-03 16:10                 ` Nano-improvements Eli Zaretskii

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=jwvmwcq9yog.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-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.
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).