emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 0dd19ac: Undo port to hypothetical nonzero Qnil cas


From: Paul Eggert
Subject: [Emacs-diffs] master 0dd19ac: Undo port to hypothetical nonzero Qnil case
Date: Tue, 20 Jan 2015 21:56:54 +0000

branch: master
commit 0dd19ac82662c5710e73852f438fd55e1d9225b7
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Undo port to hypothetical nonzero Qnil case
    
    This mostly undoes the previous change in this area.  See:
    http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00570.html
    * alloc.c (allocate_pseudovector):
    * callint.c (Fcall_interactively):
    * dispnew.c (realloc_glyph_pool):
    * fringe.c (init_fringe):
    * lisp.h (memsetnil):
    * xdisp.c (init_iterator):
    Simplify by assuming that Qnil is zero, but verify the assumption.
    * lisp.h (NIL_IS_ZERO): Revert back to this symbol, removing
    NIL_IS_NONZERO.  All uses changed.
---
 src/ChangeLog |   15 +++++++++++++++
 src/alloc.c   |    5 ++---
 src/callint.c |    3 +--
 src/dispnew.c |   13 ++++++-------
 src/fringe.c  |    3 +--
 src/lisp.h    |   14 +++++---------
 src/xdisp.c   |   15 +++++----------
 7 files changed, 35 insertions(+), 33 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index a320e22..e5e4fe9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2015-01-20  Paul Eggert  <address@hidden>
+
+       Undo port to hypothetical nonzero Qnil case
+       This mostly undoes the previous change in this area.  See:
+       http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00570.html
+       * alloc.c (allocate_pseudovector):
+       * callint.c (Fcall_interactively):
+       * dispnew.c (realloc_glyph_pool):
+       * fringe.c (init_fringe):
+       * lisp.h (memsetnil):
+       * xdisp.c (init_iterator):
+       Simplify by assuming that Qnil is zero, but verify the assumption.
+       * lisp.h (NIL_IS_ZERO): Revert back to this symbol, removing
+       NIL_IS_NONZERO.  All uses changed.
+
 2015-01-20  Jan Djärv  <address@hidden>
 
        * nsterm.m (EV_TRAILER2): Set Vinhibit_quit to Qt (Bug#19531).
diff --git a/src/alloc.c b/src/alloc.c
index d758ca1..bf0456c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3175,10 +3175,9 @@ allocate_pseudovector (int memlen, int lisplen,
   eassert (lisplen <= (1 << PSEUDOVECTOR_SIZE_BITS) - 1);
 
   /* Only the first LISPLEN slots will be traced normally by the GC.
-     If Qnil is nonzero, clear the non-Lisp data separately.  */
+     Since Qnil == 0, we can memset Lisp and non-Lisp data at one go.  */
+  verify (NIL_IS_ZERO);
   memsetnil (v->contents, zerolen);
-  if (NIL_IS_NONZERO)
-    memset (v->contents + lisplen, 0, (zerolen - lisplen) * word_size);
 
   XSETPVECTYPESIZE (v, tag, lisplen, memlen - lisplen);
   return v;
diff --git a/src/callint.c b/src/callint.c
index 43566ac..3a595b5 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -509,9 +509,8 @@ invoke it.  If KEYS is omitted or nil, the return value of
   visargs = args + nargs;
   varies = (signed char *) (visargs + nargs);
 
+  verify (NIL_IS_ZERO);
   memset (args, 0, nargs * (2 * word_size + 1));
-  if (NIL_IS_NONZERO)
-    memsetnil (args, nargs * 2);
 
   GCPRO5 (prefix_arg, function, *args, *visargs, up_event);
   gcpro3.nvars = nargs;
diff --git a/src/dispnew.c b/src/dispnew.c
index 06b34d8..9af0ae5 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1339,15 +1339,14 @@ realloc_glyph_pool (struct glyph_pool *pool, struct dim 
matrix_dim)
       ptrdiff_t old_nglyphs = pool->nglyphs;
       pool->glyphs = xpalloc (pool->glyphs, &pool->nglyphs,
                              needed - old_nglyphs, -1, sizeof *pool->glyphs);
+
+      /* Redisplay relies on nil as the object of special glyphs
+        (truncation and continuation glyphs and also blanks used to
+        extend each line on a TTY), so verify that memset does this.  */
+      verify (NIL_IS_ZERO);
+
       memset (pool->glyphs + old_nglyphs, 0,
              (pool->nglyphs - old_nglyphs) * sizeof *pool->glyphs);
-
-      /* Set the object of each glyph to nil.  Redisplay relies on
-        this for objects of special glyphs (truncation and continuation
-        glyphs and also blanks used to extend each line on a TTY).  */
-      if (NIL_IS_NONZERO)
-       for (ptrdiff_t i = old_nglyphs; i < pool->nglyphs; i++)
-         pool->glyphs[i].object = Qnil;
     }
 
   /* Remember the number of rows and columns because (a) we use them
diff --git a/src/fringe.c b/src/fringe.c
index a494f68..464379d 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1727,9 +1727,8 @@ init_fringe (void)
 
   fringe_bitmaps = xzalloc (max_fringe_bitmaps * sizeof *fringe_bitmaps);
 
+  verify (NIL_IS_ZERO);
   fringe_faces = xzalloc (max_fringe_bitmaps * sizeof *fringe_faces);
-  if (NIL_IS_NONZERO)
-    memsetnil (fringe_faces, max_fringe_bitmaps);
 }
 
 #ifdef HAVE_NTGUI
diff --git a/src/lisp.h b/src/lisp.h
index 119257b..8967d6e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1503,22 +1503,18 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object 
val)
   XVECTOR (array)->contents[idx] = val;
 }
 
-/* True if Qnil's representation is nonzero.  This is always false currently,
-   but there is fallback code for hypothetical alternative implementations.
-   Compile with -DNIL_IS_NONZERO to test the fallback code.  */
-#ifndef NIL_IS_NONZERO
-enum { NIL_IS_NONZERO = XLI_BUILTIN_LISPSYM (iQnil) != 0 };
-#endif
+/* True, since Qnil's representation is zero.  Every place in the code
+   that assumes Qnil is zero should verify (NIL_IS_ZERO), to make it easy
+   to find such assumptions later if we change Qnil to be nonzero.  */
+enum { NIL_IS_ZERO = XLI_BUILTIN_LISPSYM (iQnil) == 0 };
 
 /* Set a Lisp_Object array V's N entries to nil.  */
 INLINE void
 memsetnil (Lisp_Object *v, ptrdiff_t n)
 {
   eassert (0 <= n);
+  verify (NIL_IS_ZERO);
   memset (v, 0, n * sizeof *v);
-  if (NIL_IS_NONZERO)
-    for (ptrdiff_t i = 0; i < n; i++)
-      v[i] = Qnil;
 }
 
 /* If a struct is made to look like a vector, this macro returns the length
diff --git a/src/xdisp.c b/src/xdisp.c
index 9abaeb0..9611952 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2747,17 +2747,12 @@ init_iterator (struct it *it, struct window *w,
     }
 
   /* Clear IT.  */
+
+  /* The code assumes it->object and other Lisp_Object components are
+     set to nil, so verify that memset does this.  */
+  verify (NIL_IS_ZERO);
   memset (it, 0, sizeof *it);
-  if (NIL_IS_NONZERO)
-    {
-      it->string = Qnil;
-      it->from_overlay = Qnil;
-      it->slice.x = it->slice.y = it->slice.width = it->slice.height = Qnil;
-      it->space_width = Qnil;
-      it->font_height = Qnil;
-      it->object = Qnil;
-      it->bidi_it.string.lstring = Qnil;
-    }
+
   it->current.overlay_string_index = -1;
   it->current.dpvec_index = -1;
   it->base_face_id = remapped_base_face_id;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]