+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
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;
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;
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");
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);
}
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
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
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
}
/* 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: */
* 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
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'? */
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