]> code.delx.au - gnu-emacs/commitdiff
Undo port to hypothetical nonzero Qnil case
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 20 Jan 2015 21:56:14 +0000 (13:56 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 20 Jan 2015 21:56:46 +0000 (13:56 -0800)
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
src/alloc.c
src/callint.c
src/dispnew.c
src/fringe.c
src/lisp.h
src/xdisp.c

index a320e22c65ced621e0dc78e2c52fd987bc87b469..e5e4fe9edb0b6d146e0a4f8aaee83b324c5a0605 100644 (file)
@@ -1,3 +1,18 @@
+2015-01-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       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  <jan.h.d@swipnet.se>
 
        * nsterm.m (EV_TRAILER2): Set Vinhibit_quit to Qt (Bug#19531).
index d758ca18a7bc1c7e6e58757e2cb9864350eeed00..bf0456c6862f29cd8f74b6935529d714419d2744 100644 (file)
@@ -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;
index 43566acfbe9b35aa1fac2a9667e5737095ebc4d3..3a595b57d7790103f8dc8d121eea35742d8322ae 100644 (file)
@@ -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;
index 06b34d880773e411957e2ce696c81e633338fe55..9af0ae57b2e623d938b49d1e298af442358e31ed 100644 (file)
@@ -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
index a494f681cd7fe7141683b3c47345136199f2a517..464379d0cd09cbf04207ed070022fe5ce70a07fc 100644 (file)
@@ -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
index 119257bc4b9bea7e3e10576f188e8156801125bc..8967d6e56ceca227b8271bb1a733a3920156c513 100644 (file)
@@ -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
index 9abaeb0d77718c3249a3a56c69eeea73040d8d23..9611952e97095bd52db20c5d7c8d0a61eb24071f 100644 (file)
@@ -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;