]> git.eshelyaron.com Git - emacs.git/commitdiff
Port to hypothetical case where Qnil is nonzero
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 20 Jan 2015 00:49:11 +0000 (16:49 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 20 Jan 2015 01:17:30 +0000 (17:17 -0800)
* alloc.c (allocate_pseudovector):
* callint.c (Fcall_interactively):
* coding.c (syms_of_coding):
* dispnew.c (realloc_glyph_pool):
* fringe.c (init_fringe):
* lisp.h (memsetnil):
* xdisp.c (init_iterator):
Port to the currently-hypothetical case where Qnil is nonzero.
* dispnew.c (adjust_glyph_matrix): Remove unnecessary verification,
as there are no Lisp_Object values in the data here.
* lisp.h (NIL_IS_NONZERO): New symbol, replacing NIL_IS_ZERO.
All uses changed.  Define only if not already defined, so that one
can debug with -DNIL_IS_NONZERO.
* xdisp.c (init_iterator): Remove unnecessary initializations to 0.

src/ChangeLog
src/alloc.c
src/callint.c
src/coding.c
src/dispnew.c
src/fringe.c
src/lisp.h
src/xdisp.c

index f6a5f3837a39580492dd36550ffa02d2d48bbe79..b77f00c21c55b041ce735e4d045daaf967d39e96 100644 (file)
@@ -1,3 +1,21 @@
+2015-01-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Port to hypothetical case where Qnil is nonzero
+       * alloc.c (allocate_pseudovector):
+       * callint.c (Fcall_interactively):
+       * coding.c (syms_of_coding):
+       * dispnew.c (realloc_glyph_pool):
+       * fringe.c (init_fringe):
+       * lisp.h (memsetnil):
+       * xdisp.c (init_iterator):
+       Port to the currently-hypothetical case where Qnil is nonzero.
+       * dispnew.c (adjust_glyph_matrix): Remove unnecessary verification,
+       as there are no Lisp_Object values in the data here.
+       * lisp.h (NIL_IS_NONZERO): New symbol, replacing NIL_IS_ZERO.
+       All uses changed.  Define only if not already defined, so that one
+       can debug with -DNIL_IS_NONZERO.
+       * xdisp.c (init_iterator): Remove unnecessary initializations to 0.
+
 2015-01-19  Eli Zaretskii  <eliz@gnu.org>
 
        * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that
index 2c7b02f11583caeba643bdcf2b000605efcdda49..d758ca18a7bc1c7e6e58757e2cb9864350eeed00 100644 (file)
@@ -3175,9 +3175,10 @@ 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.
-     But since Qnil == 0, we can memset Lisp_Object slots as well.  */
-  verify (NIL_IS_ZERO);
-  memset (v->contents, 0, zerolen * word_size);
+     If Qnil is nonzero, clear the non-Lisp data separately.  */
+  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 3a595b57d7790103f8dc8d121eea35742d8322ae..43566acfbe9b35aa1fac2a9667e5737095ebc4d3 100644 (file)
@@ -509,8 +509,9 @@ 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 77cea77cef56c1cad059bb37680912f592310020..b95c0a5f82537703b7698e9e92b726338034f3b3 100644 (file)
@@ -11272,8 +11272,8 @@ internal character representation.  */);
     Vtranslation_table_for_input = Qnil;
 
   {
-    verify (NIL_IS_ZERO);
-    Lisp_Object args[coding_arg_undecided_max] = { LISP_INITIALLY_ZERO, };
+    Lisp_Object args[coding_arg_undecided_max];
+    memsetnil (args, ARRAYELTS (args));
 
     Lisp_Object plist[16];
     plist[0] = intern_c_string (":name");
index 4aaf6db3a86d9269bbfa8086fb82fe9998ae4303..e76be21dcdcc21c70f7c6ba7c58f3cff3ed38f10 100644 (file)
@@ -418,7 +418,6 @@ adjust_glyph_matrix (struct window *w, struct glyph_matrix *matrix, int x, int y
         relies on the object of special glyphs (truncation and
         continuation glyps and also blanks used to extend each line
         on a TTY) to be nil.  */
-      verify (NIL_IS_ZERO);
       memset (matrix->rows + old_alloc, 0,
              (matrix->rows_allocated - old_alloc) * sizeof *matrix->rows);
     }
@@ -1345,14 +1344,15 @@ 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);
-      /* As a side effect, this sets the object of each glyph to nil,
-        so verify we will indeed get that.  Redisplay relies on the
-        object of special glyphs (truncation and continuation glyps
-        and also blanks used to extend each line on a TTY) to be
-        nil.  */
-      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 464379d0cd09cbf04207ed070022fe5ce70a07fc..a494f681cd7fe7141683b3c47345136199f2a517 100644 (file)
@@ -1727,8 +1727,9 @@ 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 a1ea35574c355ee3781bc1339c54b76ce76010e5..119257bc4b9bea7e3e10576f188e8156801125bc 100644 (file)
@@ -1503,18 +1503,22 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
   XVECTOR (array)->contents[idx] = val;
 }
 
-/* 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 };
+/* 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
 
-/* Set a Lisp_Object array V's SIZE entries to nil.  */
+/* Set a Lisp_Object array V's N entries to nil.  */
 INLINE void
-memsetnil (Lisp_Object *v, ptrdiff_t size)
+memsetnil (Lisp_Object *v, ptrdiff_t n)
 {
-  eassert (0 <= size);
-  verify (NIL_IS_ZERO);
-  memset (v, 0, size * sizeof *v);
+  eassert (0 <= n);
+  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 2442367d3b51c6d9eb4a5e46f82589d0aaaa13e3..8d53274fd7ba9ceb4e0ecbddddb7266666a45775 100644 (file)
@@ -2747,19 +2747,22 @@ init_iterator (struct it *it, struct window *w,
     }
 
   /* Clear IT.  */
-  /* As a side effect, this sets it->object to nil, so verify we will
-     indeed get that.  */
-  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;
-  it->string = Qnil;
   IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1;
   it->paragraph_embedding = L2R;
-  it->bidi_it.string.lstring = Qnil;
-  it->bidi_it.string.s = NULL;
-  it->bidi_it.string.bufpos = 0;
   it->bidi_it.w = w;
 
   /* The window in which we iterate over current_buffer:  */
@@ -2780,7 +2783,6 @@ init_iterator (struct it *it, struct window *w,
                                  * FRAME_LINE_HEIGHT (it->f));
       else if (it->f->extra_line_spacing > 0)
        it->extra_line_spacing = it->f->extra_line_spacing;
-      it->max_extra_line_spacing = 0;
     }
 
   /* If realized faces have been removed, e.g. because of face
@@ -2792,10 +2794,6 @@ init_iterator (struct it *it, struct window *w,
   if (FRAME_FACE_CACHE (it->f)->used == 0)
     recompute_basic_faces (it->f);
 
-  /* Current value of the `slice', `space-width', and 'height' properties.  */
-  it->slice.x = it->slice.y = it->slice.width = it->slice.height = Qnil;
-  it->space_width = Qnil;
-  it->font_height = Qnil;
   it->override_ascent = -1;
 
   /* Are control characters displayed as `^C'?  */
@@ -2833,21 +2831,19 @@ init_iterator (struct it *it, struct window *w,
   it->tab_width = SANE_TAB_WIDTH (current_buffer);
 
   /* Are lines in the display truncated?  */
-  if (base_face_id != DEFAULT_FACE_ID
-      || it->w->hscroll
-      || (! WINDOW_FULL_WIDTH_P (it->w)
-         && ((!NILP (Vtruncate_partial_width_windows)
-              && !INTEGERP (Vtruncate_partial_width_windows))
-             || (INTEGERP (Vtruncate_partial_width_windows)
-                 /* PXW: Shall we do something about this?  */
-                 && (WINDOW_TOTAL_COLS (it->w)
-                     < XINT (Vtruncate_partial_width_windows))))))
+  if (TRUNCATE != 0)
     it->line_wrap = TRUNCATE;
-  else if (NILP (BVAR (current_buffer, truncate_lines)))
+  if (base_face_id == DEFAULT_FACE_ID
+      && !it->w->hscroll
+      && (WINDOW_FULL_WIDTH_P (it->w)
+         || NILP (Vtruncate_partial_width_windows)
+         || (INTEGERP (Vtruncate_partial_width_windows)
+             /* PXW: Shall we do something about this?  */
+             && (XINT (Vtruncate_partial_width_windows)
+                 <= WINDOW_TOTAL_COLS (it->w))))
+      && NILP (BVAR (current_buffer, truncate_lines)))
     it->line_wrap = NILP (BVAR (current_buffer, word_wrap))
       ? WINDOW_WRAP : WORD_WRAP;
-  else
-    it->line_wrap = TRUNCATE;
 
   /* Get dimensions of truncation and continuation glyphs.  These are
      displayed as fringe bitmaps under X, but we need them for such