From: Paul Eggert Date: Tue, 20 Jan 2015 00:49:11 +0000 (-0800) Subject: Port to hypothetical case where Qnil is nonzero X-Git-Tag: emacs-25.0.90~2592^2~18 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=347e01447194e511daaeee8835bcb86d2505e642;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index f6a5f3837a3..b77f00c21c5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2015-01-20 Paul Eggert + + 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 * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool): Verify that diff --git a/src/alloc.c b/src/alloc.c index 2c7b02f1158..d758ca18a7b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -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; diff --git a/src/callint.c b/src/callint.c index 3a595b57d77..43566acfbe9 100644 --- a/src/callint.c +++ b/src/callint.c @@ -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; diff --git a/src/coding.c b/src/coding.c index 77cea77cef5..b95c0a5f825 100644 --- a/src/coding.c +++ b/src/coding.c @@ -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"); diff --git a/src/dispnew.c b/src/dispnew.c index 4aaf6db3a86..e76be21dcdc 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -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 diff --git a/src/fringe.c b/src/fringe.c index 464379d0cd0..a494f681cd7 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -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 diff --git a/src/lisp.h b/src/lisp.h index a1ea35574c3..119257bc4b9 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -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 diff --git a/src/xdisp.c b/src/xdisp.c index 2442367d3b5..8d53274fd7b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -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