summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-01-20 13:56:14 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-01-20 13:56:46 -0800
commit0dd19ac82662c5710e73852f438fd55e1d9225b7 (patch)
tree67074879f366306af045d28f68d208fc2cf1a0ff
parent3a8312d00e59b50e76121cd512177e999c18b06d (diff)
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.
-rw-r--r--src/ChangeLog15
-rw-r--r--src/alloc.c5
-rw-r--r--src/callint.c3
-rw-r--r--src/dispnew.c13
-rw-r--r--src/fringe.c3
-rw-r--r--src/lisp.h14
-rw-r--r--src/xdisp.c15
7 files changed, 35 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a320e22c65..e5e4fe9edb 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -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).
diff --git a/src/alloc.c b/src/alloc.c
index d758ca18a7..bf0456c686 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 43566acfbe..3a595b57d7 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 06b34d8807..9af0ae57b2 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 a494f681cd..464379d0cd 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 119257bc4b..8967d6e56c 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 9abaeb0d77..9611952e97 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;